WPCubed Product Support

Is there a way to append one doc content to another other that AppendAsSection

Hello,

For test purposes I use the following simple code to append one document to another several times:

  for var i: System.Integer := 1 to Count do
  begin
    doc1.CPPosition := $FFFFFFF;
    doc1.AppendAsSection(doc2);
    doc1.ReformatAll;
  end;

The result document looks as expected - all content is appended as sections.

But I wonder is there another way to append - not as sections?

Because currently if I want to change (for example) orientation of the result document in MS Word I have to Select All first and then change the orientation. Otherwise the orientation is changed only for a section.

Regards

#1 ♥ 0
6.4k Views 2 users 1 ♥ read 2 min
wpsupport

You can simply call LoadFromFile or LoadFromStream to append (or insert) a document at cursor position.

#2 ♥ 0

And what about inserting a page break in case I'm using LoadFromStream() ?

That was the reason I used AppendAsSection().

I need page breaks between all added documents.

(format is .rtf or .docx)

#3 ♥ 0

Thanks , it works 🙂

I have another question related to performance of appending.

I've done the following test:

  1. Load doc2 from file
  2. Append 100 times to doc1 (which is empty)

**

The code is in my fist post. I've tried also with LoadFromStream() at cursor position.

I noticed that:

  • If I load the content from .rtf-file the time is about 6 minutes (on my computer)
  • If I load the content from .docx**-file the time is about 1 second (on my computer)

Is it possible the reason to be only the format differences ?

Maybe I am missing some specific setting that affects the performance.

Regards

#5 ♥ 0
wpsupport

DOCX will be a lot faster with images since they are not embedded like in RTF but just contained as PNG or JPEG files in a ZIP container.

And of course the call to ReformatAll is not required until the very end, if at all.

#6 ♥ 1
This category is archived. No new posts are possible.