Welcome Guest Search | Active Topics | Sign In | Register

Rendering {page_number} is more than doubling the output time Options
Exameron
Posted: Monday, February 10, 2014 8:48:41 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
I've tracked down what appears to be the issue with load times.

I'm generating a pdf using html to pdf. I'm rendering the document twice. The first time I build the table of contents, then outputting it a second time.

The pdf is roughly 70-90 pages long.

Rendering the pdf with {page_number} takes 32-35 seconds. By just removing that tag, the same takes 11-14 seconds

Including the page number is important. Is there another way to do this or how can we speed this up?

thanks!
eo_support
Posted: Monday, February 10, 2014 9:19:25 PM
Rank: Administration
Groups: Administration

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

Yes. Using page footer will delay the process significantly because it calls the HTML to PDF converter again on each page. To speed up the process, you can use the ACM interface (PDF Creator) to generate the page footer. ACM interface is much less powerful than the HTML to PDF interface but is much faster. You can take a look of the corresponding help and sample to find more information about how to use it. If you still have any questions, please feel free to ask.

Thanks!
Exameron
Posted: Monday, February 10, 2014 9:24:31 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
Thanks for the quick reply. Would I do this in On_AfterRenderPage ? Do you happen to have an example?
Exameron
Posted: Monday, February 10, 2014 9:30:55 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
Exameron
Posted: Monday, February 10, 2014 9:36:05 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
That worked great - thanks.

Any other ideas for speeding up rendering?

The other biggie seems to be rendering the html twice to get the table of contents:
EO.Pdf.HtmlToPdf.ConvertHtml(html, response.OutputStream, options); gets called twice.

Thanks again.
eo_support
Posted: Tuesday, February 11, 2014 8:15:42 AM
Rank: Administration
Groups: Administration

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

I am not exactly sure what you meant. You will need to call ConvertHtml twice if you want to fill in page numbers for your table of contents and there is no way to avoid calling it twice. However on the second call you do not have to convert the main contents. You can only convert the table of contents. If you do not need page number, then you can simply use HTML links in your table of contents and only call ConvertHtml once.

Thanks!
Exameron
Posted: Tuesday, February 11, 2014 4:47:06 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
Nice - good suggestion. I had been rendering the full report twice.

I found some details on what you meant here: (to help the next guy who comes across this post)
http://www.essentialobjects.com/forum/postst7713_Manually-Adding-TOC--Paging-Issue.aspx
eo_support
Posted: Tuesday, February 11, 2014 4:49:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Great. Thank you very much for posting the link!
Exameron
Posted: Tuesday, February 11, 2014 5:01:45 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
small problem - when I merge my ToC with the main report, the clickable page numbers on the toc don't work. I assume this is because of merging two different documents.

How would I fix this?

thanks!
eo_support
Posted: Tuesday, February 11, 2014 5:14:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Ah...you are right. You will have to reconvert the whole document again together in this case. Sorry for disappointing you. :(
Exameron
Posted: Tuesday, February 11, 2014 5:19:07 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
ahh, that's too bad. There's definitely no other way to make those anchor links work when merging a document?
eo_support
Posted: Tuesday, February 11, 2014 5:38:01 PM
Rank: Administration
Groups: Administration

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

There is a more complicated way to do it but it would require some code. The key is to use this method:

http://www.essentialobjects.com/doc/4/eo.pdf.pdfdocument.merge_overload_2.aspx

When using this method to merge the documents, it will update the corresponding HtmlDocument objects. That makes it possible for you to recreate all the links based on the merged HtmlDocument objects. In order to do so, you would get the corresponding source and target HtmlElement objects from the HtmlDocument objects, then use this method to manually create the link between them:

http://www.essentialobjects.com/doc/4/eo.pdf.htmlelement.createlink_overload_2.aspx

Hope this helps.

Thanks!
Exameron
Posted: Tuesday, February 11, 2014 5:54:17 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
I think I follow what you're saying part of the way.

After rendering the main body of the report, I then render the TOC pdf. While doing that I produce one of these for each item in the list:

HtmlElement elmCustomReportNotesPage = contentResult.HtmlDocument.GetElementById("CustomReportNotesPage");
toc.CustomReportNotesPageNumber = "<a href='#CustomReportNotesPage'>" + elmCustomReportNotesPage.Location.Page.ToString() + "</a>";

That's what I use to write out the number. From what I understand, I would need to somehow write out an HtmlElement at this point?

Then, within each of the reports where I currently have:
<h1 id="CustomReportNotesPage" name="CustomReportNotesPage" style="page-break-before: always;width:600px;" class="report">Custom Report Notes</h1>

I'd need to include something here?

As far as using the correct Merge function, I understand which one you want me to use.

eo_support
Posted: Tuesday, February 11, 2014 6:10:38 PM
Rank: Administration
Groups: Administration

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

You would get the HtmlElement object from the HtmlDocument object. For example:

HtmlElement e = result.HtmlDocument.GetElementById("CustomReportNotesPage");

Thanks!
Exameron
Posted: Tuesday, February 11, 2014 6:15:55 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
I dont suppose you have a code sample with some more details?
eo_support
Posted: Wednesday, February 12, 2014 4:47:52 PM
Rank: Administration
Groups: Administration

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

It will be something like this:

Code: C#
//Convert both documents
PdfDocument doc1 = new PdfDocument();
PdfDocument doc2 = new PdfDocument();
HtmlToPdfResult result1 = HtmlToPdf.ConvertHtml(htmlTableString1, doc1);
HtmlToPdfResult result2 = HtmlToPdf.ConvertHtml(htmlTableString2, doc2);

//Merge them
PdfDocument docMerged = PdfDocument.Merge(result1, result2);

//Get the source and the target
HtmlElement source = result1.HtmlDocument.GetElementById("id1");
PdfPageLocation target = result2.HtmlDocument.GetElementById("id2").Location;

//Create the link
PdfLink link = source.CreateLink(target);
link.Render();


Thanks!
Exameron
Posted: Wednesday, February 12, 2014 11:24:45 PM
Rank: Advanced Member
Groups: Member

Joined: 6/13/2012
Posts: 55
ah, i see. perfect, thx.


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.