250 - New
9 years ago
Use the -c option to include the config file
<renderers>
<renderer mime="application/pdf">
<fonts>
<!-- automatically detect operating system installed fonts -->
<auto-detect/>
</fonts>
</renderer>
</renderers>
//without XSLT:Add the stylesheet if using XSLT-XML.
transformer = factory.newTransformer();
...
Source src = new StreamSource(new File("src/currency.fo"));
//with XSLT
Source xslt = new StreamSource(new File("src/name2fo.xsl"));
transformer = factory.newTransformer(xslt);
...
Source src = new StreamSource(new File("src/name.xml"));
// Step 1: Construct a FopFactory
// (reuse if you plan to render multiple documents!)
FopFactory fopFactory = FopFactory.newInstance();
// Step 2: Set up output stream.
// Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(new File("src/currency.rtf")));
Fop fop;
fop = fopFactory.newFop(MimeConstants.MIME_RTF, out);
// Step 4: Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer; // identity transformer
//without XSLT:
transformer = factory.newTransformer();
//with XSLT:
//Source xslt = new StreamSource(new File("src/name2fo.xsl"));
//transformer = factory.newTransformer(xslt);
// Step 5: Setup input and output for XSLT transformation
// Setup input stream
//without XSLT
Source src = new StreamSource(new File("src/currency.fo"));
//with XSLT
//Source src = new StreamSource(new File("src/name.xml"));
// Resulting SAX events (the generated FO) must be piped through to FOP
SAXResult res = new SAXResult(fop.getDefaultHandler());
// Step 6: Start XSLT transformation and FOP processing
transformer.transform(src, res);
} catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (FOPException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (TransformerConfigurationException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} finally {
//Clean-up
if (out != null) {
out.close();
}
}
#!/bin/bash #$1 is name of out param, $2 is name of out param func () { local loc=8 local diff=9 local same=10 eval "$1=$diff" eval "$2=$same" } loc=7 func out same echo "loc = $loc" #loc = 7 echo "out = $out" #out = 9 echo "same = $same" #same =