正如其他人已经说过的,签名背后的想法(至少是想法的一个主要部分)是确保文档没有更改。另一方面,合并确实会更改文档。因此,合并将破坏签名。
不过,另一种不同的方法是,将另一个“普通”的PDF作为可移植的集合(一种带有附件的特殊类型的PDF),并将签名的PDF附加到该集合中。
从集合中打开已签名的PDF时,签名将与原始已签名的PDF中的签名一样安全。
用于创建可移植集合的示例代码
您可以在IText站点上找到可移植集合创建的示例:
public static final String DEST = "results/collections/portable_collection.pdf";
public static final String DATA = "resources/data/united_states.csv";
public static final String HELLO = "resources/pdfs/hello.pdf";
public static final String IMG = "resources/images/berlin2013.jpg";
public void createPdf(String dest) throws IOException, DocumentException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dest));
document.open();
document.add(new Paragraph("Portable collection"));
PdfCollec