Page 1 of 1

Convert SVG with webfonts to PDF with embedded fonts

Posted: 2014-12-12T01:31:27-07:00
by gabw
Hello,

is it possible to have this input:

a SVG File with this line:

Code: Select all

<?xml-stylesheet href="http://dev.local/media/font/Bebas+Neue.css" type="text/css"?>
Contents of the CSS File:

Code: Select all

@font-face {
    font-family: 'Bebas Neue';
    src: url('bebasneue-webfont.woff');
    src: url('bebasneue-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}
So now I can use my custom font in my SVG files.

Now is it possible to convert this SVG to a PDF File that has my custom webfont embedded?

Currently on this command the output is not including my fonts.

Code: Select all

convert input.svg -density 300 -units PixelsPerInch output.pdf

Re: Convert SVG with webfonts to PDF with embedded fonts

Posted: 2014-12-12T06:22:43-07:00
by snibgo
No. ImageMagick is a raster image processor. It plays with pixels. So it would convert your SVG into a raster image, and put that inside a PDF wrapper. The PDF would not have fonts, and would not need them, because it would contain no text.

Perhaps Ghostscript can do what you want.

Re: Convert SVG with webfonts to PDF with embedded fonts

Posted: 2014-12-12T06:38:33-07:00
by gabw
Ok thank you very much for that response.

Re: Convert SVG with webfonts to PDF with embedded fonts

Posted: 2014-12-12T07:17:34-07:00
by snibgo
A quick experiment shows that I can write text in Inkscape, save as a PDF, and Adobe Reader shows the PDF text is in vector, not raster, format. So Inkscape might do what you want.

Re: Convert SVG with webfonts to PDF with embedded fonts

Posted: 2014-12-13T17:26:34-07:00
by pipitas
Inkscape indeed does have a command line interface that can be used to convert SVG to PDF:

Code: Select all

   inkscape                 \
    --without-gui           \
    --export-pdf=output.pdf \
      input.svg
This can also be used to configure your own custom ImageMagick delegate. Here is a line that should work:

Code: Select all

    <delegate decode="svg:decode" stealth="False"                       \
            command=""/opt/local/bin/inkscape" "%s" \
            --without-gui                                               \
            --export-pdf="%s"                                 \
            --export-dpi="%s"                                 \
            --export-background="%s"                          \
            --export-background-opacity="%s"                  \
              > "%s" 2>&1"/>
Put this as a single line (remove the backslashes!) into $HOME/.magick/delegates.xml.

Warning: I've not yet tested this, but deviated it from the output of the

Code: Select all

 inkscape --help
command. There are more options in there which may be useful to add to the delegate command. There may be errors in my delegate command definitions which need to be fixed before it works.

Re: Convert SVG with webfonts to PDF with embedded fonts

Posted: 2014-12-15T01:40:52-07:00
by gabw
Yeah, I've already known that Inkscape would be the best to solve my problem, but my managed server-provider will not install inkscape on my main server. So - there is no way around with ImageMagick - i will just rent a new VPS for that ;)

Thanks for your help!