git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1658710 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_0
@@ -30,6 +30,7 @@ import java.io.OutputStream; | |||
import java.net.URI; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -142,7 +143,7 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { | |||
return new PSRendererConfigurator(getUserAgent(), new PSRendererConfigParser()); | |||
} | |||
PSRenderingUtil getPSUtil() { | |||
public PSRenderingUtil getPSUtil() { | |||
return this.psUtil; | |||
} | |||
@@ -160,12 +161,7 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { | |||
} | |||
//Setup for PostScript generation | |||
this.gen = new PSGenerator(out) { | |||
/** Need to subclass PSGenerator to have better URI resolution */ | |||
public Source resolveURI(String uri) { | |||
return getUserAgent().resolveURI(uri); | |||
} | |||
}; | |||
this.gen = new FOPPSGeneratorImpl(out); | |||
this.gen.setPSLevel(psUtil.getLanguageLevel()); | |||
this.currentPageNumber = 0; | |||
this.documentBoundingBox = new Rectangle2D.Double(); | |||
@@ -179,6 +175,37 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { | |||
} | |||
} | |||
public interface FOPPSGenerator { | |||
PSDocumentHandler getHandler(); | |||
BufferedOutputStream getTempStream(URI uri) throws IOException; | |||
Map<Integer, URI> getImages(); | |||
} | |||
public class FOPPSGeneratorImpl extends PSGenerator implements FOPPSGenerator { | |||
private Map<Integer, URI> images = new HashMap<Integer, URI>(); | |||
public FOPPSGeneratorImpl(OutputStream out) { | |||
super(out); | |||
} | |||
/** Need to subclass PSGenerator to have better URI resolution */ | |||
@Override | |||
public Source resolveURI(String uri) { | |||
return getUserAgent().resolveURI(uri); | |||
} | |||
public PSDocumentHandler getHandler() { | |||
return PSDocumentHandler.this; | |||
} | |||
public BufferedOutputStream getTempStream(URI uri) throws IOException { | |||
return new BufferedOutputStream(getUserAgent().getResourceResolver().getOutputStream(uri)); | |||
} | |||
public Map<Integer, URI> getImages() { | |||
return images; | |||
} | |||
} | |||
private void writeHeader() throws IOException { | |||
//PostScript Header | |||
gen.writeln(DSCConstants.PS_ADOBE_30); | |||
@@ -558,7 +585,7 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { | |||
* @param uri the image URI | |||
* @return a PSResource instance | |||
*/ | |||
protected PSResource getFormForImage(String uri) { | |||
public PSResource getFormForImage(String uri) { | |||
if (uri == null || "".equals(uri)) { | |||
throw new IllegalArgumentException("uri must not be empty or null"); | |||
} |
@@ -26,6 +26,7 @@ import java.awt.image.BufferedImage; | |||
import java.io.IOException; | |||
import java.util.Map; | |||
import org.apache.xmlgraphics.java2d.GeneralGraphics2DImagePainter; | |||
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; | |||
import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; | |||
import org.apache.xmlgraphics.ps.PSGenerator; | |||
@@ -94,7 +95,9 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { | |||
gen.concatMatrix(sx, 0, 0, sy, fx, fy); | |||
final boolean textAsShapes = false; | |||
PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen); | |||
PSGraphics2D graphics = (painter instanceof GeneralGraphics2DImagePainter) | |||
? (PSGraphics2D) ((GeneralGraphics2DImagePainter) painter).getGraphics(textAsShapes, gen) | |||
: new PSGraphics2D(textAsShapes, gen); | |||
graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); | |||
AffineTransform transform = new AffineTransform(); | |||
// scale to viewbox |
@@ -30,6 +30,7 @@ import org.apache.xmlgraphics.image.loader.Image; | |||
import org.apache.xmlgraphics.image.loader.ImageFlavor; | |||
import org.apache.xmlgraphics.image.loader.ImageInfo; | |||
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; | |||
import org.apache.xmlgraphics.java2d.GeneralGraphics2DImagePainter; | |||
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; | |||
import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; | |||
import org.apache.xmlgraphics.ps.FormGenerator; | |||
@@ -84,7 +85,9 @@ public class PSImageHandlerGraphics2D implements PSImageHandler { | |||
gen.concatMatrix(sx, 0, 0, sy, fx, fy); | |||
final boolean textAsShapes = false; | |||
PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen); | |||
PSGraphics2D graphics = (painter instanceof GeneralGraphics2DImagePainter) | |||
? (PSGraphics2D) ((GeneralGraphics2DImagePainter) painter).getGraphics(textAsShapes, gen) | |||
: new PSGraphics2D(textAsShapes, gen); | |||
graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); | |||
AffineTransform transform = new AffineTransform(); | |||
// scale to viewbox |
@@ -48,6 +48,9 @@ public class PSImageUtils extends org.apache.xmlgraphics.ps.PSImageUtils { | |||
* @return true if the image shall be inlined, false if forms shall be used. | |||
*/ | |||
public static boolean isImageInlined(ImageInfo info, PSRenderingContext renderingContext) { | |||
if (info.getMimeType().equals("application/pdf")) { | |||
return true; | |||
} | |||
String uri = info.getOriginalURI(); | |||
if (uri == null || "".equals(uri)) { | |||
return true; |