PDF-A1a document not valid after signing with VisualRepresentation using IText

[亡魂溺海] 提交于 2021-02-10 05:11:44

问题


I digitally sign a PDF-A1a document using IText 7.15.0.

In addition to the digital signature, I also add a visual representation (image) to the document.

PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
appearance.SetPageNumber(1);

Rectangle pr = new Rectangle(10 + ImageOffset, 10 + ImageOffset, 100, 100 );
appearance.SetPageRect(pr);
byte[] image = System.IO.File.ReadAllBytes(VisualAppearance);

appearance.SetRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);
ImageData imageData = ImageDataFactory.Create(image);
appearance.SetSignatureGraphic(imageData);

This code works and the signature is valid. But if the document was a PDF-A1a, it is no longer a valid PDF-A1a. It only becomes invalid when I add the visual representation. If I just apply the signature without the visual representation, it remains a valid PDF-A1a.

Other PDF-A standards like A2a do remain valid when adding the visual representation.

When using foxit phantom to validate the PDF-A1a, it shows the following message:

A transparent soft mask is present. Beginning with PDF 1.4 transparency is supported. Some PDF-based ISO standards prohibit the use of transparency.

What do i need to do in order to keep a PDF-A1a valid while adding the visual representation?


回答1:


As Foxit already informs, some standards prohibit the use of transparency within a conforming file, in particular ISO 19005-1 does for PDF/A-1 profiles by a number of provisions, among them:

If an SMask key appears in an ExtGState or XObject dictionary, its value shall be None.

(ISO 19005-1, section 6.4 Transparency)

But if iText adds an image with transparency information to a PDF, it translates the transparency information to a non-vanishing SMASK entry of the resulting image XObject.

To prevent this, simply use images without transparency.

In a comment to your parallel question you confirm

If i use jpeg instead of png, the PDF-A1a remains valid.

For non-rectangular image outlines consider using a clip path.



来源:https://stackoverflow.com/questions/65034339/pdf-a1a-document-not-valid-after-signing-with-visualrepresentation-using-itext

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!