pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chitgoks <chitg...@gmail.com>
Subject adding review status problem
Date Fri, 26 Apr 2019 04:22:59 GMT
hi. i used to have this working, adding review status to comments like
none, accepted, rejected, canceled, etc.

this used to be my working code

public static void main(String[] args) {
        try (PDDocument pdfDocument = PDDocument.load(new File("src.pdf")))
{
            PDPage pdPage = pdfDocument.getPages().get(0);

            PDAnnotationSquareCircle squareAnnot = new
PDAnnotationSquareCircle(PDAnnotationSquareCircle.SUB_TYPE_SQUARE);
            squareAnnot.setRectangle(new PDRectangle(67.2f, 697.19995f,
182.4f, 756.6f));
            squareAnnot.setTitlePopup("test_username");
            squareAnnot.setContents("root comment");
            squareAnnot.setCreationDate(Calendar.getInstance());
            squareAnnot.setModifiedDate(Calendar.getInstance());

            squareAnnot.setInteriorColor(new PDColor( new float[] { 255,
255, 0 }, PDDeviceRGB.INSTANCE));
            squareAnnot.setConstantOpacity(0.3f);

            // Add review status to annotation.
            PDAnnotationText status = new PDAnnotationText();
            status.setRectangle(new PDRectangle(67.2f, 697.19995f, 182.4f,
756.6f));
            status.setTitlePopup("reviewer");
            status.getCOSObject().setInt(COSName.F, 30);
            status.setState("accepted");
            status.setStateModel("Review");
            status.setInReplyTo(squareAnnot);
            pdPage.getAnnotations().add(status);

            // Add a reply to comment.
            PDAnnotationText replyAnnotation = new PDAnnotationText();
            replyAnnotation.setRectangle(new PDRectangle(67.2f, 697.19995f,
182.4f, 756.6f));
            replyAnnotation.setTitlePopup("branch");
            replyAnnotation.setContents("reply comment");
            replyAnnotation.setCreationDate(Calendar.getInstance());
            replyAnnotation.setModifiedDate(Calendar.getInstance());
            replyAnnotation.setName(PDAnnotationText.NAME_COMMENT);
            replyAnnotation.setInReplyTo(squareAnnot);
            pdPage.getAnnotations().add(replyAnnotation);

            // Add review status to reply.
            status = new PDAnnotationText();
            status.setRectangle(new PDRectangle(67.2f, 697.19995f, 182.4f,
756.6f));
            status.setTitlePopup("statuser");
            status.getCOSObject().setInt(COSName.F, 30);
            status.setState("none");
            status.setStateModel("Review");
            status.setInReplyTo(replyAnnotation);
            pdPage.getAnnotations().add(status);

            pdPage.getAnnotations().add(squareAnnot);

            pdfDocument.save("result.pdf");
            pdfDocument.close();
        } catch (Exception e) {
            Logger.getLogger(Test.class.getSimpleName()).log(Level.SEVERE,
null, e);
        }
    }


now, it does not get added anymore. i noticed ever since acrobat pdf reader
changed them to colored icons, they do not work anymore. i noticed that
they even added the SubType Text to the dictionary, but even if i added
that to the PDAnnotationText, the review comment status does not get added.
i am not sure what i am missing.

thoughts?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message