import java.awt.geom.AffineTransform;
import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.DocumentLoader;
import org.apache.batik.bridge.UserAgent;
import org.apache.fop.fonts.FontInfo;
/**
* Constructs a new bridge context.
* @param userAgent the user agent
- * @param fontInfo the font list for the text painter, may be null in which case text is
- * painted as shapes
- * @param linkTransform AffineTransform to properly place links, may be null
+ * @param loader the Document Loader to use for referenced documents.
+ * @param fontInfo the font list for the text painter, may be null
+ * in which case text is painted as shapes
+ * @param linkTransform AffineTransform to properly place links,
+ * may be null
+ */
+ public PDFBridgeContext(UserAgent userAgent,
+ DocumentLoader loader,
+ FontInfo fontInfo,
+ AffineTransform linkTransform) {
+ super(userAgent, loader);
+ this.fontInfo = fontInfo;
+ this.linkTransform = linkTransform;
+ }
+
+ /**
+ * Constructs a new bridge context.
+ * @param userAgent the user agent
+ * @param fontInfo the font list for the text painter, may be null
+ * in which case text is painted as shapes
+ * @param linkTransform AffineTransform to properly place links,
+ * may be null
*/
public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo,
AffineTransform linkTransform) {
/**
* Constructs a new bridge context.
* @param userAgent the user agent
- * @param fontInfo the font list for the text painter, may be null in which case text is
- * painted as shapes
+ * @param fontInfo the font list for the text painter, may be null
+ * in which case text is painted as shapes
*/
public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo) {
this(userAgent, fontInfo, null);
putBridge(new PDFImageElementBridge());
}
-
-}
\ No newline at end of file
+
+ // Make sure any 'sub bridge contexts' also have our bridges.
+ public BridgeContext createBridgeContext() {
+ return new PDFBridgeContext(getUserAgent(), getDocumentLoader(),
+ fontInfo, linkTransform);
+ }
+}
public void addJpegImage(JpegImage jpeg, float x, float y,
float width, float height) {
preparePainting();
- String key = "__AddJPEG_" + jpegCount[0];
+ // Need to include hash code as when invoked from FO you
+ // may have several 'independent' PDFGraphics2D so the
+ // count is not enough.
+ String key = "__AddJPEG_" + hashCode() + "_" + jpegCount[0];
jpegCount[0]++;
FopPDFImage fopimage = new FopPDFImage(jpeg, key);
int xObjectNum = this.pdfDoc.addImage(resourceContext,