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

Positions Of Every First Line in All Pages Of A Document

1 Answer 68 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Uluc Efe
Top achievements
Rank 1
Uluc Efe asked on 21 Oct 2015, 03:16 PM

Hi,

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.

Code:

01.for (int i = 2; i <= pageCount; i++)
02.{
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.    }
09.}

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.

Regards.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 26 Oct 2015, 10:12 AM
Hello ,

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.

Regards,
Todor
Telerik
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
Tags
RichTextBox
Asked by
Uluc Efe
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or