Trying to sign a PDF existing signed with PDFBox
with this test function :
/**
* 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);
}
when try to setMDPPermission process :
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");
}
but on this function SigUtils got error :
java.io.IOException: DocMDP transform method not allowed if an approval signature exists
how can i pass the document to sign ?