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

SVG to EPS

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Blocker
    • Resolution: Unresolved
    • None
    • None
    • foreign/svg
    • None
    • linux

    Description

      I tried to convert SVG to EPS. Although it was successful, the content of EPS file converted was incorrect,  I was very surprised why the color of EPS file generated was lost。

      version:

      <dependency>
          <groupId>org.apache.xmlgraphics</groupId>
          <artifactId>fop</artifactId>
          <version>2.4</version>
      </dependency>
      
      
      
      <dependency>
          <groupId>org.apache.xmlgraphics</groupId>
          <artifactId>batik-all</artifactId>
          <version>1.12</version>
          <type>pom</type>
      </dependency>
      
      public void svgtoeps(String svgCode, OutputStream os){
          EPSTranscoder epsTranscoder = new EPSTranscoder();
          try {
              svgCode = svgCode.replaceAll(":rect", "rect");
              TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgCode.getBytes()));
              TranscoderOutput output = new TranscoderOutput(os);
              epsTranscoder.transcode(input, output);
              os.flush();
              os.close();
          } catch (Exception e) {
          }
      }
      

      svg:

      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1034.7 791.52"><defs><radialGradient id="a88099553-ad5b-4e3d-9162-06592b3c5c3a" cx="521.08" cy="461.4" r="330.12" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#e35f67"/><stop offset="1" stop-color="#a6222b"/></radialGradient></defs><g><g><path d="M57.24 464.41l155.71 127c31.62 25.78 57.24 3.65 57.24-49.43V280.52c0-53.08-25.63-117-57.24-142.79L57.24 10.76C25.63-15 0 7.11 0 60.19v261.43c0 53.08 25.63 117.01 57.24 142.79zM977.45 464.41l-155.71 127c-31.62 25.78-57.24 3.65-57.24-49.43V280.52c0-53.08 25.63-117 57.24-142.79l155.71-127c31.62-25.78 57.24-3.65 57.24 49.43v261.46c.01 53.08-25.62 117.01-57.24 142.79z" fill="#cfd4d5"/><rect x="190.96" y="131.28" width="660.23" height="660.23" rx="207.26" ry="207.26" fill="url(#a88099553-ad5b-4e3d-9162-06592b3c5c3a)"/><path d="M619.78 319.62a114.15 114.15 0 0 0-98.7 56.72 114.21 114.21 0 0 0-212.9 57.48c0 119.3 212.9 210.66 212.9 210.66S734 540.06 734 433.82a114.2 114.2 0 0 0-114.22-114.2z" fill="#fff"/></g></g></svg>
      

       svg:  

       

      eps:


       
      Please help me,thank you

      Attachments

        1. c.svg
          1 kB
          zhw
        2. image-2020-04-20-18-46-35-831.png
          245 kB
          zhw
        3. image-2020-04-20-18-47-10-582.png
          34 kB
          zhw
        4. svgToEpsFile.eps
          11 kB
          zhw

        Activity

          People

            Unassigned Unassigned
            zhw zhw
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: