Positions Of Every First Line in All Pages Of A Document

2 posts, 0 answers
  1. Uluc Efe
    Uluc Efe avatar
    1 posts
    Member since:
    Jun 2015

    Posted 21 Oct 2015 Link to this post


    We are exporting the documents created in RadRichTextBox to PDF files. Then we add a Barcode on the upper right of pages as a new layer. We need to check if the Barcode borders intersects with any document element (text, table, image, etc.) in the document. 

    First Approach: We ​try to set the caret position to first line, then set to line ending, get the location and check if it intersects with Barcode border.

    Problem with this approach: When we get the location of caret position, it returns position offset to the RadRichTextBox control. But we need the offset coordinates ​to the page borders.


    01.for (int i = 2; i <= pageCount; i++)
    03.    RadEditor.Document.CaretPosition.MoveToPage(i);
    04.    RadEditor.Document.CaretPosition.MoveToCurrentLineEnd();
    05.    if ((RadEditor.Document.CaretPosition.Location.X) > 700 && (RadEditor.Document.CaretPosition.Location.Y) < 100)
    06.    {
    07.        // barcode border intersects with the text in the document
    08.    }

    Second Approach: We can use GetLayoutBoxByPosition method to check if there is an element at the coordinates we will add Barcode border.

    Problem with this approach: We should give the position offset ​to the RadRichTextBox but we need to give the position offset to the page borders.

    I've attached ​3 images to describe the problem more clearly.


  2. Todor
    Todor avatar
    168 posts

    Posted 26 Oct 2015 Link to this post

    Hello Uluc,

    Thank you for the sent attachments.

    One of the possible solutions is that to add the barcode in the Headers/Footers of a document. This will also be great if the barcode is same for all pages. However, this depends on the concrete scenario. 

    About using a custom layer - you could use the implementation of the attached to this post BarcodeLayer which illustrates the described scenario when the layout boxes are used.

    About getting the coordinates you need, you could get into the calculations the RadRichTextBox's ViewportWidth, ViewportHeight and the RadDocument's associated DocumentLayoutBox.

    I hope this helps.
    If you need further assistance, please get back to us again.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top