DOCXReadWrite Appended document looses images and page break
Posted: Fri Feb 12, 2021 12:08 pm
I have a request for a template to be copied/repeated and filled in one document many times. Effectively importing many time the template in one docx.
I read the template and i putt it i a new document but the i loose the images of the template in the process
the code i use is as bellow
tDOCX := TDOCXReadWriteVcl.Create(Nil);
tDOCX.LoadFromFile(mytemplate); //read from template.
wDocx := TDOCXReadWriteVcl.Create(Nil); //create a new working document
wDocx.Editor.Clear;
try
wDocx.Editor.Assign(tDOCX.Editor); // assign template to working doc
finally
end;
……
Loop // while db not eof
Begin
….
….
wDOCX.Editor.Paras.Last.InsertBreak(acrbtPageBreak,wDOCX.Editor.Paras.Last.EndOfParaPos);
wDocx.Editor.Append(tDOCX.Editor); // append template to working doc
…..
End;
wDOCX.SaveToFile(myoutputfile);
One strange thing also . In the template i have a page break in the end of the template that is not inserted in main document.
we could insert the page break manually (we will try that and come back to you) but the Assign does not seem to
Please inform us about these issues.
Thanks in advance
I read the template and i putt it i a new document but the i loose the images of the template in the process
the code i use is as bellow
tDOCX := TDOCXReadWriteVcl.Create(Nil);
tDOCX.LoadFromFile(mytemplate); //read from template.
wDocx := TDOCXReadWriteVcl.Create(Nil); //create a new working document
wDocx.Editor.Clear;
try
wDocx.Editor.Assign(tDOCX.Editor); // assign template to working doc
finally
end;
……
Loop // while db not eof
Begin
….
….
wDOCX.Editor.Paras.Last.InsertBreak(acrbtPageBreak,wDOCX.Editor.Paras.Last.EndOfParaPos);
wDocx.Editor.Append(tDOCX.Editor); // append template to working doc
…..
End;
wDOCX.SaveToFile(myoutputfile);
One strange thing also . In the template i have a page break in the end of the template that is not inserted in main document.
we could insert the page break manually (we will try that and come back to you) but the Assign does not seem to
Please inform us about these issues.
Thanks in advance