Hi Massimo, I would suggest to use the same example but this time write to an actual file. I have modified the PDF example in case you haven't already done so to output PostScript (the same format the print example uses). If it writes "Hello World" to the file correctly then it shows that this is likely to be related to the existing bug and unfortunately until that is resolved the only option will be to render to a file and print from the viewer. If however, it does not write to the file and is blank, then that will suggest something is maybe going wrong at the renderer level.
Note: You may need to change line 122 to change the location of where the helloworld.fo file is being read from. Regards, Robert Meyer > Date: Mon, 3 Dec 2012 03:26:58 -0800 > From: massimo.iasev...@snai.it > To: fop-users@xmlgraphics.apache.org > Subject: RE: Printed blank page when running example class > ExampleFO2JPSPrint.java > > Hi. > > I changed ExampleFO2JPSPrint.java as you recommended and it prints > (Sytem.out.println) values only if i change target resolution: > > *userAgent.setTargetResolution(200);* > > but the printed page is blank yet. > > My SO is XP Sp3 and FOP 1.1. > > Regards, > Massimo. > > > > -- > View this message in context: > http://apache-fop.1065347.n5.nabble.com/Printed-blank-page-when-running-example-class-ExampleFO2JPSPrint-java-tp37429p37444.html > Sent from the FOP - Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org > For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org >
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* $Id$ */ // Java import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FormattingResults; import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.PageSequenceResults; /** * This class demonstrates the conversion of an FO file to PDF using FOP. */ public class ExampleFO2PS { // configure fopFactory as desired private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); /** * Converts an FO file to a PDF file using FOP * @param fo the FO file * @param pdf the target PDF file * @throws IOException In case of an I/O problem * @throws FOPException In case of a FOP problem */ public void convertFO2PDF(File fo, File pdf) throws IOException, FOPException { OutputStream out = null; try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); out = new BufferedOutputStream(out); // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_EPS, foUserAgent, out); // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer // Setup input stream Source src = new StreamSource(fo); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); // Start XSLT transformation and FOP processing transformer.transform(src, res); // Result processing FormattingResults foResults = fop.getResults(); java.util.List pageSequences = foResults.getPageSequences(); for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); System.out.println("PageSequence " + (String.valueOf(pageSequenceResults.getID()).length() > 0 ? pageSequenceResults.getID() : "<no id>") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); } finally { out.close(); } } /** * Main method. * @param args command-line arguments */ public static void main(String[] args) { try { System.out.println("FOP ExampleFO2PS\n"); System.out.println("Preparing..."); //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); //Setup input and output files File fofile = new File(baseDir, "helloworld.fo"); //File fofile = new File(baseDir, "../fo/pagination/franklin_2pageseqs.fo"); File pdffile = new File(outDir, "ResultFO2PDF.ps"); System.out.println("Input: XSL-FO (" + fofile + ")"); System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); ExampleFO2PS app = new ExampleFO2PS(); app.convertFO2PDF(fofile, pdffile); System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org