Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java PDF: Ajuster une image dans un document PDF

Java PDF: Ajuster une image dans un document PDF
{filelink=10461}

/***** Code de MesExemples.com *******/
/**
 * @(#)ExempleFitPDF.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/4/30
 */
 
 
import java.io.FileOutputStream;
 
import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfWriter;
 
public class ExempleFitPDF {
 
  public static void main(String[] args) throws Exception{
      Image front = Image.getInstance("c:/toureiffel.jpeg");
      Rectangle pageSize = new Rectangle(780, 525);
      Document document = new Document(pageSize);
 
      PdfWriter writer = PdfWriter.getInstance(document, 
      	new FileOutputStream("c:/ExempleFitPDF.pdf"));
      document.open();
 
      front.scaleToFit(200, 300);
      front.setAbsolutePosition(500, 100);
      document.add(front);
 
      document.close();
  }
}