Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-1410

embed SVG file in PDF: picture incorrect (wrong colors)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 0.94
    • None
    • renderer/svg
    • None
    • Operating System: Linux
      Platform: PC
    • 43274

    Description

      We have a XSL/FO script that just embeds a SVG file using <fo:external-
      graphic>. The PDF rendered with FOP-0.20.5rc contains the SVG, correctly like
      displayed with the batik viewer gui.

      The PDF rendered with FOP-0.93 or 0.94 contains the SVG, but the colors aren't
      displayed correctly: The SVG seems to be invisible.

      After patching one file, the problem seems to be solved. Even with more complex
      XSL/FO scripts the results of the patched FOP-0.94 look fine.

      It looks like the 0.94 uses inherited color values in some cases, misleadingly.

      --------- input.xsl ------------
      <?xml version="1.0" encoding="iso-8859-1"?>
      <!DOCTYPE xsl:stylesheet []>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
      <xsl:template match="/">
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:call-template name="layout-master-set"/>
      <fo:page-sequence master-reference="one">
      <fo:flow flow-name="xsl-region-body">
      <xsl:call-template name="gfx"/>
      </fo:flow>
      </fo:page-sequence>
      </fo:root>
      </xsl:template>
      <xsl:template name="layout-master-set">
      <fo:layout-master-set>
      <fo:simple-page-master master-name="one">
      <fo:region-body margin-bottom="20pt" margin-left="12mm" margin-
      right="25pt" />
      </fo:simple-page-master>
      </fo:layout-master-set>
      </xsl:template>
      <xsl:template name="gfx">
      <fo:block>
      <fo:external-graphic content-width="222pt">
      <xsl:attribute name="src">/data/home/ckohrn/Desktop/manipulated.svg</
      xsl:attribute>
      </fo:external-graphic>
      </fo:block>
      </xsl:template>
      </xsl:stylesheet>

      --------- manipulated.svg ------------
      <?xml version="1.0" encoding="utf-8"?>
      <!-- Generator: Adobe Illustrator 10, SVG Export Plug-In . SVG Version: 3.0.0
      Build 76) -->
      <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/
      REC-SVG-20010904/DTD/svg10.dtd" [
      <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
      <!ENTITY ns_svg "http://www.w3.org/2000/svg">
      <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
      ]>
      <svg xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" xmlns:a="http://ns.adobe.com/
      AdobeSVGViewerExtensions/3.0/"
      width="117.524902" height="69.405273" viewBox="0 0 117.524902
      69.405273"
      overflow="visible" enable-background="new 0 0 117.524902 69.405273"
      xml:space="preserve">
      <g id="Dimension_Layer">
      <path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF"
      d="M57.727539,16.092773v-0.513672l-3.995117-0.001465
      L53.711914,4.447754l-
      7.166992,0.004395L46.52832,1.648438H19.372559v2.757324l-5.233887-
      0.031738V0.233398l-2.798828,0.005859
      l0.017578,15.389648l-4.234375-
      0.030762v0.463379h0.5625v24.6875l-0.5625,0.00293v0.530273l3.943359-
      0.001953v9.045898h2.029785

      342285h38.138672l-0.032227-

      9.061523l4.09375,0.015625v-0.46875h-0.3125V16.108398L57.727539,16.092773z
      M24.435547,40.749023
      h-1l-0.03125-24.65625l1.03125-0.015625V40.749023z
      M41.269043,40.787109l-1.010254-0.017578l0.004883-24.661133
      l1.015625-0.015625L41.269043,40.787109z"/>
      <path fill="none" stroke="#000000" stroke-width="0.15"
      stroke-linejoin="round" stroke-miterlimit="1" d="M103.759766,49.632812
      "/>
      <g>
      <path fill="none" stroke="#000000" stroke-width="0.15"
      stroke-linejoin="round" stroke-miterlimit="1" d="M106.358398,50.322266
      "/>
      </g>
      <path d="M5.669434,2.990723c0,1.56543-1.269043,2.833984-
      2.834961,2.833984C1.269043,5.824707,0,4.556152,0,2.990723
      c0-1.566406,1.269043-2.834961,2.834473-
      2.834961C4.400391,0.155762,5.669434,1.424316,5.669434,2.990723z"/>
      <g>
      <path fill="#FFFFFF" d="M1.834473,4.408691v-
      0.60791h0.852051V2.344727L1.90625,2.784668L1.598633,2.224609l1.099609-0.639648
      H3.45459v2.21582h0.699707v0.60791H1.834473z"/>
      </g>
      </g>
      </svg>

      ----------- fop-0.94-org.apache.fop.svg.PDFGraphics2D.patch --------------
      Index: PDFGraphics2D.java
      ===================================================================
      — PDFGraphics2D.java (Revision 570024)
      +++ PDFGraphics2D.java (Arbeitskopie)
      @@ -719,13 +719,15 @@
      }

      c = getColor();

      • if (graphicsState.setColor(c))
        Unknown macro: {+ graphicsState.setColor(c);+ // if (graphicsState.setColor(c)) { applyColor(c, false); - }
        + // }
        c = getBackground();
        - if (graphicsState.setBackColor(c)) {
        + graphicsState.setBackColor(c);
        + // if (graphicsState.setBackColor(c)) { applyColor(c, true); - }
        + // }

        Paint paint = getPaint();
        if (graphicsState.setPaint(paint)) { @@ -1718,13 +1720,15 @@ }

        c = getColor();
        - if (graphicsState.setColor(c)) {
        + graphicsState.setColor(c);
        + // if (graphicsState.setColor(c)) { applyColor(c, true);- }
        + // }
        c = getBackground();
        - if (graphicsState.setBackColor(c)) {
        + graphicsState.setBackColor(c);
        + // if (graphicsState.setBackColor(c)) { applyColor(c, false);- }+ // }

      Paint paint = getPaint();
      if (graphicsState.setPaint(paint)) {

      Attachments

        1. graph2D.diff
          1 kB
          Adrian Cumiskey

        Activity

          People

            fop-dev@xmlgraphics.apache.org fop-dev
            ckohrn@tng.de Christian Kohrn
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: