'iText7 : Image in pdf file causing error in deferred signing

So I have added a image to pdf. But when I sign the pdf file with image using deferred signing, it's giving the error "The document has been altered or corrupted since the Signature was applied" in adobe reader. Removing the image solves this issue.

I have tried different images, different formats(png & jpg), different solutions(solution1 & solution2). But the only solution that works is the removal of image?

Here is the implementation I tried to insert image (pre solution1 & solution2 code) :

Image pdfImg = new Image(ImageDataFactory.create("src/main/resources/image.png"));
pdfImg.setWidth(defaultPageSize.getWidth() / 4);
pdfImg.setHeight(defaultPageSize.getWidth() / 8);
pdfImg.setHorizontalAlignment(HorizontalAlignment.CENTER); 
Document.add(pdfImg);

The image I am trying to add is this.

Is there any solution to this?

Edit 1 :

As requested here is a nonSigned pdf and a signed pdf.



Solution 1:[1]

The signature indeed is incorrect.

Apparently an issue occurred while calculating the document hash. The embedded signature claims the hash of the signed byte ranges of the PDF is

170856708123EFDC173693BB0582FAED1CA8A40D37EA26902E0CC1142EC62F72

but it actually is

7A767EDF7BA9112A11678E70285E22170595341F8A18F8A9CD7F20AC50296CEF

Thus, Adobe Acrobat has reason to assume an alteration or corruption.


As an aside, there also appear to be issues in your certificate path.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mkl