in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

RenderText on lastpage after Renderdirect

Last post 03-24-2008 2:49 PM by C1_Dima. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-20-2008 4:54 AM

    RenderText on lastpage after Renderdirect

    After renderdirect of a richtext there are some other objects like text, graphics and so...

    They should be located on a specific position on the last page after printing the rtftext.

    It works with renderblock, but I can't set the positon of the rtftext. It doesn't work with renderdirect, but I can set the positon of rtftext.

    How can I set the page after renderdirect to print further objects, see sample.

    Thanks regards 

     

  • 03-24-2008 2:49 PM In reply to

    Re: RenderText on lastpage after Renderdirect

    To use RenderDirect to render to a specific page of the document, you have to specify the page in the "Y" argument of the RenderDirect method (which, BTW, is shown in the sample you used to try your code). Note the code that is used in that sample to call RenderDirect:

            ' now get coordinates of last fragment of RTF object and render text under it
            Dim lastFragment As RenderFragment = rt.Fragments(rt.Fragments.Count - 1)
            Dim X As String = "50mm"
            Dim y As String = String.Format(CultureInfo.InvariantCulture, "page{0}.top + {1}doc", lastFragment.Page.PageNo, lastFragment.Bounds.Height)
            txt.Width = "120mm"
            doc.RenderDirect(X, y, txt)

    If you use the debugger to see what "y" resolves to at runtime, you'll see something like "page3.top + 605.625doc" (actual values from a run on my system). The "page3.top" part tells RenderDirect that the object should be located on page 3 of the document. So, here's the modified version of your code that works:

            'this text should be on the page lastfragment.page.pageno, it was always on the first page
            Dim rlt As RenderText = New RenderText
            rlt.Text = "TEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTT"
            rlt.Style.FontSize = 20

            ' doc.RenderDirect(New Unit(75, UnitTypeEnum.Mm), New Unit(50, UnitTypeEnum.Mm), rlt)
             Dim yy As String = String.Format(CultureInfo.InvariantCulture, "page{0}.top + {1}doc", lastFragment.Page.PageNo, lastFragment.Bounds.Height)
            doc.RenderDirect(New Unit(75, UnitTypeEnum.Mm), yy, rlt)

    Of course, you could write something like: 

           doc.RenderDirect(New Unit(75, UnitTypeEnum.Mm), "page3.top + 50mm", rlt)

    but then your code won't work if the size of the RTF changes. 

    Hope this helps. If I missed the point of your question, please explain. 

     

    Cheers,
    Dima.
Page 1 of 1 (2 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.