Skip to content
Advertisement

Why is the Digital Signature not visible in some PDF documents using iText 7.1.11?

My project digitally signs PDF documents using a digital certificate and displays the signature at the bottom left of the document. It had always worked well until now, there are some documents that are digitally signed but it is not shown although it is recognized that the rectangle where it is visible is. Could someone help with this, I leave a snippet that handles the digital signature. Here I leave a screenshot of how the digital signature is in a PDF document, I show it in the lower left corner of the document.

EXAMPLES

In this link I have shared example pdf documents of the problem and without it, I will detail them below:

  • ok_unsigned.pdf file: it is a document that when passing through my project is signed well, becoming the ok_signed.pdf file (this is the norm so far)
  • ok_signed.pdf file: it is the digitally signed ok_unsigned.pdf file, it is a case of success
  • bad_unsigned.pdf file: it is a blank document that when digitally signed (bad_signed.pdf) the issue in question appears
  • bad_signed.pdf file: it is a document with the issue in question, digitally signed but without visually seeing the signature field.

CODE

JavaScript

Advertisement

Answer

As @mkl said your coordinates might be outside of the page visible area as not all PDF pages have the bottom left corner at (0, 0).

Try creating the signature rectangle like this:

JavaScript

You just have to see how you can read the page’s crop box coordinates, the lower left corner, as I’m not familiar with iText API.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement