Rank: Newbie Groups: Member
Joined: 4/19/2016 Posts: 7
|
Hi,
I've been tasked with adding custom page header+footer to a PDF document we render using HTML to PDF.
One of the design requirements are to use a custom font, but I cannot install the font on the systems where this runs, so I am embedding the font in our HTML by using data-uris.
This works fine, but for the page header and footer using the headerhtml/footerhtml properties crashes the process with out of memory exceptions, so use the AfterPageRender to be able to embed the font for those areas as well. This seems to work well, no crashes and it looks like it should.
However, performance seems horrendous (convert the HTML to the base document takes 15 seconds, adding the footer+header takes 3 minutes..).
My question is thus: Is there some way to improve the performance of the AfterPageRender call, i.e. can set the renderer to not close the page for writing or something like that? Or is it possible to get access to what the embedded font resource name is so I can use the ACM to add the content instead? (I have no knowledge of internal workings of PDF so this might not be possible at all). When rendering a page, is that considered a single document in the engine so I can use some javascript on document.unload to add this instead somehow?
Thankful for any input, Linus
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Please check if you are using the latest build. The current build has some important optimization with HeaderHtmlFormat/FooterHtmlFormat and that might be able to give you desired result. Another thing you can try to do is to use @font-face CSS instead of data Url. @font-face CSS directive will associate the font file to the Url thus makes it cachable, which can significantly improve performance and reduce memory usage (since when you use data Url a separate copy of the same font data is kept each time you reference it).
Using AfterPageRender event is a good option if you use ACM to render page header/footer. However this is not possible in your case since you need to use custom font.
The header/footer is not in the same document inside the engine as the main content So there is no way for you to use JavaScript to do things between them.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 4/19/2016 Posts: 7
|
Hi,
Yeah, I was afraid that was the case.
Managed to solve it by using another library to pregenerate the PDF document I render HTML to (it supports loading fonts using System.Drawing.FontFamily) and then load that document into EO.PDF for the HtmlToPdf goodness.
Not pretty, but it works just fine so onward I go.
Thanks!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Thanks for the update. Have you tried using latest version + @font-face together + HeaderHtmlFormat/FooterHtmlFormat? That might give you a cleaner solution.
|