Signature field could not be found in file converted to PDF/A or Could not convert PDF/A

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]

@AnySSign

Yes, every fix and improvement in .NET version of the API becomes part of the equivalent version of Aspose.PDF for Java. The referenced issue was resolved in 21.7 version of the API. Could you please make sure that you are using Aspose.PDF for Java 21.7? If still facing the issue, please share sample source files for our reference so that we can investigate and address the issue accordingly.

@asad.ali

test.zip (9.2 KB)

I’m uploading a file for testing.

Please check it out.

Maven Info :

com.aspose aspose-pdf 21.7

@AnySSign

We have logged an investigation ticket as PDFJAVA-40783 in our issue tracking system to further analyze this scenario. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.