Target
Case 1 Source
HtmlLoadOptions options = new HtmlLoadOptions();
options.setEmbedFonts(true);
options.setInputEncoding(“UTF-8”);
Document document = new Document(htmlPath, options);
SignatureField s = new SignatureField(document.getPages().get_Item(1), new Rectangle(100, 100,100, 100));
PKCS7 pkcs = new PKCS7(“sample.pfx”, “test”);
document.getForm().add(s, 1);
document.convert(logPath, PdfFormat.PDF_A_2A, ConvertErrorAction.Delete);
s.sign(pkcs);
document.save(pdfPath);
document.close();
Result
class com.aspose.pdf.exceptions.PdfException: Signature field ‘field_1’ is not defined.
com.aspose.pdf.internal.l0h.l0p.lI(Unknown Source)
com.aspose.pdf.internal.l0h.l0p.lI(Unknown Source)
com.aspose.pdf.Signature.lI(Unknown Source)
com.aspose.pdf.SignatureField.lI(Unknown Source)
com.aspose.pdf.SignatureField.sign(Unknown Source)
Case 2 Source
HtmlLoadOptions options = new HtmlLoadOptions();
options.setEmbedFonts(true);
options.setInputEncoding(“UTF-8”);
Document document = new Document(htmlPath, options);
SignatureField s = new SignatureField(document.getPages().get_Item(1), new Rectangle(100, 100,100, 100));
PKCS7 pkcs = new PKCS7(“sample.pfx”, “test”);
document.getForm().add(s, 1);
s.sign(pkcs);
document.convert(logPath, PdfFormat.PDF_A_2A, ConvertErrorAction.Delete);
document.save(pdfPath);
document.close();
Result
Could not convert PDF/A
P.S.
.NET version resolved related issues?
If that’s right, please apply the Java version as well.
[PDFNET-49740 PDF/A became invalid after multiple digital signature]