xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremias Maerki <dev.jerem...@greenmail.ch>
Subject Re: PDF font embedding
Date Mon, 10 Jan 2005 22:01:36 GMT
I hope you don't mind my CCing batik-users so other users can profit,
too.

I've put together an example that works for me and added it to the FOP
Wiki:

http://wiki.apache.org/xmlgraphics-fop/SvgNotes/PdfTranscoderTrueTypeEmbedding

I used the current CVS HEAD code and the batik.jar that is currently in
the lib directory when you download FOP from CVS. Ît will most probably
work with the latest Batik from CVS, too.

I hope this helps.

On 07.01.2005 23:46:34 zxn 6228 wrote:
> Hi, Jeremias,
> 
> I saw your your reply to batik-user on Wed, 22 Sep 2004, see below.
> 
> I downloaded the  batik 1-4-05 from CVS, generated the font metric xml file 
> using TTFReader, and created the user config file.
> 
> But the font still can't be embedded into the PDF, the font is installed in 
> winnt/fonts dir.
> 
> Would you please tell me why and which version of batik you tested?
> 
> Thanks,
> 
> Zhongli Ni
> 
> -------------------------------------------------------------------------------------------------
> 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.



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message