2626import org .apache .pdfbox .pdmodel .PDPageContentStream ;
2727import org .apache .pdfbox .pdmodel .PDResources ;
2828import org .apache .pdfbox .pdmodel .font .PDFont ;
29+ import org .apache .pdfbox .pdmodel .font .PDType0Font ;
2930import org .apache .pdfbox .pdmodel .font .PDType1Font ;
3031import org .apache .pdfbox .pdmodel .font .Standard14Fonts .FontName ;
3132import org .apache .pdfbox .pdmodel .graphics .color .PDColor ;
@@ -258,7 +259,8 @@ public static void main(String[] args) throws IOException
258259 freeTextAnnotation .setRectangle (position );
259260 freeTextAnnotation .setTitlePopup ("Sophia Lorem" );
260261 freeTextAnnotation .setSubject ("Lorem ipsum" );
261- freeTextAnnotation .setContents ("Lorem ipsum dolor sit amet, consetetur sadipscing elitr,"
262+ freeTextAnnotation .setContents ("uppercase Δ, lowercase δ\n "
263+ + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr,"
262264 + " sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam "
263265 + "erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea "
264266 + "rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum "
@@ -267,8 +269,8 @@ public static void main(String[] args) throws IOException
267269 + "erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea "
268270 + "rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum "
269271 + "dolor sit amet." );
270- // Text and border in blue RGB color, "Helv " font, 20 point
271- freeTextAnnotation .setDefaultAppearance ("0 0 1 rg /Helv 20 Tf" );
272+ // Text and border in blue RGB color, "Liberation Sans " font, 20 point
273+ freeTextAnnotation .setDefaultAppearance ("0 0 1 rg /LibSans 20 Tf" );
272274 // Quadding does not have any effect?!
273275 freeTextAnnotation .setQ (PDVariableText .QUADDING_RIGHT );
274276 freeTextAnnotation .setIntent (PDAnnotationFreeText .IT_FREE_TEXT_CALLOUT );
@@ -310,6 +312,12 @@ public static void main(String[] args) throws IOException
310312 dr .put (COSName .HELV , new PDType1Font (FontName .HELVETICA ));
311313 // If you want to use a specific font, add it here but make sure it is not subset
312314
315+ // add the "Liberation Sans" font to the default resources so we can use greek
316+ PDType0Font libSansFont = PDType0Font .load (document ,
317+ AddAnnotations .class .getResourceAsStream ("/org/apache/pdfbox/resources/ttf/LiberationSans-Regular.ttf" ),
318+ false );
319+ dr .put (COSName .getPDFName ("LibSans" ), libSansFont );
320+
313321 // Create the appearance streams.
314322 // Adobe Reader will always display annotations without appearance streams nicely,
315323 // but other applications may not.
0 commit comments