3 回答

TA貢獻1831條經驗 獲得超10個贊
正如其他人已經說過的,簽名背后的想法(至少是想法的主要部分)是確保文件沒有改變。另一方面,合并確實會更改文檔。因此,合并會破壞簽名。
但是,另一種方法是使另一個“普通”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"));
PdfCollection collection = new PdfCollection(PdfCollection.TILE);
writer.setCollection(collection);
PdfFileSpecification fileSpec = PdfFileSpecification.fileEmbedded(
writer, DATA, "united_states.csv", null);
writer.addFileAttachment("united_states.csv", fileSpec);
fileSpec = PdfFileSpecification.fileEmbedded(
writer, HELLO, "hello.pdf", null);
writer.addFileAttachment("hello.pdf", fileSpec);
fileSpec = PdfFileSpecification.fileEmbedded(
writer, IMG, "berlin2013.jpg", null);
writer.addFileAttachment("berlin2013.jpg", fileSpec);
document.close();
}
(這里在網站上,在這里他們的GitHub)
運行該示例的結果是here。
(因為您使用的是 iText 標簽而不是 itext7 標簽,所以我假設您使用的是 iText 5.5.x 版。)

TA貢獻1810條經驗 獲得超4個贊
這是不可能的,這種數字簽名是專門為保護原始文檔不被以任何方式修改而設計的。
要合并和簽署這兩個文檔,您需要知道用于簽名的密鑰并為新的合并文檔再次生成簽名。

TA貢獻1784條經驗 獲得超7個贊
在 Adobe 中打開已簽名的 pdf。
打開打印對話框 ( Ctrl+ P)
將打印機更改為“Microsoft Print to PDF”,然后打印。
新創建的 PDF 將具有簽名,并將作為合并/合并活動的普通 pdf。
注意:此方法將簽名文檔轉換為標準 pdf。結果顯示簽名信息,但底層數字簽名丟失。就我而言,原始簽名者理解這種區別。
創建摘要文件是我的目標。我將各種數字簽名以及其他相關文檔合并到一個摘要 pdf 中。原始的、數字簽名的文檔被存儲以備將來參考。我越來越相信,在保留底層數字簽名的同時,不可能將數字簽名的文檔合并成一個單一的摘要 pdf。
需要摘要數據包的用戶將從我建議的方法中受益。請記住,我的方法在原始數字簽名文檔可按需提供的范圍內仍然“合法有效”。
添加回答
舉報