Hi there,
I am trying to get content from one document and insert into another document (DOCXF) but I am having trouble when using GlobalVariable with oDocument.GetElement(i).Copy() as it crashes the document builder.
I was able to use ToJSON and FromJSON, however, all the form fields were transformed into shapes and I couldn’t get them to be fillable.
Code Snippet:
builder.OpenFile("C:path/to/test_standard.docxf", "");
var template = [];
var document = Api.GetDocument(); // get current document
var n = document.GetElementsCount();
for (var i = 0; i < n; i++) {
var element = document.GetElement(i);
template.push(element.Copy());
};
GlobalVariable["template"] = template;
builder.CloseFile();
builder.OpenFile("path/to/test_template.docxf", "");
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
var template = GlobalVariable["template"];
var clone = []; // start the cloned page
for (var i = 0; i < template.length; i++) {
clone.push(template[i].Copy()); // copy each element of the template
};
oDocument.InsertContent(clone); // apend the cloned content
builder.SaveFile("docxf", "path/to/test_530.docxf");
builder.CloseFile();
I need help getting through this.
Kind Regards,
Diogo.