Rank: Newbie Groups: Member
Joined: 2/4/2013 Posts: 7
|
Hi, I'm converting HtmlToPdf, but the file size is bigger than what I was hoping. I've read that you can set the Embed Font option to false, but that it's done on the PdfDocument object, not the HtmlToPdf.Options. Based on my below code, I'm not sure I can it. Any ideas?
Code: C#
Directory.CreateDirectory("\\\\<server>\\<share>\\" + this.Session.SessionID.ToString() + "");
string outputFileName = "\\\\<server>\\<share>\\" + this.Session.SessionID.ToString() + "\\" + iNAME + ".pdf";
HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4;
HtmlToPdf.Options.OutputArea = new RectangleF(1.0f, 0.5f, 6.85f, 10.5f);
HtmlToPdf.Options.RepeatTableHeaderAndFooter = false;
HtmlToPdf.Options.BaseUrl = "<baseURL>";
//HtmlToPdf.Options.JpegQualityLevel = 35;
//EO.Pdf.HtmlToPdf.Options.FooterHtmlFormat = "<div style='text-align:right; font-family: Arial'>{page_number} / {total_pages}</div>";
HtmlToPdf.ConvertHtml(iDATA, outputFileName);
Response.Redirect("http://<domain>/<share>/" + this.Session.SessionID.ToString() + "/" + iNAME + ".pdf", false);
Thanks!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Your code looks fine. There are two things that can affect the file size greatly: font and images. You can set EmbedFont to false to reduce the file size slightly, but it won't have a huge impact because EmbedFont only controls whether to embed mostly used fonts. For other fonts, it will be embedded regardless to ensure that the file will be displayed correctly on a target system where the font is not available.
Reducing image quality can have a bigger impact on the final file size. I see that you have tried to set JpegQualityLevel to 35, that should reduce the file size. Also the HTML to PDF converter automatically preserve your image resolution. So for example, if your original images have a very high resolution such as 3000 DPI, then that resolution will be preserved. That creates very high quality output but does takes more space. So you can try to reduce the resolution of your original image and see if it helps.
Finally, if you are using a trial version, the trial message and the font used by the trial message would count some space. You can use our online demo to create a file without the trial message and that should give you a better idea of what size the final file will be.
Thanks!
|