Welcome Guest Search | Active Topics | Sign In | Register

Html To Pdf Custom font issue Options
yogen
Posted: Tuesday, December 16, 2014 9:23:11 AM
Rank: Newbie
Groups: Member

Joined: 12/16/2014
Posts: 6
Hi Support Team,

I am facing problem while convert HTML to PDF.

All Inline rules are apply on PDF perfectly except Font.

I've used Font-family:montserrat in inline css, But for whole PDF it shows me Times new roman.

Please help to resolve Font Issue.

Thanks
eo_support
Posted: Tuesday, December 16, 2014 9:35:20 AM
Rank: Administration
Groups: Administration

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

You will need to either use @font-face to declare the custom font through CSS (basically provide the Url of the font file so that the browser can load it from your server), or have that font installed on your server. Note that this is different from browsing the page on a client's machine. If the font is already installed on the client's machine, then the client's machine will display the font fine. However the converter runs on your server, so in order for the converter to render that font correctly, that font needs to be installed on the server or declared with @font-face so that it can fetch the font data from somewhere.

Thanks!
yogen
Posted: Wednesday, December 17, 2014 5:26:16 AM
Rank: Newbie
Groups: Member

Joined: 12/16/2014
Posts: 6
Hi,

Here is my code.

string html = "<div id=\"main\" style=\"font-size:12px;font-family:Montserrat;color:#0000ff;\"> HEllo </div>";
EO.Pdf.HtmlToPdf.ConvertHtml(html, e.Page);

Other style are working for that Div but font-family is not working, How ever it works fine on ASPX page and shows me "HEllo" in Montserrat style.

I've installed Font in my machine.

Let me know if you need more information for this.

Please help me to resolve my problem.

Thanks,
Yogen






eo_support
Posted: Wednesday, December 17, 2014 9:48:01 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
You need to install the font on your web server. If that does not work, use @font-face instead.

Thanks!
yogen
Posted: Thursday, December 18, 2014 5:35:01 AM
Rank: Newbie
Groups: Member

Joined: 12/16/2014
Posts: 6
Hi,

I've already installed font 'Montserrat' in my machine.

Here is My updated HTML page in C#. The fonts are still Times New Roman on downloaded PDF.

string html = "<!DOCTYPE html><html><head><style>@font-face{font-family:'Montserrat';font-style: normal;font-weight: 100;src: url(http://themes.googleusercontent.com/static/fonts/montserrat/v3/zhcz-_WihjSQC0oHJ9TCYBsxEYwM7FgeyaSgU71cLG0.woff) format('woff');}p{color:green;font-family:'Montserrat'}</style></head><body><p>This is a paragraph.</p></body></html>";

EO.Pdf.HtmlToPdf.ConvertHtml(sample, e.Page);

Please help me to resolve this error. I using iTextSharp for PDF.

Thanks,
Yogen
eo_support
Posted: Thursday, December 18, 2014 9:53:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Where is this code running?
yogen
Posted: Thursday, December 18, 2014 10:57:54 AM
Rank: Newbie
Groups: Member

Joined: 12/16/2014
Posts: 6
Currently, It's in my local machine.

And I am not getting proper font in local machine itself.
eo_support
Posted: Thursday, December 18, 2014 11:05:29 AM
Rank: Administration
Groups: Administration

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

Please check three things:

1. Make sure you are using the latest build of EO.Pdf;
2. Do not use woff. Use ttf instead. If you use a Google font, download the ttf file directly and then use that font file;
3. Turn off Windows User Access Control;

Please let us know if those resolve the issue for you.

Thanks!
yogen
Posted: Friday, December 19, 2014 8:17:00 AM
Rank: Newbie
Groups: Member

Joined: 12/16/2014
Posts: 6
Hi,

I tried all possible way but still no solution. But when I create new ASP.NET website and write down that same text and use EO.Pdf.HtmlToPdf.ConvertHtml(htmlText, PdfFilePath);, It's working fine.

Is there anything related to web.config file or IIS that i used?

Please help me to solve this bizarre behavior.




eo_support
Posted: Friday, December 19, 2014 9:20:51 AM
Rank: Administration
Groups: Administration

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

In that case please use @font-face. @font-face does depends on anything on your system. If that still does not work, you can create a test project demonstrating the problem and send the test project to us. See here for more information on how to set the test project.

http://www.essentialobjects.com/forum/test_project.aspx

Thanks!
yogen
Posted: Friday, December 19, 2014 10:53:19 AM
Rank: Newbie
Groups: Member

Joined: 12/16/2014
Posts: 6
Hi,

My problem is resolved if I run website under "Use Visual Studio Development Server".
But when I switch "Use local IIS web server" then it doesn't work.

I am using Windows 8 PC and IIS 8.5 server.

Is there anything security related problem or need to configure something on IIS?

Thanks for your support, Now just one stet to go.:)







eo_support
Posted: Friday, December 19, 2014 11:41:37 AM
Rank: Administration
Groups: Administration

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

That usually has to do with permission settings. The reason is the user account that you used to run your website does not have enough permission to "see" that font. You can try to turn UAC off to see if it can see the font, or try to log in as that user and then install the font there. If everything fails, your only choice is to use @font-face CSS directive. That option will always work.

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.