This is a migrated thread and some comments may be shown as answers.

Copy content from one RadFixedDocument to another

3 Answers 628 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Jakub
Top achievements
Rank 1
Iron
Jakub asked on 04 Aug 2016, 11:30 AM

Hi,

i have 2 RadFixedDouments and i want to merge them in one RadFixedDocument.

Merge method works ok but i add new page for each of document.

My goal is to create one document which looks like this:

1. Content from *NameOfFirstDocument*:

-- here content --

2. Content from *NameOfSecondDocument*:

-- here content --

 

I almost done this:

- created RadFixedDocument (call it Main),

- used RadFixedDocumentEditor.InsertBlock( block with "1. Content from *NameOfFirstDocument*:" ) on Main document,

- set FixedContentEditor proper position (under block),

- foreach Content element in one and only Page in FirstDocument use FixedContentEditor.Draw to add content (as a TextFragment) on Main document,

- the same things for second document.

The problem is when i'm exporting Main document to pdf, it is cutting content of each document if it is larger than one page.

 

It looks like FixedContentEditor.Draw add lines but it does not take in account page size.

 

Any help with copying content of one RadFixedDocument to other? It's strange i cant use in any of ways a RadFixedDocumentEditor to insert other RadFixedDocument content in next lines.

 

Thanks,

Jacob.

3 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 09 Aug 2016, 08:55 AM
Hello Jakub,

Due to the specifics of the fixed document format and the purpose of the FixedContentEditor class, the behavior you are experiencing is expected. This format doesn't flow the document elements in order to render them in different pages if only one is not enough. This requires you to calculate the available space and check whether the content will fit or you will need to split it on another page.

However, for your scenario it seems like the Merge() method will fit better than manually appending the new content to the main document. Could you give it a try?

Regards,
Tanya
Telerik by Progress

0
Jakub
Top achievements
Rank 1
Iron
answered on 09 Aug 2016, 10:30 AM

Hello Tanya,

thanks for your answer.

Unfortunately, as I said in previous post, Merge() method adds merged document on new page, when i need directly under last line of text.

Now I'm using RadDocument to reach my goal and it works ok with copying Blocks from one document to other or using InsertFragment method.

 

Thanks.

0
Tanya
Telerik team
answered on 11 Aug 2016, 02:45 PM
Hi Jakub,

Another option that you could test is to measure the size that is necessary for the element to render and the remaining space on the current page. If is not enough to draw the whole element, you could split it. There is an example showing how to implement a similar scenario in this forum thread

Of course, with RadDocument could help you achieve the desired goal as well.

Hope this helps. 

Regards,
Tanya
Telerik by Progress

Tags
PdfProcessing
Asked by
Jakub
Top achievements
Rank 1
Iron
Answers by
Tanya
Telerik team
Jakub
Top achievements
Rank 1
Iron
Share this question
or