xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Dyck" <T...@dis-corp.com>
Subject problems with printing: fop-0.91
Date Thu, 16 Feb 2006 00:53:26 GMT
I have tried printing several of the examples given and so far have been
unable to get anything to print out correctly.  The specific example fo
files that I have tried are:


./examples/embedding/xml/fo/helloworld.fo (a blank page gets printed)

./examples/embedding/xml/xml/projectteam.xml (the title, and the first
have of the left column gets cup off)


./examples/fo/basic/pdfoutline.fo (last 8 to 9 lines of each page do not
get printed though seems)


I tried a few others and they had similar problems.  I tried both going
directly to a printer and also to the program PDFCreator (acts as a
printer driver) and got exactly the same results.  Though, if I generate
a PDF from the fo files and print it from Acrobat then it prints out
just fine (also tried printing a PDF file generated from a fo using
PDFBox but had no such luck).  Also, when viewing any of the files using
the ExampleAWTViewer they all look fine just when I go to print to
either a printer or the PDFCreator do I see issues.  I am currently
using windows XP and am using JDK 1.5.0_05.  Any ideas or suggestions on
how I can print and get something to print correctly?  Is anyone else
seeing these issues?






----- Code - same code as the ExampleXML2FO.java file just modified it
to also pop open a print preview of the file to print:



 * Copyright 1999-2004 The Apache Software Foundation.


 * Licensed 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,


 * See the License for the specific language governing permissions and

 * limitations under the License.



/* $Id: ExampleXML2FO.java 332791 2005-11-12 15:58:07Z jeremias $ */


package embedding;



import java.io.File;

import java.io.IOException;

import java.io.OutputStream;



import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.TransformerException;

import javax.xml.transform.Source;

import javax.xml.transform.Result;

import javax.xml.transform.stream.StreamResult;

import javax.xml.transform.stream.StreamSource;



 * This class demonstrates the conversion of an XML file to an XSL-FO

 * using JAXP (XSLT).


public class ExampleXML2FO {



     * Converts an XML file to an XSL-FO file using JAXP (XSLT).

     * @param xml the XML file

     * @param xslt the stylesheet file

     * @param fo the target XSL-FO file

     * @throws IOException In case of an I/O problem

     * @throws TransformerException In case of a XSL transformation


    public void convertXML2FO(File xml, File xslt, File fo) 

                throws IOException, TransformerException {


        //Setup output

        OutputStream out = new java.io.FileOutputStream(fo);

        try {

            //Setup XSLT

            TransformerFactory factory =

            Transformer transformer = factory.newTransformer(new


            //Setup input for XSLT transformation

            Source src = new StreamSource(xml);


            //Resulting SAX events (the generated FO) must be piped
through to FOP

            Result res = new StreamResult(out);


            //Start XSLT transformation and FOP processing

            transformer.transform(src, res);

        } finally {







     * Main method.

     * @param args command-line arguments


    public static void main(String[] args) {

        try {

            System.out.println("FOP ExampleXML2FO\n");



            //Setup directories

            File baseDir = new File(".");

            File outDir = new File(baseDir, "out");



            //Setup input and output files            

            File xmlfile = new File(baseDir, "xml/xml/projectteam.xml");

            File xsltfile = new File(baseDir,

            File fofile = new File(outDir, "ResultXML2FO.fo");


            File newFoFile = new File(baseDir,


            System.out.println("Input: XML (" + xmlfile + ")");

            System.out.println("Stylesheet: " + xsltfile);

            System.out.println("Output: XSL-FO (" + fofile + ")");




            ExampleXML2FO app = new ExampleXML2FO();

            app.convertXML2FO(xmlfile, xsltfile, fofile);


            ExampleAWTViewer appViewer = new ExampleAWTViewer();




        } catch (Exception e) {






View raw message