Convert SVG with webfonts to PDF with embedded fonts

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
gabw
Posts: 28
Joined: 2014-07-20T09:20:15-07:00
Authentication code: 6789

Convert SVG with webfonts to PDF with embedded fonts

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert SVG with webfonts to PDF with embedded fonts

Post 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.
snibgo's IM pages: im.snibgo.com
gabw
Posts: 28
Joined: 2014-07-20T09:20:15-07:00
Authentication code: 6789

Re: Convert SVG with webfonts to PDF with embedded fonts

Post by gabw »

Ok thank you very much for that response.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert SVG with webfonts to PDF with embedded fonts

Post 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.
snibgo's IM pages: im.snibgo.com
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Convert SVG with webfonts to PDF with embedded fonts

Post 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.
gabw
Posts: 28
Joined: 2014-07-20T09:20:15-07:00
Authentication code: 6789

Re: Convert SVG with webfonts to PDF with embedded fonts

Post 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!
Post Reply