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 Gary Fix <ga...@unigard.com> on 2003/04/23 20:33:25 UTC
How To Direct FOP Output To A String That Can Be Written To A Fil
e?
Hi!
How do I direct FOP output to a string that can be written to a file?
When I use the code shown below, and write it to a file, it cannot be read
by Acrobat reader...
Here is a snippet of what I am using:
public String convertToPDF(String inputToBeConverted) {
StringReader inputStringReader = new
StringReader(inputToBeConverted);
ByteArrayOutputStream out = new
ByteArrayOutputStream();
try {
Driver driver = new Driver();
driver.setLogger(logger);
driver.setRenderer(Driver.RENDER_PDF);
driver.setInputSource(new
InputSource(inputStringReader));
driver.setOutputStream(out);
driver.run();
out.flush();
out.close();
driver = null;
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return out.toString();
}
thanks!
gary...
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: How To Direct FOP Output To A String That Can Be Written To A
Fil e?
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Gary Fix wrote:
> How do I direct FOP output to a string that can be written to a file?
> When I use the code shown below, and write it to a file, it cannot be read
> by Acrobat reader...
FOP output is binary, converting it to a character string and
back may result in a different byte sequence. Just don't do this,
use byte arrays unless you relly know what you are doing.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: How To Direct FOP Output To A String That Can Be Written To A File?
Posted by Jeremias Maerki <de...@greenmail.ch>.
That won't work. PDF is a binary format. You have to use a byte[] if you
absolutely want to keep the whole PDF in memory.
Use:
return out.toByteArray();
On 23.04.2003 21:37:22 Gary Fix wrote:
> Hi Victor,
> Yes, I really do want to output to a String...
> My goal is to return the PDF String to a calling class or application
> instead of directing the PDF straight to a File...
>
> I have another method that directs the PDF output straight to a File and it
> works great...
> But when I try to return a PDF String, then write this to a file (or to the
> console and paste it to a file) for testing, I get a blank page...
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
RE: How To Direct FOP Output To A String That Can Be Written To A File?
Posted by Victor Mote <vi...@outfitr.com>.
Gary Fix wrote:
> How do I direct FOP output to a string that can be written to a file?
Why do you want to do this? Is this what you really want:
http://xml.apache.org/fop/embedding.html ?
Victor Mote
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org