Java-PDF: Annoter un document PDF à l’aide d’un autre

Author:

Java-PDF: Annoter un document PDF à l'aide d'un autre
{filelink=10324}

/***** Code de MesExemples.com *******/
import java.io.FileOutputStream;
import java.net.URL;

import com.itextpdf.text.Annotation;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfAction;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;

public class ExempleAnnotation2 {
  public static void main(String[] args) {
    Document document1 = new Document(PageSize.A4, 10, 10, 10, 10);
    try {
      PdfWriter pdf_writer = PdfWriter.getInstance(document1, 
      	new FileOutputStream("c:/annotation2.pdf"));
      pdf_writer.setPdfVersion(PdfWriter.VERSION_1_5);
      document1.open();

      Annotation a = new Annotation(100f, 400f, 200f, 500f, 
    "c:/exAnnotation.pdf", 2);

      document1.add(a);
    } catch (Exception err) {
      err.printStackTrace();
    }
    document1.close();
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *