|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
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!
|
|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
You need to install the font on your web server. If that does not work, use @font-face instead.
Thanks!
|
|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Where is this code running?
|
|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
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!
|
|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
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.aspxThanks!
|
|
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.:)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
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!
|
|