使用IText使用VisualRepresentation签名后,PDF-A1a文档无效 [英] PDF-A1a document not valid after signing with VisualRepresentation using IText

查看:66
本文介绍了使用IText使用VisualRepresentation签名后,PDF-A1a文档无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用IText 7.15.0对PDF-A1a文档进行数字签名.

除了数字签名,我还向文档添加了视觉表示(图像).

 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);
 

此代码有效,并且签名有效. 但是,如果文档是PDF-A1a,则它不再是有效的PDF-A1a.仅当添加视觉表示时,它才变得无效.如果我仅应用签名而没有视觉表示,则它仍然是有效的PDF-A1a.

添加视觉表示时,其他PDF-A标准(如A2a)仍然有效.

使用Fox幻像验证PDF-A1a时,它显示以下消息:

存在透明的软膜.从PDF 1.4开始,支持透明性.一些基于PDF的ISO标准禁止使用透明度.

在添加视觉表示时,为了使PDF-A1a有效,我需要做什么?

解决方案

正如Foxit所告知的那样,某些标准禁止在一致性文件中使用透明性,特别是ISO 19005-1对PDF/A-1配置文件做了透明性规定.条文数量,其中:

如果 ExtGState XObject 词典中出现 SMask 键,则其值应为 None . /p>

(ISO 19005-1,第6.4节透明度)

但是,如果iText将具有透明度信息的图像添加到PDF,则会将透明度信息转换为生成的图像 XObject 的不消失的 SMASK 条目.

为防止这种情况,只需使用没有透明度的图像即可.

中的注释平行问题您确认

如果我使用jpeg而不是png,则PDF-A1a仍然有效.

对于非矩形图像轮廓,请考虑使用剪切路径.

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?

解决方案

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.

这篇关于使用IText使用VisualRepresentation签名后,PDF-A1a文档无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆