1

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:

  1. Install the fonts on the server that generates the PDF and reboot.
  2. Remove all @font-face css command.
  3. 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);
    
  4. 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?

0

2 Answers 2

0

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;
Sign up to request clarification or add additional context in comments.

Comments

0

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.