Java/PDF RTF/Measurements — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 05:59, 1 июня 2010

Measurements in PDF

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfWriter;
public class MeasurementsPDF {
  public static void main(String[] args) {
    Rectangle pageSize = new Rectangle(720, 720);
    /*
     * The size of this page is 720x720 points. 720pt / 72 points per inch = 10 inch.
     * The size of this page is 10x10 inch." (25.4 cm by 25.4 cm) since
     * 10 inch x 2.54 = 25.4 cm" 
     */
    Document document = new Document(pageSize, 36, 18, 72, 72);
    /* The left border is 36pt or 0.5 inch or 1.27 cm"
            right border is 18pt or 0.25 inch or 0.63 cm."
            top border is 72pt or 1 inch or 2.54 cm.
            bottom border 72pt or 1 inch or 2.54 cm. 
     */
    try {
      PdfWriter.getInstance(document, new FileOutputStream("MeasurementsPDF.pdf"));
      document.open();
      document.add(new Paragraph("Measurements"));
    } catch (Exception ioe) {
      System.err.println(ioe.getMessage());
    }
    document.close();
  }
}