Page 1 of 1

DOCXReadWrite Appended document looses images and page break

Posted: Fri Feb 12, 2021 12:08 pm
by eteoklis
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

Re: DOCXReadWrite Appended document looses images and page break

Posted: Mon Feb 15, 2021 7:40 am
by eteoklis
Hello
After we converted the image to BMP it worked ok.

But the page break we manually input in docx still not working in PDF.

I send the command we use.

FDOCX.Editor.Paras.Last.InsertBreak(acrbtPageBreak,FDOCX.Editor.Paras.Last.EndOfParaPos);

Re: DOCXReadWrite Appended document looses images and page break

Posted: Tue Feb 16, 2021 11:00 am
by larsa
Hello

Page breaks must be added to an empty para. Example:

Code: Select all

DOCX.Editor.AppendPara.AppendBreak(acrbtPageBreak);

Re: DOCXReadWrite Appended document looses images and page break

Posted: Wed Feb 17, 2021 3:13 pm
by eteoklis
Thanks for the fast reply.