Hi Georg,
Thanks again for your help. Getting there slowly...
I believe I've managed to get to the point of getting a document back from
the transformation. The code is below:
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
SAXTransformerFactory saxTransformerFactory =
(SAXTransformerFactory)TransformerFactory.newInstance();
TransformerHandler transformerHandler =
saxTransformerFactory.newTransformerHandler( new StreamSource(
m_xslStylesheet ) );
DOMResult domResult = new DOMResult();
transformerHandler.setResult( domResult );
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream( new
FileOutputStream( m_outputPDFFile ) );
Fop fop = fopFactory.newFop( MimeConstants.MIME_FOP_AREA_TREE,
foUserAgent, bufferedOutputStream );
Transformer transformer = saxTransformerFactory.newTransformer();
// Set report parameters...
Set<String> xslKeys = m_xslParams.keySet();
for( String xslKey : xslKeys )
transformer.setParameter( xslKey, m_xslParams.get( xslKey ) );
Source source = new StreamSource( m_xmlData );
Result result = new SAXResult( transformerHandler );
saxTransformerFactory.newTransformer().transform( source, result );
Document document = (org.w3c.dom.Document)domResult.getNode();
XPathFactory factory = XPathFactory.newInstance();
String expression = ".//blo...@id='" + "HeaderID" + "']/@bpd";
String item = "fo:block";
QName returnType = XPathConstants.NUMBER;
Object returnValue = factory.newXPath().evaluate( expression, item,
returnType );
double height_in_milipoints = Double.parseDouble( (String)returnValue );
The for loop is used to set report parameters such as page size, page
margins, report title, etc.
When I run the above code, I get an XPathExpressionException. Unfortunately
there is no detailed message.
The snippet of my XSL file is:
<fo:static-content flow-name="xsl-region-before">
<fo:block id="HeaderID" font-family="{$header-font-family}"
font-size="{$header-font-size}" font-style="{$header-font-style}"
text-align="center"><xsl:value-of select="$report-title"/></fo:block>
</fo:static-content>
I'm not sure what I am doing wrong. When I debug the Java and inspect the
"document" variable it seems to have lots of stuff - but can't actually
figure out how to locate the node I want.
If easier or you prefer, send me a direct email and we can then work out how
to IM each other.
Thanks again,
Bernmeister.
--
View this message in context:
http://www.nabble.com/Change-the-header-footer-size-in-a-PDF-tp23209748p23248181.html
Sent from the FOP - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]