Java/PDF RTF/Measurements

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

Measurements in PDF

   <source lang="java">

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();
 }

}

      </source>