Dear Tilman,

Your solution works great.
Thank you so much for solving my problem.

Best wishes

Στις Πέμ 12 Δεκ 2024 στις 1:19 μ.μ., ο/η Tilman Hausherr <
thaush...@t-online.de> έγραψε:

> Hi,
>
> You need to add the font to the default resources and don't subset it,
> here is what I changed in the AddAnnotations example:
>
>              PDAcroForm acroForm =
> document.getDocumentCatalog().getAcroForm();
>              if (acroForm == null)
>              {
>                  acroForm = new PDAcroForm(document);
> document.getDocumentCatalog().setAcroForm(acroForm);
>              }
>              PDResources dr = acroForm.getDefaultResources();
>              if (dr == null)
>              {
>                  dr = new PDResources();
>                  acroForm.setDefaultResources(dr);
>              }
>
>              PDType0Font verdanaFont = PDType0Font.load(document, new
> FileInputStream("c:/windows/fonts/VerdanaPro-Black.ttf"), false);
>              dr.put(COSName.getPDFName("Verdana-Bold"), verdanaFont);
>
> freeTextAnnotation.setDefaultAppearance("/Verdana-Bold 10 Tf 0 0 0 rg");
>
>
>
> Tilman
>
> On 12.12.2024 11:48, TOM TOM wrote:
> > Hi,
> >
> > Using Apache PDFBox 3.0.3 to create Free Text Annotation that contains
> text
> > in Greek, we've come across a problem and would appreciate your help.
> >
> > 1.
> > First we tried to use:
> >
> > annotation.setDefaultAppearance("/Helvetica 10 Tf 0 0 0 rg");
> >
> > Calling annotation.constructAppearances(document);
> >
> > it throws the following exception:
> >
> > SEVERE: java.io.IOException: java.lang.IllegalArgumentException: U+0394
> > ('Deltagreek') is not available in the font Helvetica, encoding:
> > WinAnsiEncoding
> >
> >
> > 2.
> > Next, we tried to use a custom font (Verdana-Bold), having checked that
> it
> > contains the Greek character set.
> >
> > PDType0Font font = PDType0Font.load(document,
> > Annotator.class.getResourceAsStream("/verdanab.ttf"));
> > page.getResources().add(font);
> > annotation.setDefaultAppearance("/Verdana-Bold 10 Tf 0 0 0 rg");
> >
> > Calling font.getBaseFont() returns "Verdana-Bold".
> >
> > Calling annotation.constructAppearances(document);
> >
> > it throws the same exception about Helvetica.
> > It seems that the tool insists on using Helvetica instead of the chosen
> > font.
> >
> > Acrobat Reader displays the Annotation text but using  other readers the
> > text appears corrupted or is not displayed at all.
> >
> > Any idea or recommendation is welcomed.
> > Thank you for your time.
> >
> > Best regards,
> > Thomas Thoma
> >
>

Reply via email to