|
Rank: Newbie Groups: Member
Joined: 7/31/2012 Posts: 4
|
Hi,
We are using the htmltopdfsession to log in to a secure page & then create a pdf. However, for a 7pg pdf document it is taking over 20 seconds to render. What can we do to improve the performance and minimise the rendering time?
ConvertHtmlToPdfResponse - 02227 loaded login form ConvertHtmlToPdfResponse - 02578 logged in ConvertHtmlToPdfResponse - 08025 loaded pdf url ConvertHtmlToPdfResponse - 18635 rendered pdf ConvertHtmlToPdfResponse - 18805 done
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
A lot of factors can slow down the converter. You can try to simplify your HTML page to see what triggers it. The most common trigger to delay include:
1. Iframes. When your page includes an iframe, the converter will wait for the content of that iframe to be completely loaded. If this is the problem, consider removing the iframe; 2. Images. When your page contains images, the converter will wait for that image to be completely loaded; Also the bigger the image, the longer it takes to convert because the converter has to decode/re-encode the image. If this is the problem, consider using a lower resolution image, or switch the image to jpg format (jpg format is the fastest when converting to PDF); 3. Excessive JavaScript. The converter will run all JavaScript in your page. So if you have excessive JavaScript then it will slow things down ---- for example, if you have some code that loops for thousands of times when the page loads, then that will slow everything down to a halt. If this is the problem, you will need to clean up your JavaScript; 4. Over complicated HTML. A single page of text will render much faster than a page full of overlapping tables. So if your HTML is messy, then you will want to clean up that first;
So basically to improve the performance you will have to improve your HTML source.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/31/2012 Posts: 4
|
Ok Thanks,
I'm now looking into creating our page using the PDFCreator as this has better performance value. However, I do have a couple of questions.
Are we able to use svg files with the AcmImage? Can you give me an example of this?
In the following example I am trying to set up two floating blocks, but when rendered the content of the floating blocks sits below the blocks - not inside. Where am I going wrong?
this.pdfContent = new AcmBlock();
var block = new AcmBlock(); block.Style.BackgroundColor = Color.PaleGreen; var block2 = new AcmBlock(); block2.Style.BackgroundColor = Color.PaleGoldenrod; block2.Style.Width = 4.5f; block2.Style.Left = 0.0f; block2.Children.Add(new AcmText("block2")); var block3 = new AcmBlock(); block3.Style.BackgroundColor = Color.MistyRose; block3.Style.Width = 2f; block3.Style.Left = 4.5f; block3.Children.Add(new AcmText("block3"));
block.Children.Add(block2); block.Children.Add(block3); this.pdfContent.Children.Add(block); this.pdfContent.Children.Add(new AcmPageBreak()); render.Render(this.pdfContent);
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
AcmImage does not support SVG.
When a block is floated, it is TAKEN OUT of its normal layout flow. So when you have all children block of a parent block floated, that parent block would be layouted as if it has no children block. You have to have at least one non-floating children block in order for a parent block to take some space.
You should definitely stick with your HTML and fix your HTML instead. There is no way that you will be able to mimic the layout of a complex HTML file with ACM. ACM is mostly for simple "add on" output, such as header, footer, waterstamp, etc. HTML to PDF should perform quite all right as long as you get your HTML cleaned up.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/31/2012 Posts: 4
|
FYI
The solution we have come up with is to use ConvertHtml. We are using html templates which are read, data is swapped for tags we've added to the html using a simple string replace and then the html is converted into pdf.
This solution gives us the performance we desire while allowing us to use complex html layouts & css for our design. The downside of this is we do need to do additional work to create the pages as opposed to just reusing an existing aspx url.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
You may want to consider using WebClient class to pull the HTML from your existing Url and then pass that HTML to us. That way you do not have to have separate code for each page.
Thanks!
|
|