You can do that, but it's not exactly like the userconfig.xml thing of
FOP 0.20.5. The PDF Transcoder can be configured using Apache Avalon
style configuration. As the whole PDF Transcoder is still somewhat
work-in-progress this hasn't been documented, yet (and the whole thing
may yet change). Here's some code snippet out of my test harness that
should help you configure the Transcoder (Java knowledge required):

//Avalon
import org.apache.avalon.framework.ExceptionUtil;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.ConsoleLogger;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.svg.AbstractFOPTranscoder;
import org.apache.fop.svg.PDFTranscoder;
import org.apache.xml.resolver.tools.CatalogResolver;

        [..]

        Transcoder transcoder;
        transcoder = new org.apache.fop.svg.PDFTranscoder();

        //This part is for newer code with Jakarta Commons Logging
        if (transcoder instanceof AbstractFOPTranscoder) {
            Log logger = new SimpleLog("FOP/Transcoder");
            ((SimpleLog) logger).setLevel(SimpleLog.LOG_LEVEL_TRACE);
            ((AbstractFOPTranscoder)transcoder).setLogger(logger);
        }

        //This part uses older Avalon-style logging
        ContainerUtil.enableLogging(transcoder, new 
ConsoleLogger(ConsoleLogger.LEVEL_DEBUG));

        try {
            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
            Configuration cfg = cfgBuilder.buildFromFile(new 
File("src/xml/pdf-renderer-cfg.xml"));
            ContainerUtil.configure(transcoder, cfg);
        } catch (Exception e) {
            throw new TranscoderException(e);
        }
        
        transcoder.addTranscodingHint(.......

        if (transcoder instanceof AbstractFOPTranscoder) {
            ((AbstractFOPTranscoder)transcoder).setEntityResolver(resolver);
        }

        [..] //Set up input and output

        transcoder.transcode(input, output);
        
If either of the two logging parts doesn't compile just comment them.

The XML file to use would look approximately like this:
<cfg>
  <filterList>
    <value>null</value>
  </filterList>
  <filterList type="image">
    <value>flate</value>
    <value>ascii-85</value>
  </filterList>
  <!--filterList type="jpeg">
    <value>ascii-85</value>
  </filterList-->
  <fonts>
    <font metrics-url="file:C:/Dev/FOP/fonts/BauerBodoni-Roman.xml"
         kerning="no"
         embed-url="file:C:/Dev/FOP/fonts/BauerBodoni-Roman.pfb">
      <font-triplet name="BauerBodoni" style="normal" weight="normal"/>
    </font>
  </fonts>
</cfg>

You can leave the filterList stuff aside.

I can't tell what version of PDF transcoder you are using, so it may be
that the above XML structure may not work. We haven't had a proper
release of the PDF transcoder, yet, so this is all trial and error. At
any rate, the above works with the latest CVS code on my machine. If it
doesn't work, try removing the enclosing "fonts" element, but keeping
the "font" elements. You will recognize a similarity with the old FOP
0.20.5 config format, but behind all this the configuration system has
changed quite a bit.

You will also have to make sure that the font you are trying to embed is
installed on your operating system, because Batik makes use of AWT fonts
which in turn are taken from the operating system. When the PDF
transcoder has to render a particularly complex text element the text
will not be rendered using PDF text operators but using shapes in which
case the fonts come from the AWT subsystem not from FOP's own font
subsystem.

I hope the above is understandable. Good luck.

On 22.09.2004 08:58:28 Markus Neff wrote:
> 
> Hi dear Batik users,
> 
> I have the following problem that I could not find a solution for so
> far:
> 
> If I try to convert (using batik-1.5.1\batik-rasterizer.jar) the svg
> file below to png, the right font is used. If try to convert it to
> pdf, the font is not embedded and a substitution is used.
> 
> Now my question: how can I tell the transcoder to embed the font into
> the PDF file? Can one place a "userconfig.xml" file somewhere like
> described on the FOP pages or do I have to embed the font into the svg
> file?
> 
> 
> Thanks a lot for any hint in advance,
> Markus
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 
> 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
> <svg>
>   <g font-family="&apos;Comic Sans MS&apos;" font-size="11">
>       <text x="0" y="13" xml:space="preserve">Test</text>
>   </g>
> </svg>


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to