You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Biying Huang <bi...@synthematix.com> on 2002/08/20 22:42:31 UTC
Is there a better way that I don't need to save those temperary files?
I am learning how to use FOP to format a java object into a PDF file on
the fly. My current solution is to save the object as a temperary xml
file into some directory. Is there a better way that I don't need to
save those temperary files?
The java object is like this and all its attributes are populated from a
database:
MyObject {
long id;
String info;
String imageFileName;
byte[] image;
}
Step 1, I save this object as myObject123.xml and its image file
123.jpg into some temp directory. The xml file looks like this:
<MyObject>
<id>123</id>
<info>object info</info>
<imageFileName>123.jpg</imageFileName>
</MyObject>
Step 2, I create a xslt template file named myObject.xsl which has a
template to insert the image:
<xsl:template match=".">
<fo:external-graphic>
<xsl:attribute name="src"><xsl:value-of select="imageFileName"
/> </xsl:attribute>
</fo:external-graphic>
</xsl:template>
Step 3, I call the API like this:
Driver driver = new Driver();
driver.setRenderer( Driver.RENDER_PDF);
driver.setOutputStream( out );
XSLTInputHandler input = new XSLTInputHandler( new File(
"myObject123.xml" ), new File( "myObject.xsl") );
driver.render( input.getParser(), input.getInputSource() );
Step 4. I delete all temperary files: myObject123.xml and 123.jpg.
Thanks for any suggestions.
Biying
Re: Is there a better way that I don't need to save those temperary
files?
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Biying Huang wrote:
> I am learning how to use FOP to format a java object into a PDF file on
> the fly. My current solution is to save the object as a temperary xml
> file into some directory. Is there a better way that I don't need to
> save those temperary files?
Look here for the XML
http://marc.theaimsgroup.com/?l=fop-user&m=102873292920835&w=2
it is a bit harder for the Images you probably should stick to
temporary files there.
J.Pietschmann