DOCXReadWrite Appended document looses images and page break

Questions and answers on how to use DOCXReadWrite
Post Reply
eteoklis
Posts: 31
Joined: Wed Feb 03, 2021 10:42 am

DOCXReadWrite Appended document looses images and page break

Post 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
eteoklis
Posts: 31
Joined: Wed Feb 03, 2021 10:42 am

Re: DOCXReadWrite Appended document looses images and page break

Post 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);
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: DOCXReadWrite Appended document looses images and page break

Post by larsa »

Hello

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

Code: Select all

DOCX.Editor.AppendPara.AppendBreak(acrbtPageBreak);
Lars Arvidsson, Axolot Data
eteoklis
Posts: 31
Joined: Wed Feb 03, 2021 10:42 am

Re: DOCXReadWrite Appended document looses images and page break

Post by eteoklis »

Thanks for the fast reply.
Post Reply