pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1857768 - /pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java
Date Thu, 18 Apr 2019 17:44:14 GMT
Author: tilman
Date: Thu Apr 18 17:44:13 2019
New Revision: 1857768

URL: http://svn.apache.org/viewvc?rev=1857768&view=rev
Log:
PDFBOX-4515: add freetext annotation with callout to example

Modified:
    pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java

Modified: pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java?rev=1857768&r1=1857767&r2=1857768&view=diff
==============================================================================
--- pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java
(original)
+++ pdfbox/branches/issue45/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java
Thu Apr 18 17:44:13 2019
@@ -242,6 +242,41 @@ public final class AddAnnotations
             pageLink.setAction(actionGoto);
             annotations.add(pageLink);
 
+            PDAnnotationMarkup freeTextAnnotation = new PDAnnotationMarkup();
+            freeTextAnnotation.getCOSObject().setName(COSName.SUBTYPE, PDAnnotationMarkup.SUB_TYPE_FREETEXT);
+            PDColor yellow = new PDColor(new float[] { 1, 1, 0 }, PDDeviceRGB.INSTANCE);
+            // this sets background only (contradicts PDF specification)
+            freeTextAnnotation.setColor(yellow);
+            position = new PDRectangle();
+            position.setLowerLeftX(1 * INCH);
+            position.setLowerLeftY(ph - 5f * INCH - 3 * INCH);
+            position.setUpperRightX(pw - INCH);
+            position.setUpperRightY(ph - 5f * INCH);
+            freeTextAnnotation.setRectangle(position);
+            freeTextAnnotation.setTitlePopup("Sophia Lorem");
+            freeTextAnnotation.setSubject("Lorem ipsum");
+            freeTextAnnotation.setContents("Lorem ipsum dolor sit amet, consetetur sadipscing
elitr,"
+                    + " sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
aliquyam "
+                    + "erat, sed diam voluptua. At vero eos et accusam et justo duo dolores
et ea "
+                    + "rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
ipsum "
+                    + "dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, "
+                    + "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
"
+                    + "erat, sed diam voluptua. At vero eos et accusam et justo duo dolores
et ea "
+                    + "rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
ipsum "
+                    + "dolor sit amet.");
+            // Text and border in blue RGB color, "Helv" font, 20 point
+            // setDefaultAppearance() missing in 2.0
+            freeTextAnnotation.getCOSObject().setString(COSName.DA, "0 0 1 rg /Helv 20 Tf");
+            freeTextAnnotation.setIntent("FreeTextCallout");
+            COSArray newCallout = new COSArray();
+            newCallout.setFloatArray(new float[]{0, ph - 9 * INCH, 3 * INCH, ph - 9 * INCH,
4 * INCH, ph - 8 * INCH});
+            // setCallout() missing in 2.0
+            freeTextAnnotation.getCOSObject().setItem(COSName.CL, newCallout);
+            freeTextAnnotation.getCOSObject();
+            // setLineEndingStyle() missing in 2.0
+            freeTextAnnotation.getCOSObject().setName(COSName.LE, PDAnnotationLine.LE_OPEN_ARROW);
+            annotations.add(freeTextAnnotation);
+
             // create a polygon annotation. Yes this is clunky, it will be easier in 3.0
             PDAnnotationMarkup polygon = new PDAnnotationMarkup();
             polygon.getCOSObject().setName(COSName.SUBTYPE, PDAnnotationMarkup.SUB_TYPE_POLYGON);



Mime
View raw message