[
https://issues.apache.org/jira/browse/PDFBOX-5432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17535987#comment-17535987
]
Laurence Urbain commented on PDFBOX-5432:
-----------------------------------------
Hi [~tilman], thanks for you quick feedback :)
Indeed, if I put the embedded font in the acroform resources, and reference it
by name in default appearance, it is picked up and embedded in the appearence
stream resources.
Though it is a little bit hacky in my opinion to add a font to the acroform
resources while it won't be actually used.
Alos, I have juste realized that the contentStream.setFont() method will always
automatically add the font to the stream resources. So there is no way I can
reference in the appearance stream text a font from the page resources, for
example.
Is it a delibarate limitation? I would think that one might want to reuse the
same embedded font for mulitple annotations (or other streams in the page).
Unless each stream MUST embed its own resource ??
> 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]