You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Ha...@Elaxy.com on 2001/09/12 15:10:26 UTC

Unable to perform PDF creation

Hello,
i have download the newest version of FOP ( 0_20_1_bin ) and could
not perform a pdf creation. I embedded this code:

FileInputStream file = new FileInputStream( new File( "e:\\border.fo" ) );
Driver driver = new Driver( new InputSource( file ), out );
driver.setRenderer( Driver.RENDER_PDF );
driver.setupDefaultMappings();
driver.run();
FileWriter file = new FileWriter( "e:\\my.pdf" );
file.write( new String( out.toByteArray() );
file.flush();
file.close();

in my application. I tried to render 'border.fo' from example directory.
The result is very strange. I got a pdf file that contains only a blank
page.
If i run the 'runtests.bat', all pdf documents will be build correct (
including
border.pdf )

The only difference i see between 'my.pdf' and 'border.pdf' is in pdf
source:

'Border.pdf':

/Producer (FOP 0.20.1) >>
endobj
5 0 obj
<< /Length 1330 /Filter [ /ASCII85Decode /FlateDecode ] >>
stream
Gat=,9lC\:&A@sBoRTAk2FW*qIiJOn.BCEQ1'eHF6a@T8Ohuj\%4M7JlC%)9E9ru......
...

'My.pdf':

/Producer (null) >>
endobj
5 0 obj
<< /Length 1062 /Filter /FlateDecode  >>
stream
xœ?XMoI½ûWô?C?6EU)«Å@2ÚC²²‘†µ(ÿžê™îùpì™2Ê!뽞W¯ª»«ü¼Z<......
...

It seems to be the stream is not correct.

My System:
JDK 1.3 with JBuilder4
Win NT 4.0 and Win98
All Jar-Files included from \\lib

Hope, somebody can help me, because i spended much time to find this error.

greetings harry


Elaxy AG
Harry Grüneis
Gutenbergstr. 5
D- 82178 Puchheim bei München
Tel. +49 (89) 890 130 81 Fax +49 (89) 890 130 89
e-Mail: h.grueneis@turck.de, Web: http://www.turck.de


Re: Unable to perform PDF creation

Posted by Jeremias Maerki <je...@outline.ch>.
Hi

PDF is a binary format. Don't convert it to a String and don't use
FileWriters. Your code should probably look approximately like this:

FileInputStream file = new FileInputStream( new File( "e:\\border.fo" ));
OutputStream out = new FileOutputStream("e:\\my.pdf");
try {
    Driver driver = new Driver( new InputSource( file ), out );
    driver.setRenderer( Driver.RENDER_PDF );
    driver.setupDefaultMappings();
    driver.run();
} finally {
    out.close();
}


On Wed, 12 Sep 2001 15:10:26 +0200 Harry.Grueneis wrote:
> Hello,
> i have download the newest version of FOP ( 0_20_1_bin ) and could
> not perform a pdf creation. I embedded this code:
> 
> FileInputStream file = new FileInputStream( new File( "e:\\border.fo" ) );
> Driver driver = new Driver( new InputSource( file ), out );
> driver.setRenderer( Driver.RENDER_PDF );
> driver.setupDefaultMappings();
> driver.run();
> FileWriter file = new FileWriter( "e:\\my.pdf" );
> file.write( new String( out.toByteArray() );
> file.flush();
> file.close();
> 
> in my application. I tried to render 'border.fo' from example directory.
> The result is very strange. I got a pdf file that contains only a blank
> page.
> If i run the 'runtests.bat', all pdf documents will be build correct (
> including
> border.pdf )
> 
> The only difference i see between 'my.pdf' and 'border.pdf' is in pdf
> source:
> 
> 'Border.pdf':
> 
> /Producer (FOP 0.20.1) >>
> endobj
> 5 0 obj
> << /Length 1330 /Filter [ /ASCII85Decode /FlateDecode ] >>
> stream
> Gat=,9lC\:&A@sBoRTAk2FW*qIiJOn.BCEQ1'eHF6a@T8Ohuj\%4M7JlC%)9E9ru......
> ...
> 
> 'My.pdf':
> 
> /Producer (null) >>
> endobj
> 5 0 obj
> << /Length 1062 /Filter /FlateDecode  >>
> stream
> xœ?XMoI½ûWô?C?6EU)«Å@2ÚC²²‘†µ(ÿžê™îùpì™2Ê!뽞W¯ª»«ü¼Z<......
> ...
> 
> It seems to be the stream is not correct.
> 
> My System:
> JDK 1.3 with JBuilder4
> Win NT 4.0 and Win98
> All Jar-Files included from \\lib
> 
> Hope, somebody can help me, because i spended much time to find this error.
> 
> greetings harry
> 
> 
> Elaxy AG
> Harry Grüneis
> Gutenbergstr. 5
> D- 82178 Puchheim bei München
> Tel. +49 (89) 890 130 81 Fax +49 (89) 890 130 89
> e-Mail: h.grueneis@turck.de, Web: http://www.turck.de
> 

Freundliche Grüsse
OUTLINE AG
Jeremias Märki

mailto:jeremias.maerki@outline.ch

Postfach 3954 - Rhynauerstr. 15 - CH-6002 Luzern
Fon +41 (41) 317 2020 - Fax +41 (41) 317 2029
Internet http://www.outline.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org