Uh, now it gets complicated....
On 23.12.2004 14:32:56 Saptarshi Sen wrote:
> Hi,
> I got the desired output using Batik. I am now trying to integrate it
> into my application.
>
> Since Batik uses the PDFTranscoder class from FOP, what are the
> various jar's that I need to include in my project path. I understand that I
> should remove the fop.jar (from version 0.20.5) from my project path. Which
> are the jar's from batik 1.5.1 that I need to include.
I think you need all JARs from the lib directory of the binary
distribution except batik-svggen.jar and batik-swing.jar. Not sure. I'd
have to do a trial-and-error. pdf-transcoder.jar contains all classes
needed by FOP's PDF Transcoder.
> A few requirements in my application is that I'll be embedding custom
> fonts and using batik just for SVG to PDF conversion.
Now for the tricky part. Font configuration for the new transcoder is
not documented, yet, and it's a bit different than in FOP 0.20.5 and may
even change again until the first release of the redesign code.
Here's a snippet to create an Avalon Configuration Object with the font
configuration:
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.batik.transcoder.Transcoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.XMLAbstractTranscoder;
import org.apache.batik.transcoder.image.ImageTranscoder;
[..]
//Transcoder instantiation
Transcoder transcoder = transcoder = new org.apache.fop.svg.PDFTranscoder();
[..]
//Font configuration
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new
File("src/xml/pdf-transcoder-cfg.xml"));
ContainerUtil.configure(transcoder, cfg);
[..]
//Transcoder properties supported by the PDF Transcoder
int dpi = 300;
transcoder.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER,
new Float((float)(25.4 / dpi)));
transcoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING,
Boolean.FALSE);
transcoder.addTranscodingHint(PDFTranscoder.KEY_STROKE_TEXT, Boolean.FALSE);
[..]
//On with the normal transcoding process as documented in Batik...
The XML file for the font configuration would look approximately like
this:
<cfg>
<fonts>
<font metrics-url="file:C:/Dev/FOP/temp/fonts/FUTURAL.ttf.xml"
kerning="no" embed-url="file:C:/Dev/FOP/Temp/fonts/FUTURAL.ttf">
<font-triplet name="Futura" style="normal" weight="200"/>
<font-triplet name="Futura" style="normal" weight="normal"/>
</font>
<font metrics-url="file:C:\Dev\FOP\temp\fonts\ARIAL.TTF.xml"
kerning="no" embed-url="file:C:/Dev/FOP/Temp/fonts/ARIAL.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>
<font metrics-url="file:C:\Dev\FOP\temp\fonts\ARIALBD.TTF.xml"
kerning="no" embed-url="file:C:/Dev/FOP/Temp/fonts/ARIALBD.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
</font>
</fonts>
</cfg>
There's one potential problem, though: I don't know what version of the
PDF Transcoder is in the Batik 1.5.1 release. That part didn't get
released properly. It could be that the font configuration doesn't work,
but I hope so.
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]