Welcome Guest Search | Active Topics | Sign In | Register

How to add existing HtmlToPdfResult to another page Options
Brad Mathews
Posted: Tuesday, July 16, 2013 5:26:20 PM
Rank: Advanced Member
Groups: Member

Joined: 6/19/2013
Posts: 38
Hi,

I am adding headers and footers to my converted doc using an AfterRenderPage handler.

I am doing a HtmlToPdf.ConvertHtml on each footer because I have page numbers and each footer is different.

However, the header does not change as often and rather than waste resources converting the header each time, I want to remember the HtmlToPdfResult of the conversion and simply add it to each page.

I can't figure it out. I first tried:

Code: Visual Basic.NET
e.Page.Contents.Add(HeaderResult.PdfDocument.Pages(0).Contents(0))


But I got the error: The object already has an owner. Please use a clone of the object instead

So I dug around and tried this to clone the document:

Code: Visual Basic.NET
e.Page.Contents.Add(HeaderResult.PdfDocument.Clone(0, 1).Pages(0).Contents(0))


But I get the same error.

So what is the correct way to add an existing HtmlToPdfResult to a page?

Thanks,
Brad
eo_support
Posted: Wednesday, July 17, 2013 2:16:42 PM
Rank: Administration
Groups: Administration

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

You will not be able to do that. an HtmlToPdfResult object is tied to a specific PdfDocument. So you can not merge one into another.

If performance is an issue for you, you can use the ACM interface to create page header/footer. The ACM interface does not run the HTML parser so it's much faster.

Thanks!
Brad Mathews
Posted: Wednesday, July 17, 2013 2:58:02 PM
Rank: Advanced Member
Groups: Member

Joined: 6/19/2013
Posts: 38
In my case, ACM is not really an option, need to keep everything in html.

I looked but did not find any way to add (overlay) a file or other page to a current page. That is how I currently handle it in the PDF library that yours is replacing. I make a header, save it and then overlay it onto each page that needs it.

I would like to put in an official vote for adding this feature. Maybe you could even do something like it internally for your auto headers/footers. If the source of the header/footer has not changed, just copy what has already been rendered.

- Brad
eo_support
Posted: Wednesday, July 17, 2013 5:23:02 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Yes. Certainly we will keep that in mind. Thank you very much for your feedback!


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.