Welcome Guest Search | Active Topics | Sign In | Register

pageindex sometimes wrong in HtmlDocument element location (EO PDF) Options
lostfish
Posted: Thursday, April 23, 2020 6:10:28 AM
Rank: Member
Groups: Member

Joined: 6/7/2017
Posts: 13
I'm building a table of contents, to do that i first render html, then loop through the contents to get locations (page index) for the elements in the table of contents, and then rerender the html with the page indexes passed as a parameter to the html (code below).

Sometimes, the returned element location is off by 1 page (index is 1 too low).

It looks like if an element has been pushed to the top of the next page by break-after / break-before css, the returned index is wrong.

(using version 20.0.81)

Here's the code I'm using:

Code: C#
var pageNumbers = new PdfDocument();
            var pageNumbersResult = HtmlToPdf.ConvertUrl(url + "&showPages=np", pageNumbers, options);

            var index = "";
            var i = 0;
            var el = pageNumbersResult.HtmlDocument.GetElementById("h" + i);

            while (el != null && i < 200)
            {
                index += "," + (el.Location.PageIndex + 1);
                i++;
                el = pageNumbersResult.HtmlDocument.GetElementById("h" + i);
            }

            if (index.StartsWith(",")) index = index.Substring(1);


            var pages = new PdfDocument();
            HtmlToPdf.ConvertUrl(url + "&showPages=np&index=" + index, pages, options);


I'm hoping it's just me doing something wrong :)
eo_support
Posted: Friday, April 24, 2020 3:41:49 PM
Rank: Administration
Groups: Administration

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

We tested e.Location.PageIndex and it does work correctly. We can not tell you what could be wrong just from your code. If you continue to have problem, you can create a test project and send the test project to us to demonstrate the problem. See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

Once we have that we will investigate further.

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.