Hi @Constantine,
Sorry for not clarifying my view on what “components” are.
My interpretation of “components” is pieces of .docbuilder that insert a predefined structure into the document. For example, a component could be a generateImageAndText.docbuilder file that generates an image and a predefined text with some placeholders (e.g., explaining the image). This component needs information for the image (URL, width, and height) and the values to place in the text, like so:
builder.SetProperty("--argument", "{"imageURL" : "image.com", "witdh" : 100, "height" : 100, "textValue1" : "something", "textValue2" : "else" }")
Similarly, I have another component, generateParagraphs.docbuilder, that generates some paragraphs with the provided document builder, with arguments like:
builder.SetProperty("--argument", "{"array" : ["Paragraph1","Paragraph2"] }")
Now, I want to create a document using these components, for example: Image and Text, paragraphs, and another Image and Text. In this case, the argument names for the first and last Image and Text will be the same (because these components are generic), so I can’t call only one builder.SetProperty(“–argument”, (…)) with all the arguments values. Soo i tried to generate the document like this:
def generateFile(docName, docType, dstPath):
builder = docbuilder.CDocBuilder()
builder.CreateFile(docType)
builder.SetProperty("--argument", {"imageInfo" : [Array with the image info], "textValue1" : "something", "textValue2" : "else"})
builder.Run('generateImageAndText.docbuilder')
builder.SetProperty("--argument", {"array" : ["paragraph1", "paragraph2"]})
builder.Run('generateParagraphs.docbuilder')
builder.SetProperty("--argument", {"imageInfo" : [Array with another image info], "textValue1" : "nothing", "textValue2" : "else2"})
builder.Run('generateImageAndText.docbuilder')
builder.SaveFile(docType, dstPath)
builder.CloseFile()
However, the problem is that only the first .docbuilder script received its arguments; the others appear as “undefined” or are not generated at all.
The only solution I found to use this method is to save the file and open it again after running each .docbuilder. But I find this solution inelegant because of the constant reading and writing of the files.
Keep in mind that no .docbuilder creates or saves the file; that part is handled by the Python code, and only one document is generated. I also know this is not the standard way of using this library!