[OS X TeX] Re: svg to pdf

Ross Moore ross at ics.mq.edu.au
Sun Jul 9 19:17:21 EDT 2006


Hi Alain,

On 08/07/2006, at 5:38 AM, Alain Schremmer wrote:

> Hi,
>
>
> A while back, Ross Moore suggested on the "TeX on Mac OS X"  
> Mailing, instead of keeping both a svg and a pdf version of each  
> graphic along with the LaTeX file, to include, say
> \begin{filecontents*}{mypicture.svg}
> <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C// 
> DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/ 
> svg11.dtd"><!--Generated by Intaglio, www.PurgatoryDesign.com-- 
> ><svg viewBox="0,0,576,734" xmlns="http://www.w3.org/2000/svg"  
> version="1.1"><path fill="#fff" stroke="#000" d="M201,196 L422,196  
> L422,290 L201,290 Z"></path></svg>
> \end{filecontents*}
> in the preamble and then have
>  \begin{figure}
>  \centering
>   \immediate\write18{svg2pdf mypicture.svg  mypicture.pdf}%
>   \includegraphics{mypicture.pdf}
>  \end{figure}
> in the document body.
>
> When I did, I got of course the error message:
> LaTeX Warning: Writing file `./mypicture.svg'.
>
> (./TestForSVG.aux)
> (/usr/local/teTeX/share/texmf.tetex/tex/context/base/supp-pdf.tex
> (/usr/local/teTeX/share/texmf.tetex/tex/context/base/supp-mis.tex
> loading : Context Support Macros / Missing
> )
> loading : Context Support Macros / PDF
> )sh: line 1: svg2pdf: command not found
>
> LaTeX Warning: File `mypicture.pdf' not found on input line 358.
>
> Error: /usr/local/teTeX/bin/powerpc-apple-darwin-current/pdflatex  
> (file mypictu
> re.pdf): cannot find image file
>  ==> Fatal error occurred, the output PDF file is not finished!
> which, since mypicture.svg was in fact created, seemed to say that,  
> indeed, the only thing missing was svg2pdf which, unfortunately,  
> being a Terminal-moron, I knew I couldn't install.
>
> However, last night, a professional system engineer friend of mine  
> tried but failed to compile svg2pdf. He said XCode claimed some  
> library was missing and when he downloaded it, that it was not in  
> the right language.
>
> I would much appreciate any help you could give me as the solution  
> suggested by Moore would seem to be rather an elegant one.

I've spent several hours last Saturday trawling the web for
SVG-->PDF converters. There are several that claim to do it,
but most simply put a wrapper around a bitmap, at some fixed
resolution.

What we really want is a conversion that retains the
"vector graphics" character of the resulting PDF file.
For this, the natural expectation is that such a converter
would come from Adobe, or use Ghostscript, since it must
generate (a flavour of) raw PostScript coding, suitably
wrapped (distilled ?) for PDF.

Adobe's Illustrator CS certainly opens SVG images, which
can then be resaved as PDF.
Can this be automated using scripts and Apple events?


Here's what Ghostscript documentation says about the
possibility of having an SVG interpreter.


   ** SVG (XML Structured Vector Graphics) interpreter. **

   Ghostscript could be adapted with some work to read SVG.  This  
would be an
   interesting and challenging project because SVG's graphics model  
would
   require extending the library (see above).
   "If SVG turns out to be an important standard, it is important that
   there be a good free implementation of it."

Quite. That message was formulated 4-5 years ago, I think.


In fact there is a "free"  svg2pdf  converter that preserves the VG
nature of the converted image. You can use it online here:
     http://me.in-berlin.de/~darwin/svg/svg2pdf.html
To compile this as a command-line tools requires Python, svglib
and something called "ReportLab ToolKit"; viz,
    (from  http://www.python.net/~gherman/svglib.html)

   svglib  is an extension module for the Open Source RLTK,
    the ReportLab ToolKit and provides SVG reading and reusing
    capabilities to a reasonable degree. As a module it reads
    existing SVG files and returns them converted to ReportLab
    Drawing objects that can be used in a variety of contexts,
    like in RML2PDF, Platypus or PythonPoint. As a command-line
    tool it converts SVG files into PDF ones.


There is another converter, using  Cairo .
Source coding (by Carl Worth ?) can be found at several places:

   http://www.freshports.org/graphics/svg2pdf
   http://webcvs.freedesktop.org/cairo/svg2pdf/
   http://www.freebsdsoftware.org/graphics/svg2pdf.html

I've not examined these repositories or the build procedure,
to see how much of Cairo is actually needed, or whether
it works on MacOS X  --- expect so, as there is a macosx
directory at these repositories.



Also, there is this that looks promising:
   http://www.planetpdf.com/mainpage.asp?webpageid=625
but the links do not lead any to any satisfaction.


>
> Best regards
> --Schremmer

I hope this helps someone to produce a good converter for SVG,
which certainly would be nice to have.


Cheers,

	Ross

------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114
------------------------------------------------------------------------


------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the MacOSX-TeX mailing list