pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: adding review status problem
Date Fri, 26 Apr 2019 06:57:09 GMT
Hi,

 From looking at the PDF specification, the strings are "Accepted" and 
not "accepted", and "None" instead of "none". I just noticed that, I 
didn't test your code. The best would be to create a "gold standard" 
model with Adobe, and then compare that one with yours.

Tilman

Am 26.04.2019 um 06:22 schrieb chitgoks:
> 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?
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message