Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-1002

org.apache.batik.apps.rasterizer.SVGConverter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Resolution: Unresolved
    • 1.6
    • None
    • SVG DOM
    • None
    • Operating System: Linux
      Platform: PC

    Description

      Hi,

      I've a weird problem, I'm using org.apache.fop.svg.PDFTranscoder to generate a

      PDf from an SVG document in xml format, the problem that I'm facing is despite of defining 'pdf-renderer-cfg.xml' in the specified format and configuring the PDFTranscoder with it, PDFTranscoder is not embedding the font into the PDF. In the 'embed-url' I've given actual path to the true type font.

      The contents of 'pdf-renderer-cfg.xml' are :

      <?xml version="1.0" encoding="UTF-8"?>
      <pdf-renderer>
      <fonts>
      <font metrics-url="/home/prince/appDir/webapp/lib/Fonts/cursive-standard.xml" kerning="no" embed-url="/home/prince/appDir/webapp/lib/Fonts/Cursive-standard.ttf">
      <font-triplet name="Cursive" style="normal" weight="normal"/>
      </font>
      </fonts>
      </pdf-renderer>

      and to configure the PDF transcoder I've extended org.apache.batik.apps.rasterizer.SVGConverter

      and overridden 'execute' method as :

         public void execute() throws SVGConverterException {
              // Compute the set of SVGConverterSource from the source properties
              // (srcDir and srcFile);
              // This throws an exception if there is not at least one src file.
              Vector sources =  computeSources();
      
              // Compute the destination files from dest
              Vector dstFiles = null;
              if(sources.size() == 1 && dst != null && isFile(dst)){
                  dstFiles = new Vector();
                  dstFiles.addElement(dst);
              }
              else{
                  dstFiles =  computeDstFiles(sources);
              }
             
              //Getting the path of the FOP config file
              String fopPath = UtilProperties.getPropertyValue("fop.properties", "fop.path", "webapp/lib/Fonts");
              File userConfigFile = new File(fopPath + "/pdf-renderer-cfg.xml");       
             
              //Build the configuration
              cfgBuilder = new DefaultConfigurationBuilder();       
              try {
                  cfg = cfgBuilder.buildFromFile(userConfigFile);
              } catch (ConfigurationException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (SAXException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
             
              //Get the PDF Transcoder object
              pdfTranscoder = new PDFTranscoder();
             
              //Configure the transcoder
              try {
                  pdfTranscoder.configure(cfg);
              } catch (ConfigurationException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
             
              // Now, get the transcoder to use for the operation       
              Transcoder transcoder = (Transcoder) pdfTranscoder;
              if(transcoder == null) {
                  throw new SVGConverterException(ERROR_CANNOT_ACCESS_TRANSCODER,
                                                   new Object[]{destinationType.toString()},
                                                   true /* fatal error */);
              }
      
              // Now, compute the set of transcoding hints to use
              Map hints = computeTranscodingHints();
              transcoder.setTranscodingHints(hints);
      
              // Notify listener that task has been computed
              if(!controller.proceedWithComputedTask(transcoder,
                                                     hints,
                                                     sources,
                                                     dstFiles)){
                  return;
              }
      
              // Convert files one by one
              for(int i = 0 ; i < sources.size() ; i++) {
                  // Get the file from the vector.
                  SVGConverterSource currentFile
                      = (SVGConverterSource)sources.elementAt(i);
                  File outputFile  = (File)dstFiles.elementAt(i);
      
                  createOutputDir(outputFile);
                  transcode(currentFile, outputFile, transcoder);
              }
          }
         
      }
      

      and the content of the svg file is :

      <svg width="432" height="288" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
      <g>
      <title>Layer 1</title>
      <image transform="rotate(14.4551, 388.899, 199.566)" xlink:href="http://localhost:8080/app/control/app/flex/svgdol/1321955504845/20111123141633795.jpg" id="svg_2" height="362.33104" width="308.62977" y="18.40178" x="234.58535"/>
      <image transform="rotate(-13.6166, 149.053, 95.3409)" xlink:href="http://localhost:8080/app/control/app/flex/svgdol/1321955504845/20111123141524886.jpg" id="svg_1" height="246.3374" width="314.99999" y="-27.82715" x="-8.44604"/>
      <text transform="matrix(1, 0, 0, 1.20588, 0, -25.8382)" xml:space="preserve" text-anchor="middle" font-family="Cursive" font-size="24" id="svg_3" y="155.817" x="265" stroke-width="0" stroke="#000000" fill="#000000">All Mine....!!!!</text>
      </g>
      </svg>

      but even after this the PDFTransocder 's output , i.e. the PDF doesn't contain the text in proper font, I tried to install the font on my O.S. as well,

      but that too didn't work.

      I'm using batik-all-1.6.jar ,Java version is 1.6 and O.S. is Linux(Ubuntu).

      Any guidance /pointers will of extreme help as I've been debugging the library at runtime since last couple of days and haven't been able to find the cause.

      Regards
      Prince

      Attachments

        Activity

          People

            batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
            princesewani@ymail.com Prince Sewani
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: