[
https://issues.apache.org/jira/browse/PDFBOX-5432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17535021#comment-17535021
]
Tilman Hausherr commented on PDFBOX-5432:
-----------------------------------------
You can put the font in the acroform default resources. The font should not be
subsetted. It might be needed to save first and reload, I remember this was a
problem a few years ago.
A code comment mentions the file from this issue that does just that:
https://gitlab.freedesktop.org/poppler/poppler/issues/6
An alternative would be to write your own appearance handler and pass it to the
annotation.
> Use embedded fonts in text annotations
> --------------------------------------
>
> Key: PDFBOX-5432
> URL: https://issues.apache.org/jira/browse/PDFBOX-5432
> Project: PDFBox
> Issue Type: New Feature
> Affects Versions: 2.0.26
> Reporter: Laurence Urbain
> Priority: Major
>
> Hi,
> We are using pdfbox to add text annotations to a pdf document. Now, we need
> to embed the font used in the annotations to preserve the PDF/A compliance.
> Here is the code snippet we use to create the text annotation :
> {code:java}
> final PDDocument document = new PDDocument();
> final PDPage page = new PDPage();
> document.addPage(page);
> final PDAnnotationMarkup annotation = new PDAnnotationMarkup();
> annotation.getCOSObject().setName(COSName.SUBTYPE,
> PDAnnotationMarkup.SUB_TYPE_FREETEXT);
> annotation.setRectangle(new PDRectangle(200, 600, 100, 20));
> annotation.setContents("some text");
> annotation.setPrinted(true);
> annotation.setDefaultAppearance("/Helv 12 Tf 0 g");
> annotation.constructAppearances(document);
> final List<PDAnnotation> annotations = page.getAnnotations();
> annotations.add(annotation);
> page.setAnnotations(annotations);
> {code}
> It is currently not possible to use an embedded font. From what I can see,
> _PDFreeTextAppearanceHandler_ is building the annotation's appearance
> dictionnary based on the annotation's default appearance or the form's
> default appearance.
> The font is then either retrieved by name from the form default resources, or
> the standard font helvetica is used.
> Would it be possible to pass a _PDFont_ object to the
> annotation/appearanceHandler ?
> That way, we could either choose an embedded font, a reference to an existing
> font (from the page resources for example), or a standard font.
> Thanks for your help
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]