1 import org.faceless.report.*; 2 import org.faceless.pdf2.*; 3 import org.xml.sax.*; 4 import java.io.*; 5 6 public class SampleApplication 14 { 15 public static void main(String [] args) 16 { 17 try { 18 doParse(args); 19 } catch (SAXException e) { 20 if (e.getException()!=null) { 21 e.getException().printStackTrace(); 22 } else { 23 e.printStackTrace(); 24 } 25 } catch (Exception e) { 26 e.printStackTrace(); 27 } 28 } 29 30 public static void doParse(String [] args) 31 throws SAXException, IOException 32 { 33 if (args.length==0) { 34 System.err.println("Usage: java Sample <infile1.xml> [<infile2.xml> ...]"); 35 System.exit(0); 36 } 37 38 ReportParser p = ReportParser.getInstance(); 41 42 System.out.println("---------------------------------------------------"); 43 System.out.println("Parsing files. Note the first file will take longer"); 44 System.out.println("as it must load various static resources."); 45 System.out.println("---------------------------------------------------"); 46 47 for (int i=0;i<args.length;i++) 48 { 49 File infile = new File(args[i]); 52 String outfilename = infile.getName(); 53 if (outfilename.indexOf('.')>0) { 54 outfilename = outfilename.substring(0,outfilename.lastIndexOf('.')); 55 } 56 outfilename = (infile.getParent()==null ? "" : infile.getParent()+File.separator)+outfilename; 57 File outfile = new File(outfilename+".pdf"); 58 59 60 System.out.print("Parsing \""+infile+"\"... "); 63 long now = System.currentTimeMillis(); 64 65 PDF pdf = p.parse(infile); 66 pdf.render(new FileOutputStream(outfile)); 67 68 System.out.println("created \""+outfile+"\" in "+(System.currentTimeMillis()-now)+"ms"); 69 } 70 System.out.println("---------------------------------------------------"); 71 } 72 } 73 | Popular Tags |