Start by running from the command line. If you still get a problem send us your FO file(s).
On Wed, Jul 3, 2013 at 11:55 AM, cilen.deng <cilend...@gmail.com> wrote: > /* > * 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$ */ > > package tiff; > > // Java > > import org.apache.fop.apps.*; > import org.apache.fop.render.bitmap.TIFFConstants; > import org.apache.fop.render.bitmap.TIFFRenderer; > > 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 java.awt.image.BufferedImage; > import java.io.*; > > /** > * This class demonstrates the conversion of an FO file to PDF using FOP. > */ > public class ExampleFO2Tiff { > > // configure fopFactory as desired > private final FopFactory fopFactory = FopFactory.newInstance(); > > /** > * Converts an FO file to a PDF file using FOP > * @param fo the FO file > * @param tiff the target PDF file > * @throws java.io.IOException In case of an I/O problem > * @throws org.apache.fop.apps.FOPException In case of a FOP problem > */ > public void ExampleFO2Tiff(File fo, File tiff) throws IOException, > FOPException { > > OutputStream out = null; > > try { > FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); > foUserAgent.setTargetResolution(204); > TIFFRenderer renderer = new TIFFRenderer(foUserAgent); > > > renderer.getWriterParams().setCompressionMethod(TIFFConstants.COMPRESSION_PACKBITS); > foUserAgent.setRendererOverride(renderer); > // configure foUserAgent as desired > > // Setup output stream. Note: Using BufferedOutputStream > // for performance reasons (helpful with FileOutputStreams). > out = new FileOutputStream(tiff); > out = new BufferedOutputStream(out); > > fopFactory.setUserConfig(new > > File("/home/fanfu/projects/untitled1/fanfuWeb/src/main/resources/fos/fop.xconf")); > // Construct fop with desired output format > Fop fop = fopFactory.newFop(MimeConstants.MIME_TIFF, > foUserAgent, out); > > // Setup JAXP using identity transformer > TransformerFactory factory = TransformerFactory.newInstance(); > Transformer transformer = factory.newTransformer(); // identity > transformer > // 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 ExampleFO2PDF\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("/home/fanfu/projects/untitled1/fanfuWeb/src/main/resources/fos/ > simple.fo"); > //File fofile = new File(baseDir, > "/home/fanfu/projects/untitled1/fanfuWeb/src/main/resources/fos// > franklin_2pageseqs.fo"); > File pdffile = new File( "/home/fanfu/fax/ResultFO2Tiff.tif"); > > System.out.println("Input: XSL-FO (" + fofile + ")"); > System.out.println("Output: PDF (" + pdffile + ")"); > System.out.println(); > System.out.println("Transforming..."); > > ExampleFO2Tiff app = new ExampleFO2Tiff(); > > app.ExampleFO2Tiff(fofile, pdffile); > > System.out.println("Success!"); > } catch (Exception e) { > e.printStackTrace(System.err); > System.exit(-1); > } > } > } > > The code is just above , but I JUST get a blank tiff file but no any > content .can anyone help me with this problem? Thanks sincerely > > > > > > -- > View this message in context: > http://apache-fop.1065347.n5.nabble.com/Help-when-create-a-tiff-G3-1D-fax-file-tp38849.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 > >