FormSignaturePDF.java Source code

Java tutorial

Introduction

Here is the source code for FormSignaturePDF.java

Source

import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfAcroForm;
import com.lowagie.text.pdf.PdfWriter;

public class FormSignaturePDF {
    public static void main(String[] args) {
        Document document = new Document(PageSize.A4);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FormSignaturePDF.pdf"));
            document.open();
            PdfAcroForm acroForm = writer.getAcroForm();
            document.add(new Paragraph("Hello World"));
            acroForm.addSignature("sig", 73, 705, 149, 759);

        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        document.close();
    }
}