Welcome Guest Search | Active Topics | Sign In | Register

HtmlToPdf.ConvertHtml on non-Win8 PC yields garbled text using open-type font Options
Michael
Posted: Wednesday, September 24, 2014 11:21:15 AM
Rank: Newbie
Groups: Member

Joined: 8/26/2014
Posts: 5
Hi,
I’m using the following code to generate a PDF document. The font is installed on the computer. On Windows 8 computers, the PDF generates correctly and the text looks normal. If I run this on a non-windows 8 computer (Tried Windows 7, Windows Server 2008 R2), the text in the PDF looks like garbage (extended ASCII characters overlapping characters, nothing at all like what it is supposed to look like.) I’m using the 6.0.10.2 version of the EO.PDF Class Library. On the PCs that I’m having the issue, I can load and view the font in the Windows Font Explorer with no issues. I can open notepad and type text using the font in question and everything looks fine. It’s just when I try to create a PDF using the font that I see issues with the text. Any Ideas?

Font Information:
Font Name: Lavanderia Regular
Version: Version 1.100
OpenType Layout, PostScript Outlines

C# Code to Generate PDF:
PdfDocument doc = new PdfDocument();
doc.Pages.Add();
HtmlToPdfOptions options = new HtmlToPdfOptions();
options.StartPosition = (float)3.25;
HtmlToPdf.ConvertHtml("<div style=\"font-family: 'Lavanderia Regular'; font-size: 22pt; text-align: center;\">1st Quarter 2014</div>", doc.Pages[0], options);
doc.Save(@".\test.pdf");


eo_support
Posted: Wednesday, September 24, 2014 12:32:47 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

Please try to disable UAC on Windows 7. On Windows 7 for some reason the application won't see custom font unless UAC is turned off. If that still does not work, you can try to use custom @font-face CSS directive. That will allow you to load the font directly from a Url/file thus by passing Window's font manager.

Thanks!
Michael
Posted: Wednesday, September 24, 2014 9:00:21 PM
Rank: Newbie
Groups: Member

Joined: 8/26/2014
Posts: 5
Hi,
Thanks for the quick feedback. I’ve tried disabling the UAC which didn’t help. I’d rather try to get the @font-face solution to work because it seems to be a better solution. That being said, I’m having issues getting it to work on any PC. I’ve tried different versions of the following with no luck (the font file is located in the same directory as the executing application). Could you give me some pointers?

Quote:

PdfDocument doc = new PdfDocument();
doc.Pages.Add();

HtmlToPdfOptions options = new HtmlToPdfOptions();
options.StartPosition = (float)3.25;

HtmlToPdf.ConvertHtml(
"<style type='text/css'>"+
"@font-face"+
"{"+
"font-family: lavanderia_regular;"+
"src: url(lavanderia_regular.otf);" +
"}"+
"</style>" +
"<div style='font-family: lavanderia_regular; font-size: 22pt; text-align: center;'>1st Quarter 2014</div>",
doc.Pages[0], options);

doc.Save(@".\Test.pdf");

eo_support
Posted: Wednesday, September 24, 2014 10:24:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

You have to set HtmlToPdf.Options.BaseUrl when you use ConvertHtml. Without BaseUrl, the converter can't expand your partial path (in this case lavanderia_regular.otf) into a full path.

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.