Welcome Guest Search | Active Topics | Sign In | Register

Performance of various footer/header methods Options
Brad Mathews
Posted: Friday, September 1, 2017 2:22:25 PM
Rank: Advanced Member
Groups: Member

Joined: 6/19/2013
Posts: 38
I have been using the Adding Page Header/Footer After the Conversion technique for a while now but my reports have been getting longer and this technique is quite slow so I am looking for alternatives.

I assume that using AfterRenderPage would not result in better performance because they both still use ConvertHtml. Am I correct in that assumption?

Is using HeaderHtmlFormat/FooterHtmlFormat any faster? Or is it also using ConvertHtml internally? Also, I have not been able to figure out a way to change the header for each page using HeaderHtmlFormat (I have different headers for each section of my document,) but I am a few versions behind, has that changed in recent versions?

I also saw a comment on the forum which indicated that v2016 has better performance with ConvertHtml in this context. If true, how much better could I expect on a 100 page doc?

Thanks,
Brad
eo_support
Posted: Friday, September 1, 2017 3:06:01 PM
Rank: Administration
Groups: Administration

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

Yes. We have optimized this feature specifically in 2016 and again in 2017. You should expect significant performance improvements with the current version (2017). The main difference is how many times the converter is called. In older versions, the converter can be called as many as 2 * page_count + 1 times, with once for the main contents and twice for each page (one for header and one for footer). In the new version, the converter is only called two times in total ---- one for the main contents and one for all header/footers. So not only the performance increase can be significant, it also means the performance no longer degrade rapidly as number of pages grow.

You are correct about AfterRenderPage ---- it won't help because it still calls the converter. This is why the new version's focus is to reduce number of calls to the converter.

Thanks!
Brad Mathews
Posted: Friday, September 15, 2017 12:56:02 PM
Rank: Advanced Member
Groups: Member

Joined: 6/19/2013
Posts: 38
So I am using 2017 now and I am seeing performance degradation with larger files, more so than with 2015.

Maybe I am doing something wrong which doesn't take advantage of your code optimizations?

Here is basically what I am doing:

Code: Visual Basic.NET
For PageNumber = 1 To PageTotal
        Page = result.PdfDocument.Pages(PageNumber - 1)
        AddOverlay(FooterHtml, FooterMargins, Page)
        AddOverlay(HeaderHtml, HeaderMargins, Page)
    Next

    Public Function AddOverlay(HTML As String, margins As TemplateBuilder.Margins, page As PdfPage) As HtmlToPdfResult
        If HTML <> "" Then
            EO.Pdf.HtmlToPdf.Options.BaseUrl = WorkFolder
            EO.Pdf.HtmlToPdf.Options.TriggerMode = EO.Pdf.HtmlToPdfTriggerMode.Auto
            EO.Pdf.HtmlToPdf.Options.PageSize = New SizeF(8.5F, 11.0F)
            EO.Pdf.HtmlToPdf.Options.AutoBookmark = False
            EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(margins.Left, margins.Top, margins.Width, margins.Height)
            Return EO.Pdf.HtmlToPdf.ConvertHtml(HTML, page)
        End If
    End Function


eo_support
Posted: Friday, September 15, 2017 1:23:20 PM
Rank: Administration
Groups: Administration

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

The 2017 optimization is for HtmlToPdf.Options.HeaderHtmlFormat and FooterHtmlFormat property. It will only have performance gain if you use those two properties.

Thanks!
Brad Mathews
Posted: Friday, September 15, 2017 3:17:06 PM
Rank: Advanced Member
Groups: Member

Joined: 6/19/2013
Posts: 38
Boom! That was fast! Almost worth the price of the upgrade all by itself. I would recommend altering the docs to reflect the performance difference between techniques.

One problem though, the first page was numbered 2 and the last page didn't get a footer.

If I set the FirstHeaderFooterPageIndex option to 2 (thanks for that btw, it will come in handy) the numbering starts on page 3 with the page number of 2 and the last page still has no footer.

Setting FirstPageNumber to 1 made no difference and setting it to 3 made the page numbering start at 4.

- Brad
eo_support
Posted: Friday, September 15, 2017 4:27:24 PM
Rank: Administration
Groups: Administration

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

We can't think of anything that can cause that. Please send a test project to us and 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.