Thank you Anze! Happy to see that it was easier than I thought. I always assume the worst with PDF 😂

I've added a comment to the example (will be in 2.0.23)

Tilman

Am 16.12.2020 um 21:58 schrieb anze:
Hello Tilman and others,

thanks for your answer.

I found a simple solution for this two errors (without handlers).

I include:
txtMark.setPrinted(true);
And exclude:
// txtMark.setConstantOpacity((float) 0.2); // 20% transparent

This is simple method for new annotation:

private void addPDAnnotationTextMarkup(List<PDAnnotation> annotations,
PDColor yellow, float ph) {
// Now add the markup annotation, a highlight to PDFBox text
PDAnnotationTextMarkup txtMark = new
PDAnnotationTextMarkup(PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);
txtMark.setPrinted(true);
txtMark.setColor(yellow);
// txtMark.setConstantOpacity((float) 0.2); // 20% transparent
//
// // Set the rectangle containing the markup
float textWidth = 7779 / 1000 * 18;
//logger.info("textWidth=[" + font.getStringWidth("Dodan nov tekst") + "]");
PDRectangle position = new PDRectangle();
position.setLowerLeftX(INCH);
position.setLowerLeftY(ph - INCH - 18);
position.setUpperRightX(INCH + textWidth);
position.setUpperRightY(ph - INCH);
txtMark.setRectangle(position);
//
// // work out the points forming the four corners of the annotations
// // set out in anti clockwise form (Completely wraps the text)
// // OK, the below doesn't match that description.
// // It's what acrobat 7 does and displays properly!
float[] quads = new float[8];
quads[0] = position.getLowerLeftX(); // x1
quads[1] = position.getUpperRightY() - 2; // y1
quads[2] = position.getUpperRightX(); // x2
quads[3] = quads[1]; // y2
quads[4] = quads[0]; // x3
quads[5] = position.getLowerLeftY() - 2; // y3
quads[6] = quads[2]; // x4
quads[7] = quads[5]; // y5
//
txtMark.setQuadPoints(quads);
txtMark.setContents("A simple comment");
annotations.add(txtMark);
}

It's working with PDF/A 2b and PDF/A 3b. And sign is not corupted.

Best regards

Anze



V V sre., 16. dec. 2020 ob 16:37 je oseba Tilman Hausherr <
[email protected]> napisala:

Am 16.12.2020 um 15:57 schrieb anze:
Hello,

I am writing to this group for the first time.

I would like to know if I can add a comment (annotation) to an
existing PDF/A 2b document that contains digital signatures and
content? After adding an annotation to my existing PDF/A 2b document
and call *saveIncremental* I need to get a valid digital signature and
a valid PDF / A 2b document. Is this possible and covered by PDFBOX
implementation?

I checked my samples and I got a valid digital signature, but not a
valid PDF/A 2b document.

I checked on page:
Verify PDFA online (bfo.com)
<https://bfo.com/blog/2017/11/08/verify_pdfa_online/>

and I get:


       PDF/A-2b

NonPopupAnnotationPrintFlagNotSetis set, but shouldn't be

https://bfo.com/products/pdf/docs/api/org/faceless/pdf2/OutputProfile.Feature.html#NonPopupAnnotationPrintFlagNotSet

According to them, this means you should set the print flag. Try it...


AnnotationTransparentis set, but shouldn't be

I assume they mean the transparency. The implementation of the highlight
does involve transparency. I wanted to have code similar to what Adobe
Reader does.

You might try to rewrite the PDHighlightAppearanceHandler and pass the
modified one to your annotation with setCustomAppearanceHandler().

Use the code that fills "frm2CS" directly into the main content stream
("cs"). Or you add such an annotation with Adobe Reader on your PDF, and
if it is validated, then look at the file with PDFDebugger to see how it
is different.

Try also VeraPDF as validator, maybe their output tells more...


In my case, I would like to add a simple comment to the PDF / A 2b
document and I am wondering how I can achieve this?

What types of annotations can I use in the case of PDF / A 2b documents?
I don't know. I don't have the PDF/A-2b specification. I assume that
there is no list, rather it will be like above that there are surprising
problems.

Tilman



In attachment you can find a test class for this case.

Any help would be very welcome. Thanks
--
Best regards

Anze

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to