import java.io.*;

import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

import java.awt.Color;

public class PushbuttonExample {

    
    public static void main(String[] args) throws Exception {
		FileOutputStream out = new FileOutputStream("submit_new.pdf");
		PdfReader reader = new PdfReader("submit_template.pdf");
		PdfStamper stamper = new PdfStamper(reader, out);
		
		// Get fields
		AcroFields form = stamper.getAcroFields();
		
		PushbuttonField bt = form.getNewPushbuttonFromField("upload");
		if (bt != null) {
			bt.setText("Upload Document");
			bt.setBackgroundColor(Color.GRAY);
			bt.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
			bt.setOptions(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
			
			PdfFormField submitField = bt.getField();
			PdfAction ac = PdfAction.createSubmitForm("http://dgcrelease.gfdi.be/gok/template/pdf/fr/show_data.jsp", null, PdfAction.SUBMIT_PDF);
			submitField.setAction(ac);
			
			form.replacePushbuttonField("upload", bt.getField());
		}
		
		stamper.close();
		out.close();		
    }
}
