Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

Performance, Template caching from html Options
Damo
Posted: Wednesday, February 15, 2017 4:37:33 PM
Rank: Newbie
Groups: Member

Joined: 2/15/2017
Posts: 2
Hi,
What I need is something that has very high performance (around 100-300ms per document).
I see that acm pdf creator has very fast performance especially compared to the html to pdf converter. However I want to retain the flexibility of being able to create my pdf templates in html i.e can I generate the document ACM content model using the html to pdf api beforehand cache that somewhere then just use cached acm model when doing my data population say within a web request?

Kind Regards,
Damo
eo_support
Posted: Wednesday, February 15, 2017 4:49:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 18,999
Hi,

Yes. You can do that. You would just pass the template document to the AcmRender object. For example, you will find all the ACM sample code uses a new PdfDocument object such as:

Code: C#
//Create an empty PDF document
PdfDocument doc = new PdfDocument();
            
//Create an ACM Render
AcmRender render = new AcmRender(doc);


You would just change it to:
Code: C#
//Load the template PDF document
PdfDocument doc = new PdfDocument(your_template_file.pdf);
            
//Create an ACM Render
AcmRender render = new AcmRender(doc);


Here your_template_file.pdf would the result file of a previous HTML to PDF conversion. You can also add marker elements in your HTML so that after the HTML to PDF conversion, you can use the marker elements to get the exact location/size of those elements. Such information maybe useful as to where to output your ACM objects. You would get such information through the HtmlToPdfResult object returned by the HTML to PDF converter.

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!

Damo
Posted: Wednesday, February 15, 2017 5:37:11 PM
Rank: Newbie
Groups: Member

Joined: 2/15/2017
Posts: 2
Thanks for the quick reply.
This is awesome. Can you please also tell me how do I navigate a PdfDocument object once loaded? for example say I have a <div id="name">{name to be replaced from model}</div> once this is converted to a PdfDocment how to do I find that particular object to populate its text?

Cheers.
eo_support
Posted: Thursday, February 16, 2017 8:16:22 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 18,999
Hi,

You won't be able to navigate a PdfDocument once it loaded. You can only navigate the result of a HTML to PDF conversion. So for example, if you have code like this:

Code: C#
//Convert HTML to PDF
PdfDocument doc = PdfDocument();
HtmlToPdfResult result = HtmlToPdf.ConvertHtml("<div id='test'>hello</div>", doc);

//Get the location and size of the 'test' DIV
EO.Pdf.HtmlElement e = result.HTMLDocument.GetElementById("test");
EO.Pdf.PdfPageLocation location = e.Location;
System.Drawing.SizeF size = e.Size;


Since your template file and the final file is not necessary generated together, you may want to save the location and size somewhere so that you can use them when you fill in the final files.

Hope this helps.

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.