Reputation: 2310
I am trying to render a PDF from html using ABCPdf. The css contains custom fonts. I have followed the instructions (Using @font-face with ABCPDF? Or other way of getting fonts into PDF? and EmbedFont Function) and I have managed to achieve some level of success by doing the following:
Call the EmbedFont method. As follows.
pdfDoc.Font = pdfDoc.EmbedFont("icomoon Regular", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Bold", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Bold Italic", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Extrabold", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Extrabold Italic", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Italic", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Light", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Light Italic", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Regular", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Semibold", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Open Sans Semibold Italic", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Sanchez Italic", LanguageType.Latin);
pdfDoc.Font = pdfDoc.EmbedFont("Sanchez Regular", LanguageType.Latin);
I am using Gecko engine and pdfDoc.AddImageHtml(html, false, documentWidth, true) to render the pdf
If I view PDF on a computer that has the font installed, it works correctly.
If I view the PDF on a computer that does not have the font installed, only the first font works (icomoon Regular). Why?
Upvotes: 1
Views: 1980
Reputation: 61
I managed to get this right by adding those two options:
doc.HtmlOptions.FontEmbed = true;
doc.HtmlOptions.FontProtection = false;
I had only one special font (icomoon).
Upvotes: 0
Reputation: 2310
I actually did not need the fonts in the end but I believe the issue could have been solved by setting
pdfDoc.HtmlOptions.FontProtection = false;
Upvotes: 0