Copy content from one RadFixedDocument to another

4 posts, 0 answers
  1. Jakub
    Jakub avatar
    14 posts
    Member since:
    Sep 2015

    Posted 04 Aug Link to this post

    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.

  2. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 09 Aug Link to this post

    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

  3. Jakub
    Jakub avatar
    14 posts
    Member since:
    Sep 2015

    Posted 09 Aug Link to this post

    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.

  4. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 11 Aug Link to this post

    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 the space 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

Back to Top