Welcome Guest Search | Active Topics | Sign In | Register

Paragraph have more the 4 lines we need to split less then means don't want to split Options
Tamil
Posted: Tuesday, March 16, 2021 11:24:30 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 4
Case 1 We have paragraph with 4 or more lines this should be splitted 2 lines in the bottom of 1st page and rest of the lines top of 2 page.

case 2 We have paragraph with less then 4 line, this paragraph should not be splitted.

Is there is way to achieve this?
eo_support
Posted: Tuesday, March 16, 2021 12:56:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

This is possible but requires you to write custom paging code to explicitly "tell" the converter where to page. See here for more details on how to do this:

https://www.essentialobjects.com/doc/pdf/htmltopdf/paging.aspx#custom

The basic steps will be:

1. Follow the sample code above to get a Paginator object by calling session.CreatePaginator(). At this point the Paginator's Pages collection already contains the default paging result;
2. Use paginator.Pages[0] to get the top and bottom Y position of the page (for example, 0 - 820);
3. Walk through the DOM tree starting from paginator.Document.Body, then examine each HtmlTextNode's PageBreakLineRanges (which contains an array of YRange objects) to determine where you want to break before that. For example, you may see a HtmlTextNode with 4 YRange objects with the following value:

YRange0: 801 - 820
YRange1: 821 - 840
YRange2: 841 - 860
YRange3: 861 - 880

In this case, the default paging result would break after the first line (since the page height is 820 and it will only fit the first line) and the rest would be pushed to the second page. If you wish text only to break after the second line on the first page, then you will need to "correct" this problem. One way to correct this problem is to push the entire paragraph to the second page. In that case you would decide to break at 800 instead of the default value 820;
4. After you reached this conclusion, you would call the following code to force the paging process to run again from the first page:

Code: C#
paginator.Pages[0].PageAgain(800);


5. This would update the entire Pages collection (since you are redoing it from the first page). At this point you are satisfied with the first page. 6. Now you can repeat the above process on contents on the second page, figuring out where you want to break on the second page, then call:

Code: C#
paginator.Pages[1].PageAgain(position_for_the_end_of_the_second_page);


You would repeat this process until you finish all the pages.

Hope this helps. This is one of the most advanced (and probably least used) features. So please feel free to let us know if you have any more questions.

Also please keep in mind that in our next build, we will support "high resolution rendering" which will multiply all coordinate values by 100 by default, so 800 will become 80000, 810 will become 81000, etc. This will be a breaking change but it is necessary to support sub pixel rendering.

Thanks!
Tamil
Posted: Wednesday, March 17, 2021 1:02:26 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2021
Posts: 4
Thanks for explanation.

We are getting top and bottom Y range values of page based on page content. Means if page have less content Y bottom value will be less. Is there is a way to get max Y value of a page? (e.g : letter size page with top and bottom of 0.2 inches) or can you give us constant Y range values for letter and legal size pages, excluding top and bottom margin?

eo_support
Posted: Wednesday, March 17, 2021 2:36:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

This value is not currently exposed. We will look into it and see if we can expose it.

Generally, when you use custom paging, you can only trim output from each page. This is because the default paging process will always try to fit as much as it can before exceeding the maximum page height. So for example, if the default paging process only fit 10 lines of text, then there is no way for you to call PageAgain to make it fit 11 lines of text since PageAgain will still see that the 11th line would exceed the maximum page height thus push it to the second page. However if you decide that you want to push the 10th line to the next page, then you can do so by calling PageAgain on the Y position of the 10th page.

Thanks
eo_support
Posted: Wednesday, March 17, 2021 2:39:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

You can calculate the full page height with the following formula:

full height in pixel = full height in inches * 72 / paginator.ZoomLevel

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.