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 Tim Dyck <Ti...@dis-corp.com> on 2006/02/16 01:53:26 UTC

problems with printing: fop-0.91

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?

 

Thanks,

 

Tim.

 

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

 * 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: ExampleXML2FO.java 332791 2005-11-12 15:58:07Z jeremias $ */

 

package embedding;

 

//Java

import java.io.File;

import java.io.IOException;

import java.io.OutputStream;

 

//JAXP

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
file

 * 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
problem

     */

    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 =
TransformerFactory.newInstance();

            Transformer transformer = factory.newTransformer(new
StreamSource(xslt));

        

            //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 {

            out.close();

        }

    }

 

 

    /**

     * Main method.

     * @param args command-line arguments

     */

    public static void main(String[] args) {

        try {

            System.out.println("FOP ExampleXML2FO\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 xmlfile = new File(baseDir, "xml/xml/projectteam.xml");

            File xsltfile = new File(baseDir,
"xml/xslt/projectteam2fo.xsl");

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

            

            File newFoFile = new File(baseDir,
"fo/basic/pdfoutline.fo");

 

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

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

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

            System.out.println();

            System.out.println("Transforming...");

            

            ExampleXML2FO app = new ExampleXML2FO();

            app.convertXML2FO(xmlfile, xsltfile, fofile);

            

            ExampleAWTViewer appViewer = new ExampleAWTViewer();

            appViewer.viewFO(newFoFile);

            

            System.out.println("Success!");

        } catch (Exception e) {

            e.printStackTrace(System.err);

            System.exit(-1);

        }

    }

}


Re: problems with printing: fop-0.91

Posted by Manuel Mall <ma...@apache.org>.
Tim,

you didn't say which renderer (output format) you used for your attempts
at printing. If you used PCL that renderer is non functional in the FOP
0.91 release (that's why it is in the sandbox area). See also
http://xmlgraphics.apache.org/fop/status.html.

Your best option is probably to go via PDF and print the PDF file.
Actually the very best option is if you could find the time to fix the PCL
renderer :-).

Manuel

> 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?
>
>
>
> Thanks,
>
>
>
> Tim.
>
>
>
> ----- 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,
>
>  * 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: ExampleXML2FO.java 332791 2005-11-12 15:58:07Z jeremias $ */
>
>
>
> package embedding;
>
>
>
> //Java
>
> import java.io.File;
>
> import java.io.IOException;
>
> import java.io.OutputStream;
>
>
>
> //JAXP
>
> 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
> file
>
>  * 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
> problem
>
>      */
>
>     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 TransformerFactory.newInstance();
>
>             Transformer transformer = factory.newTransformer(new
> StreamSource(xslt));
>
>
>
>             //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 {
>
>             out.close();
>
>         }
>
>     }
>
>
>
>
>
>     /**
>
>      * Main method.
>
>      * @param args command-line arguments
>
>      */
>
>     public static void main(String[] args) {
>
>         try {
>
>             System.out.println("FOP ExampleXML2FO\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 xmlfile = new File(baseDir, "xml/xml/projectteam.xml");
>
>             File xsltfile = new File(baseDir,
> "xml/xslt/projectteam2fo.xsl");
>
>             File fofile = new File(outDir, "ResultXML2FO.fo");
>
>
>
>             File newFoFile = new File(baseDir,
> "fo/basic/pdfoutline.fo");
>
>
>
>             System.out.println("Input: XML (" + xmlfile + ")");
>
>             System.out.println("Stylesheet: " + xsltfile);
>
>             System.out.println("Output: XSL-FO (" + fofile + ")");
>
>             System.out.println();
>
>             System.out.println("Transforming...");
>
>
>
>             ExampleXML2FO app = new ExampleXML2FO();
>
>             app.convertXML2FO(xmlfile, xsltfile, fofile);
>
>
>
>             ExampleAWTViewer appViewer = new ExampleAWTViewer();
>
>             appViewer.viewFO(newFoFile);
>
>
>
>             System.out.println("Success!");
>
>         } catch (Exception e) {
>
>             e.printStackTrace(System.err);
>
>             System.exit(-1);
>
>         }
>
>     }
>
> }
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org