[ 
https://issues.apache.org/jira/browse/FOP-2489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hussein Shafie updated FOP-2489:
--------------------------------
    Attachment: header_layout.svg

> An SVG file using markers is not rendered by FOP 2.0
> ----------------------------------------------------
>
>                 Key: FOP-2489
>                 URL: https://issues.apache.org/jira/browse/FOP-2489
>             Project: FOP
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Linux; Java 1.6 64-bit (not relevant).
>            Reporter: Hussein Shafie
>         Attachments: __doc.fo, __doc.pdf, header_layout.svg
>
>
> An SVG file using markers is not rendered by FOP 2.0
> ----------------------------------------------------
> How to reproduce the problem (see attached files)
> fop -fo __doc.fo -pdf __doc.pdf
> Running this command reports:
> ---
> SEVERE: SVG graphic could not be built. Reason: 
> org.apache.batik.bridge.BridgeException: 
> resources/resources/header_layout.svg (No such file or directory)
> org.apache.batik.bridge.BridgeException: 
> resources/resources/header_layout.svg (No such file or directory)
>         at org.apache.batik.bridge.BridgeContext.getReferencedNode(Unknown 
> Source)
>         at org.apache.batik.bridge.BridgeContext.getReferencedElement(Unknown 
> Source)
>         at org.apache.batik.bridge.PaintServer.convertMarker(Unknown Source)
>         at org.apache.batik.bridge.PaintServer.convertMarkers(Unknown Source)
>         at 
> org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createMarkerPainter(Unknown
>  Source)
>         at 
> org.apache.batik.bridge.SVGDecoratedShapeElementBridge.createShapePainter(Unknown
>  Source)
>         at 
> org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(Unknown 
> Source)
>         at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown 
> Source)
>         at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
>         at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown 
> Source)
>         at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
>         at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown 
> Source)
>         at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
>         at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)
>         at 
> org.apache.fop.render.pdf.PDFImageHandlerSVG.handleImage(PDFImageHandlerSVG.java:103)
>         at 
> org.apache.fop.render.intermediate.AbstractIFPainter.drawImage(AbstractIFPainter.java:249)
>         at 
> org.apache.fop.render.intermediate.AbstractIFPainter.drawImage(AbstractIFPainter.java:205)
>         at 
> org.apache.fop.render.intermediate.AbstractIFPainter.drawImageUsingImageHandler(AbstractIFPainter.java:170)
>         at 
> org.apache.fop.render.intermediate.AbstractIFPainter.drawImageUsingURI(AbstractIFPainter.java:292)
>         at org.apache.fop.render.pdf.PDFPainter.drawImage(PDFPainter.java:173)
>         at 
> org.apache.fop.render.intermediate.IFRenderer.drawImage(IFRenderer.java:1295)
>         at 
> org.apache.fop.render.intermediate.IFRenderer.renderImage(IFRenderer.java:1282)
>         at 
> org.apache.fop.render.AbstractRenderer.renderInlineViewport(AbstractRenderer.java:858)
> ---
> The expected result is EXPECTED__doc.pdf
> My workaround:
> To resolve URLs such as "marker-start:url(#TriangleInM)", Batik 1.8 needs 
> to know the URL of the SVG document it processes.
> Therefore in org/apache/fop/apps/FOUserAgent.java, I've replaced:
> ---
>     public StreamSource resolveURI(String uri) {
>         // TODO: What do we want to do when resources aren't found??? We also 
> need to remove this
>         // method entirely
>         try {
>             // Have to do this so we can resolve data URIs
>             StreamSource src = new 
> StreamSource(resourceResolver.getResource(uri));
>             src.setSystemId(uri);
>             return src;
>         } catch (URISyntaxException use) {
>             return null;
>         } catch (IOException ioe) {
>             return null;
>         }
>     }
> ---
> by:
> ---
>     public StreamSource resolveURI(String uri) {
>         // TODO: What do we want to do when resources aren't found??? We also 
> need to remove this
>         // method entirely
>         try {
>             // Have to do this so we can resolve data URIs
>             StreamSource src = new 
> StreamSource(resourceResolver.getResource(uri));
>             // A systemId is always expected to be absolute.
>             // Anyway, without this, SVG files using markers 
>             // (e.g. marker-start:url(#TriangleInM)) cannot be rendered.
>             if (!uri.startsWith("data:")) {
>                 uri = 
> resourceResolver.getBaseURI().resolve(uri).toASCIIString();
>             }
>             src.setSystemId(uri);
>             return src;
>         } catch (URISyntaxException use) {
>             return null;
>         } catch (IOException ioe) {
>             return null;
>         }
>     }
> ---



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to