Search code examples
javalinuxpdfsvgbatik

batik: svg to pdf on linux (no X server)


Similar to approach in Convert SVG to PDF the svg2pdf conversion runs successfully under windows and text items are searchable in the resulting pdf. It produces pdfs (with -Djava.awt.headless=true to avoid exceptions due missing X11 window server) under linux (Ubuntu) as well, but the text items are not searchable and sometimes are even coded as images.

Is it possible to preserve text in pdf under linux as well, am I missing some runtime options?

UPD: Can I somehow force batik (SVGGraphics2D or SVGConverter) to fall back to a default font, if certain font wasn't found?


Solution

  • Solved by following the recipe here:

    http://batik.2283329.n4.nabble.com/Placing-SVG-Text-into-PDF-td3778127.html

    major steps:

    1. compile fop with ant all
    2. copy fop-transcoder-allinone.jar under name pdf-transcoder.jar into the classpath
    3. copy xmlgraphics-commons-1.4.jar from fop's lib directory into the classpath