Changeset 84 in default for v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/generator/FoToPdfOrRtf.java
- Timestamp:
- 07/02/14 13:59:44 (10 years ago)
- 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 23 23 24 24 25 public class foToPdf {25 public class FoToPdfOrRtf { 26 26 27 27 … … 33 33 } 34 34 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, 36 42 TransformerException{ 37 43 File file = new File(foFileName+".fo"); … … 45 51 // Step 3: Construct fop with desired output format 46 52 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); 47 84 48 85 // Step 4: Setup JAXP using identity transformer
Note: See TracChangeset
for help on using the changeset viewer.