Rank: Newbie Groups: Member
Joined: 2/13/2013 Posts: 2
|
Hi,
Having some concerns about the rendering of HTML document to PDF. I am using the EO.Pdf control in a ASP.NET 4 application my company developed. There are many stylesheets attached to the page and I am concerned if other css attributes are also incorrect. The original page renders perfectly and uses responsive design to render correctly for all media devices. I noticed the pdf document is using the wrong font for the <H1> tag. On the stylesheet file for the html document the <H1> tag has PFDinTextCondPro as its font but the resulting pdf document it appears to be Time New Roman. Here are the details:-
EO.Pdf version: 4.0.54.2 OS: Windows 7 Browser: Chrome, version: 24.0.1312.57 m
C# Code:
public class EOPdfExporter {
public PdfDocument GenerateFromHtml(string html) { PdfDocument doc = new PdfDocument(); HtmlToPdf.ConvertHtml(html, doc); return doc; } }
This is called by the following code in a handler (*.ashx)
private void GeneratePdfFromUrlEOP(HttpContext context) { // Setup var pdfGenerator = new Tools.EOPdfExporter(); var doc = pdfGenerator.GenerateFromUrl(context.Request["url"].Replace("|", "?").Replace(",", "&")); doc = pdfGenerator.as HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ClearHeaders(); response.ContentType = "application/pdf"; response.AppendHeader("Content-Disposition", "attachment; filename=pdfeksport.pdf");
//Send the PdfDocument to the client doc.Save(response.OutputStream);
response.End(); }
|
Rank: Newbie Groups: Member
Joined: 2/13/2013 Posts: 2
|
I have determined the problem. The H1 tag was using a custom font and the font family had no fallbacks. So the pdf creator defaulted to Times Roman.
It would be nice if the control could handle custom fonts like browsers do already.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Thanks for the update. You can use custom font but the font has to be installed on your server. Also when you use ConvertHtml, make sure you set HtmlToPdf.Options.BaseUrl correctly. With BaseUrl it can not resolve relative path, so it won't be able to to resolve external resources such as CSS or image files.
Thanks!
|