You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2022/05/13 17:11:00 UTC
[jira] [Reopened] (PDFBOX-5432) Use embedded fonts in text annotations
[ https://issues.apache.org/jira/browse/PDFBOX-5432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr reopened PDFBOX-5432:
-------------------------------------
> 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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org