How to get the font info from a PDF document?

Hi @kim,

Sorry for the delay.

we uploaded a document that has Robotic or Lato , but the getName() method will return us "DejaVuSans" .

The issue will sometimes be that the font is not actually embedded in the PDF, and the viewer will then use a fallback font. I suspect that is why you are seeing DejaVuSans. You can read more about fonts here.

For your latest question, there is a workaround to generate an appearance for a free text, which should be generated with the font you expect. Here is the code:

  const { Annotations } = instance;

  Annotations.setCustomDrawHandler(Annotations.FreeTextAnnotation, (ctx, pageMatrix, rotation, options) => {
    options.originalDraw(ctx, pageMatrix, rotation);
  }, { generateAppearance: true });

The appearance should show the correct font when the doc is downloaded. However, we can also have a look at how you are setting font and fontsize to confirm the issue.

Armando Bollain
Software Developer
Apryse Software Inc.