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?
If you want to copy a font from Windows to Linux, you only need to copy the
.ttf
file to the right place (note: Some fonts are copyrighted and you need permission to install them). There is no need to put them into some kind of registry.To make them available in Java, you have two options:
You can set the environment variable
JAVA_FONTS
before running batikOpen
font.properties
file in thejre/lib
directory, uncommnent and set to the appropriate font directory:Try to add definitions (with url) for those fonts you want to use:
I had the same problem. One thing that i forgot in svg was type="text/css".
Solved by following the recipe here:
http://batik.2283329.n4.nabble.com/Placing-SVG-Text-into-PDF-td3778127.html
major steps:
install imagemagick. Then call convert:
which will convert into a PDF.