1 31 package org.pdfbox.examples.pdmodel; 32 33 import java.io.IOException ; 34 35 import org.pdfbox.exceptions.COSVisitorException; 36 37 import org.pdfbox.pdmodel.PDDocument; 38 import org.pdfbox.pdmodel.PDPage; 39 40 48 public class CreateBlankPDF 49 { 50 51 59 public void create( String file ) throws IOException , COSVisitorException 60 { 61 PDDocument document = null; 62 try 63 { 64 document = new PDDocument(); 65 PDPage blankPage = new PDPage(); 68 document.addPage( blankPage ); 69 document.save( file ); 70 } 71 finally 72 { 73 if( document != null ) 74 { 75 document.close(); 76 } 77 } 78 } 79 80 88 public static void main( String [] args ) throws IOException , COSVisitorException 89 { 90 if( args.length != 1 ) 91 { 92 usage(); 93 } 94 else 95 { 96 CreateBlankPDF creator = new CreateBlankPDF(); 97 creator.create( args[0] ); 98 } 99 } 100 101 104 private static void usage() 105 { 106 System.err.println( "usage: java org.pdfbox.examples.pdmodel.CreateBlankPDF <outputfile.pdf>" ); 107 } 108 } | Popular Tags |