Please give a brief summary of your issue:
Not sure if this can be done by just using the WebViewer.
But the intention here is to match the annotation font with the document’s font.
So we would like to get the font-family, and font-size from the loaded PDF. Then we’ll use the information to set the annotation’s font.
Fonts can be complicated in a PDF as there is a difference between embedded vs the fonts available in the host machine. You can extract embedded fonts using the node SDK or in WebViewer for example. Moreover, the fonts that are available in the PDF are not always available to the webfonts that are used for a FreeText. The current webfonts supported are available in the dropdown that appears when styling a freetext.
If your use case is to perform PDF text edits, then the fonts that are shown in the dropdown are the ones that are available for editing, and at this time this set cannot be augmented. We do however have plans to add support for more fonts in the future.
Apryse Software Inc.
Okay, so we can create the Font by extracting the indirectObj of SDFDoc?
Then from the created Font, we now have access to the Font.getFamilyName() method?
And we can use this when we set the font-family for the FreeTextAnnotation?
Thanks for the quick response and confirming.
The link you provided was helpful!
Currently, we’re getting the font-name by using PDFNet.Font.getName(), although sometimes we noticed that it is inaccurate for some documents. I think this is what you meant by:
Moreover, the fonts that are available in the PDF are not always available to the webfonts that are used for a FreeText
Right? Like we uploaded a document that has Robotic or Lato, but the getName() method will return us "DejaVuSans".
Or is there any more reason for that?
And if it’s possible to get Robotic or Lato instead of DejaVuSans?
Also if it’s possible to get the font-size?
I just noticed that after exporting (exportAnnotations) the FreeTextAnnotations and then importing them back (to view).
The Font and FontSizes did not persist, so they went back to their default value.
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: