Browse Source

Deprecated constructors Fop(int) and Fop(int, FOUserAgent).

Deprecated Fop.getVersion() in favor for Version.getVersion().
Changed every place the newly deprecated methods were called.
Ant task and TestConverter changed to fully use MIME types.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@332791 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_90-alpha1
Jeremias Maerki 18 years ago
parent
commit
b4af2746c8
29 changed files with 160 additions and 142 deletions
  1. 2
    1
      examples/embedding/java/embedding/ExampleAWTViewer.java
  2. 2
    1
      examples/embedding/java/embedding/ExampleDOM2PDF.java
  3. 2
    1
      examples/embedding/java/embedding/ExampleFO2OldStylePrint.java
  4. 2
    1
      examples/embedding/java/embedding/ExampleFO2PDF.java
  5. 2
    1
      examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java
  6. 2
    1
      examples/embedding/java/embedding/ExampleFO2RTF.java
  7. 3
    1
      examples/embedding/java/embedding/ExampleObj2PDF.java
  8. 3
    2
      examples/embedding/java/embedding/ExampleXML2PDF.java
  9. 2
    1
      src/java/org/apache/fop/apps/FOUserAgent.java
  10. 10
    1
      src/java/org/apache/fop/apps/Fop.java
  11. 2
    1
      src/java/org/apache/fop/cli/CommandLineOptions.java
  12. 3
    3
      src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java
  13. 2
    2
      src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
  14. 2
    2
      src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java
  15. 2
    2
      src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java
  16. 5
    4
      src/java/org/apache/fop/servlet/FopPrintServlet.java
  17. 4
    3
      src/java/org/apache/fop/servlet/FopServlet.java
  18. 23
    26
      src/java/org/apache/fop/tools/TestConverter.java
  19. 61
    66
      src/java/org/apache/fop/tools/anttasks/Fop.java
  20. 5
    4
      test/java/org/apache/fop/BasicDriverTestCase.java
  21. 2
    1
      test/java/org/apache/fop/GenericFOPTestCase.java
  22. 3
    2
      test/java/org/apache/fop/URIResolutionTestCase.java
  23. 2
    2
      test/java/org/apache/fop/fotreetest/FOTreeTester.java
  24. 2
    2
      test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
  25. 2
    2
      test/java/org/apache/fop/threading/FOProcessorImpl.java
  26. 2
    2
      test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java
  27. 2
    1
      test/java/org/apache/fop/visual/BitmapProducerJava2D.java
  28. 3
    3
      test/java/org/apache/fop/visual/BitmapProducerPDF.java
  29. 3
    3
      test/java/org/apache/fop/visual/BitmapProducerPS.java

+ 2
- 1
examples/embedding/java/embedding/ExampleAWTViewer.java View File

//FOP //FOP
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.fo.Constants; import org.apache.fop.fo.Constants;
/** /**
throws IOException, FOPException, TransformerException { throws IOException, FOPException, TransformerException {
//Setup FOP //Setup FOP
Fop fop = new Fop(Constants.RENDER_AWT);
Fop fop = new Fop(MimeConstants.MIME_FOP_AWT_PREVIEW);
try { try {

+ 2
- 1
examples/embedding/java/embedding/ExampleDOM2PDF.java View File



// FOP // FOP
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;




/** /**
public void convertDOM2PDF(Document xslfoDoc, File pdf) { public void convertDOM2PDF(Document xslfoDoc, File pdf) {
try { try {
// Construct fop with desired output format // Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output // Setup output
OutputStream out = new java.io.FileOutputStream(pdf); OutputStream out = new java.io.FileOutputStream(pdf);

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2OldStylePrint.java View File

import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.print.PrintRenderer; import org.apache.fop.render.print.PrintRenderer;
/** /**
userAgent.setRendererOverride(renderer); userAgent.setRendererOverride(renderer);
// Construct fop with desired output format // Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PRINT, userAgent);
Fop fop = new Fop(MimeConstants.MIME_FOP_PRINT, userAgent);
//Note: the first parameter here has no effect if we use //Note: the first parameter here has no effect if we use
//FOUserAgent.setRendererOverride() //FOUserAgent.setRendererOverride()

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2PDF.java View File

import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FormattingResults; import org.apache.fop.apps.FormattingResults;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PageSequenceResults; import org.apache.fop.apps.PageSequenceResults;


/** /**
try { try {
// Construct fop with desired output format // Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output stream. Note: Using BufferedOutputStream // Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams). // for performance reasons (helpful with FileOutputStreams).

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java View File

// FOP // FOP
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;


/** /**
* This class demonstrates the conversion of an FO file to PDF using FOP. * This class demonstrates the conversion of an FO file to PDF using FOP.
try { try {
// Construct fop and setup output format // Construct fop and setup output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output stream. Note: Using BufferedOutputStream // Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams). // for performance reasons (helpful with FileOutputStreams).

+ 2
- 1
examples/embedding/java/embedding/ExampleFO2RTF.java View File

// FOP // FOP
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;


/** /**
* This class demonstrates the conversion of an FO file to RTF using FOP. * This class demonstrates the conversion of an FO file to RTF using FOP.
try { try {
// Construct fop with desired output format // Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_RTF);
Fop fop = new Fop(MimeConstants.MIME_RTF);
// Setup output stream. Note: Using BufferedOutputStream // Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams). // for performance reasons (helpful with FileOutputStreams).

+ 3
- 1
examples/embedding/java/embedding/ExampleObj2PDF.java View File

// FOP // FOP
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;

import embedding.model.ProjectTeam; import embedding.model.ProjectTeam;


/** /**
throws IOException, FOPException, TransformerException { throws IOException, FOPException, TransformerException {
// Construct fop with desired output format // Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);


// Setup output // Setup output
OutputStream out = new java.io.FileOutputStream(pdf); OutputStream out = new java.io.FileOutputStream(pdf);

+ 3
- 2
examples/embedding/java/embedding/ExampleXML2PDF.java View File

/* /*
* Copyright 1999-2004 The Apache Software Foundation.
* Copyright 1999-2005 The Apache Software Foundation.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.


//FOP //FOP
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;


/** /**
* This class demonstrates the conversion of an XML file to PDF using * This class demonstrates the conversion of an XML file to PDF using
System.out.println("Transforming..."); System.out.println("Transforming...");
// Construct fop with desired output format // Construct fop with desired output format
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Setup output // Setup output
OutputStream out = new java.io.FileOutputStream(pdffile); OutputStream out = new java.io.FileOutputStream(pdffile);

+ 2
- 1
src/java/org/apache/fop/apps/FOUserAgent.java View File

import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;


// FOP // FOP
import org.apache.fop.Version;
import org.apache.fop.fo.ElementMapping; import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.layoutmgr.LayoutManagerMaker; import org.apache.fop.layoutmgr.LayoutManagerMaker;
/** Producer: Metadata element for the system/software that produces /** Producer: Metadata element for the system/software that produces
* the document. (Some renderers can store this in the document.) * the document. (Some renderers can store this in the document.)
*/ */
protected String producer = "Apache FOP Version " + Fop.getVersion();
protected String producer = "Apache FOP Version " + Version.getVersion();


/** Creator: Metadata element for the user that created the /** Creator: Metadata element for the user that created the
* document. (Some renderers can store this in the document.) * document. (Some renderers can store this in the document.)

+ 10
- 1
src/java/org/apache/fop/apps/Fop.java View File

* Primary class that activates the FOP process for embedded usage. * Primary class that activates the FOP process for embedded usage.
* <P> * <P>
* JAXP is the standard method of embedding FOP in Java programs. * JAXP is the standard method of embedding FOP in Java programs.
* Please check our <a href="http://xmlgraphics.apache.org/fop/embedding.html">embedding page</a>
* Please check our
* <a href="http://xmlgraphics.apache.org/fop/trunk/embedding.html">embedding page</a>
* for samples (these are also available within the distribution in * for samples (these are also available within the distribution in
* FOP_DIR\examples\embedding) * FOP_DIR\examples\embedding)
* <P> * <P>
* process. For example, a specific Renderer object can be specified, * process. For example, a specific Renderer object can be specified,
* also ElementMappings which determine elements in the FO that can be * also ElementMappings which determine elements in the FO that can be
* processed) can be added. * processed) can be added.
* <P>
* At the moment, it is recommended not to reuse an instance of this
* class for more than one rendering run.
*/ */
public class Fop implements Constants { public class Fop implements Constants {


* </ul> * </ul>
* @param ua FOUserAgent object * @param ua FOUserAgent object
* @throws IllegalArgumentException if an unsupported renderer type was requested. * @throws IllegalArgumentException if an unsupported renderer type was requested.
* @deprecated Use {@link org.apache.fop.apps.Fop#Fop(java.lang.String, FOUserAgent)} instead!
* This constructor will be removed.
*/ */
public Fop(int renderType, FOUserAgent ua) { public Fop(int renderType, FOUserAgent ua) {
this(getMimeTypeForRenderType(renderType), ua); this(getMimeTypeForRenderType(renderType), ua);
/** /**
* Constructor that creates a default FOUserAgent * Constructor that creates a default FOUserAgent
* @see org.apache.fop.apps.Fop#Fop(int, FOUserAgent) * @see org.apache.fop.apps.Fop#Fop(int, FOUserAgent)
* @deprecated Use {@link org.apache.fop.apps.Fop#Fop(java.lang.String)} instead!
* This constructor will be removed.
*/ */
public Fop(int renderType) { public Fop(int renderType) {
this(renderType, null); this(renderType, null);
/** /**
* Get the version of FOP * Get the version of FOP
* @return the version string * @return the version string
* @deprecated Use {@link org.apache.fop.Version#getVersion()} instead!
*/ */
public static String getVersion() { public static String getVersion() {
return org.apache.fop.Version.getVersion(); return org.apache.fop.Version.getVersion();

+ 2
- 1
src/java/org/apache/fop/cli/CommandLineOptions.java View File

import java.util.Locale; import java.util.Locale;
import java.util.Vector; import java.util.Vector;


import org.apache.fop.Version;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
} else if (args[i].equals("-at")) { } else if (args[i].equals("-at")) {
i = i + parseAreaTreeOption(args, i); i = i + parseAreaTreeOption(args, i);
} else if (args[i].equals("-v")) { } else if (args[i].equals("-v")) {
System.out.println("FOP Version " + Fop.getVersion());
System.out.println("FOP Version " + Version.getVersion());
} else if (args[i].equals("-param")) { } else if (args[i].equals("-param")) {
if (i + 2 < args.length) { if (i + 2 < args.length) {
if (xsltParams == null) { if (xsltParams == null) {

+ 3
- 3
src/java/org/apache/fop/render/awt/viewer/PreviewDialogAboutBox.java View File

/* /*
* Copyright 1999-2004 The Apache Software Foundation.
* Copyright 1999-2005 The Apache Software Foundation.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;


//FOP //FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.Version;


/** /**
* AWT Viewer's "About" dialog. * AWT Viewer's "About" dialog.
imageControl1.setIcon(new ImageIcon(getClass().getResource("images/fop.gif"))); imageControl1.setIcon(new ImageIcon(getClass().getResource("images/fop.gif")));
JLabel label1 = new JLabel(translator.getString("About.Product")); JLabel label1 = new JLabel(translator.getString("About.Product"));
JLabel label2 = new JLabel(translator.getString("About.Version") JLabel label2 = new JLabel(translator.getString("About.Version")
+ " " + Fop.getVersion());
+ " " + Version.getVersion());
JLabel label3 = new JLabel(translator.getString("About.Copyright")); JLabel label3 = new JLabel(translator.getString("About.Copyright"));
panel1.setLayout(new BorderLayout()); panel1.setLayout(new BorderLayout());
panel2.setLayout(new BorderLayout()); panel2.setLayout(new BorderLayout());

+ 2
- 2
src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java View File

import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.PageViewport; import org.apache.fop.area.PageViewport;


import org.apache.fop.fo.Constants;
import org.apache.fop.render.awt.AWTRenderer; import org.apache.fop.render.awt.AWTRenderer;




} }


//Always recreate the Fop instance. It is a use-once only. //Always recreate the Fop instance. It is a use-once only.
fop = new Fop(Constants.RENDER_AWT, foUserAgent);
fop = new Fop(MimeConstants.MIME_FOP_AWT_PREVIEW, foUserAgent);


pagePanels = null; pagePanels = null;



+ 2
- 2
src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java View File



import java.io.IOException; import java.io.IOException;


import org.apache.fop.apps.Fop;
import org.apache.fop.Version;


/** /**
* This class is a wrapper for the <tt>AbstractPSDocumentGraphics2D</tt> that * This class is a wrapper for the <tt>AbstractPSDocumentGraphics2D</tt> that
//PostScript Header //PostScript Header
gen.writeln(DSCConstants.PS_ADOBE_30 + " " + DSCConstants.EPSF_30); gen.writeln(DSCConstants.PS_ADOBE_30 + " " + DSCConstants.EPSF_30);
gen.writeDSCComment(DSCConstants.CREATOR, gen.writeDSCComment(DSCConstants.CREATOR,
new String[] {"Apache FOP " + Fop.getVersion()
new String[] {"Apache FOP " + Version.getVersion()
+ ": EPS Transcoder for SVG"}); + ": EPS Transcoder for SVG"});
gen.writeDSCComment(DSCConstants.CREATION_DATE, gen.writeDSCComment(DSCConstants.CREATION_DATE,
new Object[] {new java.util.Date()}); new Object[] {new java.util.Date()});

+ 2
- 2
src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java View File

import java.io.IOException; import java.io.IOException;


//FOP //FOP
import org.apache.fop.apps.Fop;
import org.apache.fop.Version;
import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontSetup; import org.apache.fop.fonts.FontSetup;


//PostScript Header //PostScript Header
gen.writeln(DSCConstants.PS_ADOBE_30); gen.writeln(DSCConstants.PS_ADOBE_30);
gen.writeDSCComment(DSCConstants.CREATOR, gen.writeDSCComment(DSCConstants.CREATOR,
new String[] {"Apache FOP " + Fop.getVersion()
new String[] {"Apache FOP " + Version.getVersion()
+ ": PostScript Transcoder for SVG"}); + ": PostScript Transcoder for SVG"});
gen.writeDSCComment(DSCConstants.CREATION_DATE, gen.writeDSCComment(DSCConstants.CREATION_DATE,
new Object[] {new java.util.Date()}); new Object[] {new java.util.Date()});

+ 5
- 4
src/java/org/apache/fop/servlet/FopPrintServlet.java View File

/* /*
* Copyright 1999-2004 The Apache Software Foundation.
* Copyright 1999-2005 The Apache Software Foundation.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
// XML // XML
import org.apache.commons.logging.impl.SimpleLog; import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;




/** /**
* Example URL: http://servername/fop/servlet/FopPrintServlet?xml=data.xml&xsl=format.xsl * Example URL: http://servername/fop/servlet/FopPrintServlet?xml=data.xml&xsl=format.xsl
* *
* @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a> * @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a>
* @version $Id: FopPrintServlet.java,v 1.2 2003/03/07 09:48:05 jeremias Exp $
* @version $Id$
* (todo) Doesn't work since there's no AWTRenderer at the moment. Revisit when * (todo) Doesn't work since there's no AWTRenderer at the moment. Revisit when
* available. * available.
* (todo) Ev. add caching mechanism for Templates objects * (todo) Ev. add caching mechanism for Templates objects
public void renderFO(InputStream foFile, public void renderFO(InputStream foFile,
HttpServletResponse response) throws ServletException { HttpServletResponse response) throws ServletException {
try { try {
Fop fop = new Fop(Fop.RENDER_PRINT);
Fop fop = new Fop(MimeConstants.MIME_FOP_PRINT);


// Setup JAXP // Setup JAXP
TransformerFactory factory = TransformerFactory.newInstance(); TransformerFactory factory = TransformerFactory.newInstance();
public void renderXML(File xmlfile, File xsltfile, public void renderXML(File xmlfile, File xsltfile,
HttpServletResponse response) throws ServletException { HttpServletResponse response) throws ServletException {
try { try {
Fop fop = new Fop(Fop.RENDER_PRINT);
Fop fop = new Fop(MimeConstants.MIME_FOP_PRINT);


// Setup XSLT // Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance(); TransformerFactory factory = TransformerFactory.newInstance();

+ 4
- 3
src/java/org/apache/fop/servlet/FopServlet.java View File

/* /*
* Copyright 1999-2004 The Apache Software Foundation.
* Copyright 1999-2005 The Apache Software Foundation.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
//FOP //FOP
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.MimeConstants;


/** /**
* Example servlet to generate a PDF from a servlet. * Example servlet to generate a PDF from a servlet.
* to the URL. * to the URL.
* *
* @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a> * @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a>
* @version $Id: FopServlet.java,v 1.2 2003/03/07 09:48:05 jeremias Exp $
* @version $Id$
* (todo) Ev. add caching mechanism for Templates objects * (todo) Ev. add caching mechanism for Templates objects
*/ */
public class FopServlet extends HttpServlet { public class FopServlet extends HttpServlet {
throws FOPException, TransformerException { throws FOPException, TransformerException {


//Setup FOP //Setup FOP
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);


//Setup output //Setup output
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();

+ 23
- 26
src/java/org/apache/fop/tools/TestConverter.java View File



import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler; import org.apache.fop.cli.InputHandler;
import org.apache.fop.tools.anttasks.FileCompare; import org.apache.fop.tools.anttasks.FileCompare;
import org.w3c.dom.Document; import org.w3c.dom.Document;


import org.apache.commons.logging.impl.SimpleLog; import org.apache.commons.logging.impl.SimpleLog;



/** /**
* TestConverter is used to process a set of tests specified in * TestConverter is used to process a set of tests specified in
* a testsuite. * a testsuite.
* The area tree can be used for automatic comparisons between different * The area tree can be used for automatic comparisons between different
* versions of FOP or the pdf can be view for manual checking and * versions of FOP or the pdf can be view for manual checking and
* pdf rendering. * pdf rendering.
*
*/ */
public class TestConverter { public class TestConverter {
private boolean failOnly = false; private boolean failOnly = false;
private int renderType = Fop.RENDER_XML;
private String outputFormat = MimeConstants.MIME_FOP_AREA_TREE;
private File destdir; private File destdir;
private File compare = null; private File compare = null;
private String baseDir = "./"; private String baseDir = "./";
if (args[count].equals("-failOnly")) { if (args[count].equals("-failOnly")) {
tc.setFailOnly(true); tc.setFailOnly(true);
} else if (args[count].equals("-pdf")) { } else if (args[count].equals("-pdf")) {
tc.setRenderType(Fop.RENDER_PDF);
tc.setOutputFormat(MimeConstants.MIME_PDF);
} else if (args[count].equals("-rtf")) { } else if (args[count].equals("-rtf")) {
tc.setRenderType(Fop.RENDER_RTF);
tc.setOutputFormat(MimeConstants.MIME_RTF);
} else if (args[count].equals("-ps")) { } else if (args[count].equals("-ps")) {
tc.setRenderType(Fop.RENDER_PS);
tc.setOutputFormat(MimeConstants.MIME_POSTSCRIPT);
} else if (args[count].equals("-d")) { } else if (args[count].equals("-d")) {
tc.setDebug(true); tc.setDebug(true);
} else if (args[count].equals("-b")) { } else if (args[count].equals("-b")) {
} }


/** /**
* Controls output type to generate
* @param renderType fo.Constants output constant (RENDER_PDF, RENDER_XML, etc.)
* Controls output format to generate
* @param outputFormat the MIME type of the output format
*/ */
public void setRenderType(int renderType) {
this.renderType = renderType;
public void setOutputFormat(String outputFormat) {
this.outputFormat = outputFormat;
} }


/** /**
destdir = new File(baseDir + "/" + dest); destdir = new File(baseDir + "/" + dest);
destdir.mkdirs(); destdir.mkdirs();
File f = new File(baseDir + "/" + fname); File f = new File(baseDir + "/" + fname);
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = factory.newDocumentBuilder(); DocumentBuilder db = factory.newDocumentBuilder();
Document doc = db.parse(f); Document doc = db.parse(f);


testsuite = doc.getDocumentElement(); testsuite = doc.getDocumentElement();


if (testsuite.hasAttributes()) { if (testsuite.hasAttributes()) {
String profile =
testsuite.getAttributes().getNamedItem("profile").getNodeValue();
String profile
= testsuite.getAttributes().getNamedItem("profile").getNodeValue();
logger.debug("testing test suite:" + profile); logger.debug("testing test suite:" + profile);
} }


*/ */
protected void runTestCase(Node tcase) { protected void runTestCase(Node tcase) {
if (tcase.hasAttributes()) { if (tcase.hasAttributes()) {
String profile =
tcase.getAttributes().getNamedItem("profile").getNodeValue();
String profile
= tcase.getAttributes().getNamedItem("profile").getNodeValue();
logger.debug("testing profile:" + profile); logger.debug("testing profile:" + profile);
} }


Node result = locateResult(testcase, id); Node result = locateResult(testcase, id);
boolean pass = false; boolean pass = false;
if (result != null) { if (result != null) {
String agreement =
result.getAttributes().getNamedItem("agreement").getNodeValue();
String agreement
= result.getAttributes().getNamedItem("agreement").getNodeValue();
pass = agreement.equals("full"); pass = agreement.equals("full");
} }




FOUserAgent userAgent = new FOUserAgent(); FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(baseURL); userAgent.setBaseURL(baseURL);
Fop fop = new Fop(renderType, userAgent);
Fop fop = new Fop(outputFormat, userAgent);


userAgent.getRendererOptions().put("fineDetail", new Boolean(false)); userAgent.getRendererOptions().put("fineDetail", new Boolean(false));
userAgent.getRendererOptions().put("consistentOutput", new Boolean(true)); userAgent.getRendererOptions().put("consistentOutput", new Boolean(true));
OutputStream outStream = new java.io.BufferedOutputStream( OutputStream outStream = new java.io.BufferedOutputStream(
new java.io.FileOutputStream(outputFile)); new java.io.FileOutputStream(outputFile));
fop.setOutputStream(outStream); fop.setOutputStream(outStream);
logger.debug("ddir:" + destdir + " on:" +
outputFile.getName());
logger.debug("ddir:" + destdir + " on:" + outputFile.getName());
inputHandler.render(fop); inputHandler.render(fop);
outStream.close(); outStream.close();


* Return a suitable file extension for the output format. * Return a suitable file extension for the output format.
*/ */
private String makeResultExtension() { private String makeResultExtension() {
if (renderType == Fop.RENDER_PDF) {
if (MimeConstants.MIME_PDF.equals(outputFormat)) {
return ".pdf"; return ".pdf";
} else if (renderType == Fop.RENDER_RTF) {
} else if (MimeConstants.MIME_RTF.equals(outputFormat)) {
return ".rtf"; return ".rtf";
} else if (renderType == Fop.RENDER_PS) {
} else if (MimeConstants.MIME_POSTSCRIPT.equals(outputFormat)) {
return ".ps"; return ".ps";
} else { } else {
return ".at.xml"; return ".at.xml";
Node node = cases.item(count); Node node = cases.item(count);
String nodename = node.getNodeName(); String nodename = node.getNodeName();
if (nodename.equals("result")) { if (nodename.equals("result")) {
String resultid =
node.getAttributes().getNamedItem("id").getNodeValue();
String resultid
= node.getAttributes().getNamedItem("id").getNodeValue();
if (id.equals(resultid)) { if (id.equals(resultid)) {
return node; return node;
} }

+ 61
- 66
src/java/org/apache/fop/tools/anttasks/Fop.java View File

import java.util.List; import java.util.List;


// FOP // FOP
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler; import org.apache.fop.cli.InputHandler;


import org.apache.commons.logging.impl.SimpleLog; import org.apache.commons.logging.impl.SimpleLog;
case Project.MSG_WARN : logLevel = SimpleLog.LOG_LEVEL_WARN; break; case Project.MSG_WARN : logLevel = SimpleLog.LOG_LEVEL_WARN; break;
case Project.MSG_ERR : logLevel = SimpleLog.LOG_LEVEL_ERROR; break; case Project.MSG_ERR : logLevel = SimpleLog.LOG_LEVEL_ERROR; break;
case Project.MSG_VERBOSE: logLevel = SimpleLog.LOG_LEVEL_DEBUG; break; case Project.MSG_VERBOSE: logLevel = SimpleLog.LOG_LEVEL_DEBUG; break;
default: logLevel = SimpleLog.LOG_LEVEL_INFO;
} }
SimpleLog logger = new SimpleLog("FOP/Anttask"); SimpleLog logger = new SimpleLog("FOP/Anttask");
logger.setLevel(logLevel); logger.setLevel(logLevel);
this.task = task; this.task = task;
} }


private int determineRenderer(String format) {
if ((format == null)
|| format.equalsIgnoreCase("application/pdf")
|| format.equalsIgnoreCase("pdf")) {
return Constants.RENDER_PDF;
} else if (format.equalsIgnoreCase("application/postscript")
|| format.equalsIgnoreCase("ps")) {
return Constants.RENDER_PS;
} else if (format.equalsIgnoreCase("application/vnd.mif")
|| format.equalsIgnoreCase("mif")) {
return Constants.RENDER_MIF;
} else if (format.equalsIgnoreCase("application/msword")
|| format.equalsIgnoreCase("application/rtf")
|| format.equalsIgnoreCase("rtf")) {
return Constants.RENDER_RTF;
} else if (format.equalsIgnoreCase("application/vnd.hp-PCL")
|| format.equalsIgnoreCase("pcl")) {
return Constants.RENDER_PCL;
} else if (format.equalsIgnoreCase("text/plain")
|| format.equalsIgnoreCase("txt")) {
return Constants.RENDER_TXT;
} else if (format.equalsIgnoreCase("text/xml")
|| format.equalsIgnoreCase("at")
|| format.equalsIgnoreCase("xml")) {
return Constants.RENDER_XML;
} else if (format.equalsIgnoreCase("image/tiff")
|| format.equalsIgnoreCase("tiff")
|| format.equalsIgnoreCase("tif")) {
return Constants.RENDER_TIFF;
} else if (format.equalsIgnoreCase("image/png")
|| format.equalsIgnoreCase("png")) {
return Constants.RENDER_PNG;
} else {
String err = "Couldn't determine renderer to use: " + format;
throw new BuildException(err);
private static final String[][] SHORT_NAMES = {
{"pdf", MimeConstants.MIME_PDF},
{"ps", MimeConstants.MIME_POSTSCRIPT},
{"mif", MimeConstants.MIME_MIF},
{"rtf", MimeConstants.MIME_RTF},
{"pcl", MimeConstants.MIME_PCL},
{"txt", MimeConstants.MIME_PLAIN_TEXT},
{"at", MimeConstants.MIME_FOP_AREA_TREE},
{"xml", MimeConstants.MIME_FOP_AREA_TREE},
{"tiff", MimeConstants.MIME_TIFF},
{"tif", MimeConstants.MIME_TIFF},
{"png", MimeConstants.MIME_PNG}
};

private String normalizeOutputFormat(String format) {
for (int i = 0; i < SHORT_NAMES.length; i++) {
if (SHORT_NAMES[i][0].equals(format)) {
return SHORT_NAMES[i][1];
}
} }
return format; //no change
} }


private String determineExtension(int renderer) {
switch (renderer) {
case Constants.RENDER_PDF:
return ".pdf";
case Constants.RENDER_PS:
return ".ps";
case Constants.RENDER_MIF:
return ".mif";
case Constants.RENDER_RTF:
return ".rtf";
case Constants.RENDER_PCL:
return ".pcl";
case Constants.RENDER_TXT:
return ".txt";
case Constants.RENDER_XML:
return ".xml";
case Constants.RENDER_TIFF:
return ".tiff";
case Constants.RENDER_PNG:
return ".png";
default:
String err = "Unknown renderer: " + renderer;
throw new BuildException(err);
private static final String[][] EXTENSIONS = {
{MimeConstants.MIME_FOP_AREA_TREE, ".at.xml"},
{MimeConstants.MIME_FOP_AWT_PREVIEW, null},
{MimeConstants.MIME_FOP_PRINT, null},
{MimeConstants.MIME_PDF, ".pdf"},
{MimeConstants.MIME_POSTSCRIPT, ".ps"},
{MimeConstants.MIME_PCL, ".pcl"},
{MimeConstants.MIME_PCL_ALT, ".pcl"},
{MimeConstants.MIME_PLAIN_TEXT, ".txt"},
{MimeConstants.MIME_RTF, ".rtf"},
{MimeConstants.MIME_RTF_ALT1, ".rtf"},
{MimeConstants.MIME_RTF_ALT2, ".rtf"},
{MimeConstants.MIME_MIF, ".mif"},
{MimeConstants.MIME_SVG, ".svg"},
{MimeConstants.MIME_PNG, ".png"},
{MimeConstants.MIME_JPEG, ".jpg"},
{MimeConstants.MIME_TIFF, ".tif"},
{MimeConstants.MIME_XSL_FO, ".fo"}
};
private String determineExtension(String outputFormat) {
for (int i = 0; i < EXTENSIONS.length; i++) {
if (EXTENSIONS[i][0].equals(outputFormat)) {
String ext = EXTENSIONS[i][1];
if (ext == null) {
throw new RuntimeException("Output format '"
+ outputFormat + "' does not produce a file.");
} else {
return ext;
}
}
} }
return ".unk"; //unknown
} }


private File replaceExtension(File file, String expectedExt, private File replaceExtension(File file, String expectedExt,


task.log("Using base URL: " + baseURL, Project.MSG_DEBUG); task.log("Using base URL: " + baseURL, Project.MSG_DEBUG);


int rint = determineRenderer(task.getFormat());
String newExtension = determineExtension(rint);
String outputFormat = normalizeOutputFormat(task.getFormat());
String newExtension = determineExtension(outputFormat);


// actioncount = # of fofiles actually processed through FOP // actioncount = # of fofiles actually processed through FOP
int actioncount = 0; int actioncount = 0;
// output file is older than input file // output file is older than input file
if (task.getForce() || !outf.exists() if (task.getForce() || !outf.exists()
|| (task.getFofile().lastModified() > outf.lastModified() )) { || (task.getFofile().lastModified() > outf.lastModified() )) {
render(task.getFofile(), outf, rint);
render(task.getFofile(), outf, outputFormat);
actioncount++; actioncount++;
} else if (outf.exists() } else if (outf.exists()
&& (task.getFofile().lastModified() <= outf.lastModified() )) { && (task.getFofile().lastModified() <= outf.lastModified() )) {
// output file is older than input file // output file is older than input file
if (task.getForce() || !outf.exists() if (task.getForce() || !outf.exists()
|| (f.lastModified() > outf.lastModified() )) { || (f.lastModified() > outf.lastModified() )) {
render(f, outf, rint);
render(f, outf, outputFormat);
actioncount++; actioncount++;
} else if (outf.exists() && (f.lastModified() <= outf.lastModified() )) { } else if (outf.exists() && (f.lastModified() <= outf.lastModified() )) {
skippedcount++; skippedcount++;
} }


private void render(File foFile, File outFile, private void render(File foFile, File outFile,
int renderer) throws FOPException {
String outputFormat) throws FOPException {
InputHandler inputHandler = new InputHandler(foFile); InputHandler inputHandler = new InputHandler(foFile);


OutputStream out = null; OutputStream out = null;
try { try {
FOUserAgent userAgent = new FOUserAgent(); FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(this.baseURL); userAgent.setBaseURL(this.baseURL);
org.apache.fop.apps.Fop fop =
new org.apache.fop.apps.Fop(renderer, userAgent);
org.apache.fop.apps.Fop fop = new org.apache.fop.apps.Fop(
outputFormat, userAgent);
fop.setOutputStream(out); fop.setOutputStream(out);
inputHandler.render(fop); inputHandler.render(fop);
} catch (Exception ex) { } catch (Exception ex) {

+ 5
- 4
test/java/org/apache/fop/BasicDriverTestCase.java View File



import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler; import org.apache.fop.cli.InputHandler;


/** /**
public void testFO2PDFWithJAXP() throws Exception { public void testFO2PDFWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream(); ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(baout); fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance(); TransformerFactory factory = TransformerFactory.newInstance();
public void testFO2PSWithJAXP() throws Exception { public void testFO2PSWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream(); ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_PS);
Fop fop = new Fop(MimeConstants.MIME_POSTSCRIPT);
fop.setOutputStream(baout); fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance(); TransformerFactory factory = TransformerFactory.newInstance();
public void testFO2RTFWithJAXP() throws Exception { public void testFO2RTFWithJAXP() throws Exception {
File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo"); File foFile = new File(getBaseDir(), "test/xml/bugtests/block.fo");
ByteArrayOutputStream baout = new ByteArrayOutputStream(); ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_RTF);
Fop fop = new Fop(MimeConstants.MIME_RTF);
fop.setOutputStream(baout); fop.setOutputStream(baout);
TransformerFactory factory = TransformerFactory.newInstance(); TransformerFactory factory = TransformerFactory.newInstance();
File xmlFile = new File(getBaseDir(), "test/xml/1.xml"); File xmlFile = new File(getBaseDir(), "test/xml/1.xml");
File xsltFile = new File(getBaseDir(), "test/xsl/doc.xsl"); File xsltFile = new File(getBaseDir(), "test/xsl/doc.xsl");
ByteArrayOutputStream baout = new ByteArrayOutputStream(); ByteArrayOutputStream baout = new ByteArrayOutputStream();
Fop fop = new Fop(Fop.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(baout); fop.setOutputStream(baout);
InputHandler handler = new InputHandler(xmlFile, xsltFile, null); InputHandler handler = new InputHandler(xmlFile, xsltFile, null);

+ 2
- 1
test/java/org/apache/fop/GenericFOPTestCase.java View File



import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.util.DigestFilter; import org.apache.fop.util.DigestFilter;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;


MessageDigest outDigest = MessageDigest.getInstance("MD5"); MessageDigest outDigest = MessageDigest.getInstance("MD5");
DigestOutputStream out = DigestOutputStream out =
new DigestOutputStream(new ByteArrayOutputStream(), outDigest); new DigestOutputStream(new ByteArrayOutputStream(), outDigest);
Fop fop = new Fop(Fop.RENDER_PDF, foUserAgent);
Fop fop = new Fop(MimeConstants.MIME_PDF, foUserAgent);
fop.setOutputStream(out); fop.setOutputStream(out);
InputSource source = new InputSource(new StringReader(fo)); InputSource source = new InputSource(new StringReader(fo));
DigestFilter filter = new DigestFilter("MD5"); DigestFilter filter = new DigestFilter("MD5");

+ 3
- 2
test/java/org/apache/fop/URIResolutionTestCase.java View File

import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.image.ImageFactory; import org.apache.fop.image.ImageFactory;
import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.render.xml.XMLRenderer;
import org.apache.xpath.XPathAPI; import org.apache.xpath.XPathAPI;
ua.setURIResolver(resolver); ua.setURIResolver(resolver);
ua.setBaseURL(foFile.getParentFile().toURL().toString()); ua.setBaseURL(foFile.getParentFile().toURL().toString());


Fop fop = new Fop(Fop.RENDER_PDF, ua);
Fop fop = new Fop(MimeConstants.MIME_PDF, ua);


ByteArrayOutputStream baout = new ByteArrayOutputStream(); ByteArrayOutputStream baout = new ByteArrayOutputStream();
fop.setOutputStream(baout); fop.setOutputStream(baout);
atrenderer.setTransformerHandler(athandler); atrenderer.setTransformerHandler(athandler);
ua.setRendererOverride(atrenderer); ua.setRendererOverride(atrenderer);
Fop fop = new Fop(Fop.RENDER_XML, ua);
Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, ua);


Transformer transformer = tfactory.newTransformer(); //Identity transf. Transformer transformer = tfactory.newTransformer(); //Identity transf.
Source src = new StreamSource(fo); Source src = new StreamSource(fo);

+ 2
- 2
test/java/org/apache/fop/fotreetest/FOTreeTester.java View File



import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;


import org.apache.fop.fotreetest.ext.TestElementMapping; import org.apache.fop.fotreetest.ext.TestElementMapping;


ua.setBaseURL(testFile.getParentFile().toURL().toString()); ua.setBaseURL(testFile.getParentFile().toURL().toString());
ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua)); ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));
ua.addElementMapping(new TestElementMapping()); ua.addElementMapping(new TestElementMapping());
Fop fop = new Fop(Constants.RENDER_XML, ua);
Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, ua);
SAXResult fores = new SAXResult(fop.getDefaultHandler()); SAXResult fores = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, fores); transformer.transform(src, fores);

+ 2
- 2
test/java/org/apache/fop/layoutengine/LayoutEngineTester.java View File

import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.layoutmgr.ElementListObserver; import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.render.xml.XMLRenderer; import org.apache.fop.render.xml.XMLRenderer;
import org.w3c.dom.Document; import org.w3c.dom.Document;
atrenderer.setUserAgent(ua); atrenderer.setUserAgent(ua);
atrenderer.setTransformerHandler(athandler); atrenderer.setTransformerHandler(athandler);
ua.setRendererOverride(atrenderer); ua.setRendererOverride(atrenderer);
Fop fop = new Fop(Constants.RENDER_XML, ua);
Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, ua);
SAXResult fores = new SAXResult(fop.getDefaultHandler()); SAXResult fores = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, fores); transformer.transform(src, fores);

+ 2
- 2
test/java/org/apache/fop/threading/FOProcessorImpl.java View File



import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;
import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.activity.Initializable;


public class FOProcessorImpl extends AbstractLogEnabled public class FOProcessorImpl extends AbstractLogEnabled


public void process(InputStream in, Templates templates, OutputStream out) public void process(InputStream in, Templates templates, OutputStream out)
throws org.apache.fop.apps.FOPException, java.io.IOException { throws org.apache.fop.apps.FOPException, java.io.IOException {
Fop fop = new Fop(Constants.RENDER_PDF);
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(out); fop.setOutputStream(out);


try { try {

+ 2
- 2
test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java View File

protected abstract String getTargetExtension(); protected abstract String getTargetExtension();
/** /**
* @return the output format constant for the FOP renderer, i.e. one of Constants.RENDER_*.
* @return the output format for the FOP renderer, i.e. a MIME type.
*/ */
protected abstract int getTargetFormat();
protected abstract String getTargetFormat();
/** @see org.apache.fop.visual.BitmapProducer */ /** @see org.apache.fop.visual.BitmapProducer */
public BufferedImage produce(File src, ProducerContext context) { public BufferedImage produce(File src, ProducerContext context) {

+ 2
- 1
test/java/org/apache/fop/visual/BitmapProducerJava2D.java View File

import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop; import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.fo.Constants; import org.apache.fop.fo.Constants;


/** /**
OutputStream out = new FileOutputStream(outputFile); OutputStream out = new FileOutputStream(outputFile);
out = new BufferedOutputStream(out); out = new BufferedOutputStream(out);
try { try {
Fop fop = new Fop(Constants.RENDER_PNG, userAgent);
Fop fop = new Fop(MimeConstants.MIME_PNG, userAgent);
fop.setOutputStream(out); fop.setOutputStream(out);
SAXResult res = new SAXResult(fop.getDefaultHandler()); SAXResult res = new SAXResult(fop.getDefaultHandler());

+ 3
- 3
test/java/org/apache/fop/visual/BitmapProducerPDF.java View File



package org.apache.fop.visual; package org.apache.fop.visual;


import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;


/** /**
* BitmapProducer implementation that uses the PDFRenderer and an external converter * BitmapProducer implementation that uses the PDFRenderer and an external converter
} }
/** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */ /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */
protected int getTargetFormat() {
return Constants.RENDER_PDF;
protected String getTargetFormat() {
return MimeConstants.MIME_PDF;
} }
} }

+ 3
- 3
test/java/org/apache/fop/visual/BitmapProducerPS.java View File



package org.apache.fop.visual; package org.apache.fop.visual;


import org.apache.fop.fo.Constants;
import org.apache.fop.apps.MimeConstants;


/** /**
* BitmapProducer implementation that uses the PSRenderer and an external converter * BitmapProducer implementation that uses the PSRenderer and an external converter
} }
/** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */ /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */
protected int getTargetFormat() {
return Constants.RENDER_PS;
protected String getTargetFormat() {
return MimeConstants.MIME_POSTSCRIPT;
} }



Loading…
Cancel
Save