Ignore:
Timestamp:
07/02/14 13:59:44 (10 years ago)
Author:
hkaulbersch
Message:

commit: generator improved

File:
1 moved

Legend:

Unmodified
Added
Removed
  • v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/FoToPdfOrRtf.java

    r82 r84  
    2323 
    2424 
    25 public class foToPdf { 
     25public class FoToPdfOrRtf { 
    2626 
    2727 
     
    3333        } 
    3434         
    35         private static void createfoFromPdf(String foFileName, String pdfFileName)throws IOException, FOPException, 
     35        public static void createRtfFromFo(String fileName) throws IOException, FOPException, 
     36        TransformerException{ 
     37 
     38                createRtfFromFo(fileName,fileName); 
     39        } 
     40         
     41        private static void createRtfFromFo(String foFileName, String pdfFileName)throws IOException, FOPException, 
    3642        TransformerException{ 
    3743                File file = new File(foFileName+".fo"); 
     
    4551                        // Step 3: Construct fop with desired output format 
    4652                        Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, out); 
     53 
     54                        // Step 4: Setup JAXP using identity transformer 
     55                        TransformerFactory factory = TransformerFactory.newInstance(); 
     56                        Transformer transformer = factory.newTransformer(); 
     57 
     58                        // Step 5: Setup input and output for XSLT transformation 
     59                        Source src = new StreamSource(file); 
     60 
     61                        // Resulting SAX events (the generated FO) must be piped through to FOP          
     62                        Result res = new SAXResult(fop.getDefaultHandler()); 
     63 
     64                        // Step 6: Start XSLT transformation and FOP processing 
     65                        transformer.transform(src, res); 
     66                } finally { 
     67                        out.close(); 
     68                } 
     69        } 
     70         
     71         
     72        private static void createfoFromPdf(String foFileName, String pdfFileName)throws IOException, FOPException, 
     73        TransformerException{ 
     74                File file = new File(foFileName+".fo"); 
     75                // Step 1: Construct a FopFactory 
     76                FopFactory fopFactory = FopFactory.newInstance(); 
     77 
     78                // Step 2: Set up output stream. 
     79                OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(pdfFileName+".pdf"))); 
     80 
     81                try { 
     82                        // Step 3: Construct fop with desired output format 
     83                        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); 
    4784 
    4885                        // Step 4: Setup JAXP using identity transformer 
Note: See TracChangeset for help on using the changeset viewer.