Remove digital signatures

This is a code example of iText PDF, discover more.

7th November 2015
admin-marketing

Switch code for this example

FlattenSignature.java
  1. /**
  2.  * Example written by Bruno Lowagie in answer to the following question:
  3.  * http://stackoverflow.com/questions/28163159/about-visible-digital-signatures
  4.  */
  5. package sandbox.acroforms;
  6.  
  7. import com.itextpdf.text.DocumentException;
  8. import com.itextpdf.text.pdf.PdfReader;
  9. import com.itextpdf.text.pdf.PdfStamper;
  10.  
  11. import java.io.File;
  12. import java.io.FileOutputStream;
  13. import java.io.IOException;
  14. import sandbox.WrapToTest;
  15.  
  16. @WrapToTest
  17. public class FlattenSignature {
  18.  
  19.     public static final String SRC = "resources/pdfs/input_signed.pdf";
  20.     public static final String DEST = "results/acroforms/output_no_longer_signed.pdf";
  21.    
  22.  
  23.     public static void main(String[] args) throws DocumentException, IOException {
  24.         File file = new File(DEST);
  25.         file.getParentFile().mkdirs();
  26.         new FlattenSignature().manipulatePdf(SRC, DEST);
  27.     }
  28.  
  29.     public void manipulatePdf(String src, String dest) throws DocumentException, IOException {
  30.         PdfReader reader = new PdfReader(src);
  31.         PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
  32.         stamper.setFormFlattening(true);
  33.         stamper.close();
  34.     }
  35. }
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now