Rank: Member Groups: Member
Joined: 6/26/2012 Posts: 17
|
I am using the .ConvertHTML function and I am using 2 custom fonts on my website "1GDT-SPC Font" & "FCGDT2" both are installed on the server and my system. The webpage displays it correctly but whenever I export to .pdf only the "FCGDT2" font displays correctly. and the "1GDT-SPC Font" displays as Arial, so it acts like its not finding it. I believe it is because there is a space (" ") in the font name causing an escape to happen within your app? Is there any way to check what it is looking for so I know why its not embedding it? or how to manually point to the .tff/.oef files on the server for the pdf?
here is my current code to export
HtmlToPdfOptions myOptions = new HtmlToPdfOptions(); myOptions.MaxLoadWaitTime = 300000000; myOptions.PageSize = new SizeF(11f, 8.5f); // Landscape Letter myOptions.OutputArea = new RectangleF(0.1f, 0.9f, 10.9f, 7.6f); myOptions.AutoFitX = HtmlToPdfAutoFitMode.ShrinkToFit; myOptions.GeneratePageImages = true; myOptions.HeaderHtmlFormat = "<table width='100%' border='0'><tr><td width='80%'><img src='images/Avalign-Nemcomed-red.jpg' border='0' alt=''></td><td width='20%' style='vertical-align:bottom;'><div align='right'>Page: {page_number} of {total_pages}</div></td></tr><tr><td colspan='2'><img alt='' src='images/redline.jpg' style='width: 100%; height: 2px'></td></tr></table><br>"; myOptions.BaseUrl = "http://localhost:64467/"; string strFileName = ""; if (Session["exportfilename"] != null) { strFileName = Session["exportfilename"].ToString() + ".pdf"; } else { strFileName = DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Year + ".pdf"; } Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=" + strFileName); Response.ContentType = "application/pdf";
HtmlToPdf.ConvertHtml("<div style='font-size: 8px'>" + ltReport.Text.ToString() + "</div>", Response.OutputStream, myOptions); Response.End();
this is how I am calling the font
<p> <span style="font-family: fcgdt2,impact,arial,sans-serif">asdasdabbjm8k7j46y7</span></p> this one works
while this one doesn't work <p> <span style="font-family: 1gdt-spc font,impact,arial,sans-serif">sadasd</span></p>
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Please try to put your font name in quotation mark, such as "font-family:'1gdt-spc font',impact,arial,sans-serif". That should resolve the problem for you. Thanks!
|
Rank: Member Groups: Member
Joined: 6/26/2012 Posts: 17
|
that worked thanks!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
You are very welcome. Please feel free to let us know if there is anything else.
|