Remove digital signatures

Tags: digital signaturesiText 7
Files: 
/*
 
    This file is part of the iText (R) project.
    Copyright (c) 1998-2016 iText Group NV
 
*/
 
/**
 * Example written by Bruno Lowagie in answer to the following question:
 * http://stackoverflow.com/questions/28163159/about-visible-digital-signatures
 */
package com.itextpdf.samples.sandbox.acroforms;
 
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.test.annotations.type.SampleTest;
import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.samples.GenericTest;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
 
import org.junit.experimental.categories.Category;
 
@Category(SampleTest.class)
public class FlattenSignature extends GenericTest {
    public static final String DEST = "./target/test/resources/sandbox/acroforms/flatten_signature.pdf";
    public static final String SRC = "./src/test/resources/pdfs/input_signed.pdf";
 
    public static void main(String[] args) throws Exception {
        File file = new File(DEST);
        file.getParentFile().mkdirs();
        new FlattenSignature().manipulatePdf(DEST);
    }
 
    @Override
    protected void manipulatePdf(String dest) throws Exception {
        PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(DEST));
        PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true);
        form.flattenFields();
        pdfDoc.close();
    }
}
File nameRaw URLUpdated
FlattenSignature.javaFlattenSignature.java2016-08-10 10:05 am
Resources: 
File nameRaw URLUpdated
input_signed.pdfinput_signed.pdf2016-08-10 10:06 am
Results: 
File nameRaw URLUpdated
cmp_flatten_signature.pdfcmp_flatten_signature.pdf2016-08-10 10:07 am