【发布时间】:2021-09-13 08:25:41
【问题描述】:
正在尝试对已使用 PDFBox 签名的 PDF 进行签名
使用此测试功能:
/**
* Test creating visual signature with the modernized example.
*
* @throws IOException
* @throws CMSException
* @throws OperatorCreationException
* @throws GeneralSecurityException
* @throws TSPException
* @throws CertificateVerificationException
*/
@ParameterizedTest
@MethodSource("signingTypes")
void testCreateVisibleSignature2(boolean externallySign)
throws IOException, CMSException, OperatorCreationException, GeneralSecurityException,
TSPException, CertificateVerificationException
{
// sign PDF
String inPath = IN_DIR + "pdf.pdf";
File destFile;
CreateVisibleSignature2 signing = new CreateVisibleSignature2(keyStore, PASSWORD.toCharArray());
Rectangle2D humanRect = new Rectangle2D.Float(200, 300, 200, 100);
signing.setImageFile(new File(JPEG_PATH));
signing.setExternalSigning(externallySign);
destFile = new File(OUT_DIR + getOutputFileName("Signed.pdf", externallySign));
signing.signPDF(new File(inPath), destFile, humanRect, tsa);
checkSignature(new File(inPath), destFile, false);
}
当尝试设置MDPPermission进程时:
if (doc.getVersion() >= 1.5f && accessPermissions == 0)
{
SigUtils.setMDPPermission(doc, signature, 2);
}
if (sig.getCOSObject().containsKey(COSName.CONTENTS))
{
throw new IOException("DocMDP transform method not allowed if an approval signature exists");
}
但是在这个函数上 SigUtils 出错了:
java.io.IOException: DocMDP 转换方法不允许,如果 批准签名存在
我怎样才能通过文件签名?
【问题讨论】:
标签: pdfbox