convert PDF to SVG fails to create valid file

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
jeffrey.berger
Posts: 12
Joined: 2013-08-16T09:33:28-07:00
Authentication code: 6789

convert PDF to SVG fails to create valid file

Post by jeffrey.berger »

Using the command:
>convert foo.pdf foo.svg
>
produces an SVG file that, when viewed in a browser contains:
-----------------------
This page contains the following errors:

error on line 871 at column 74: Namespace prefix xlink for href on image is not defined
Below is a rendering of the page up to the first error.
-----------------------

Nothing follows the error message.

The original PDFs were produced:
- using PDFLib
- as export-to-pdf from Excel
- by the US gov (W-4 Form)

Version: ImageMagick 6.9.0-0 Q16 x86_64 2014-12-11 http://www.imagemagick.org on Mac OS 10.10.1
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert PDF to SVG fails to create valid file

Post by snibgo »

The command "convert foo.pdf foo.svg" should rasterize each page of the PDF, converting it to pixels, making SVG files that contain embedded bitmaps.

For someone to investigate, you should put a PDF that shows the problem somewhere like dropbox.com and paste the link here.
snibgo's IM pages: im.snibgo.com
jeffrey.berger
Posts: 12
Joined: 2013-08-16T09:33:28-07:00
Authentication code: 6789

Re: convert PDF to SVG fails to create valid file

Post by jeffrey.berger »

Sure. Here's one:
http://www.irs.gov/pub/irs-pdf/fw4.pdf

convert DOES create an SVG file, but the file cannot be opened in the browser because of the missing namespace specification.

Thanks.
jeffrey.berger
Posts: 12
Joined: 2013-08-16T09:33:28-07:00
Authentication code: 6789

Re: convert PDF to SVG fails to create valid file

Post by jeffrey.berger »

Aha!
The problem is in the headers IM is creating for the SVG. I pasted in headers from an SVG created by exporting from Adobe Illustrator and the IM SVG became viewable.

Below, IM's headers are commented, Illustrator's are not:

<!-- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010 ... /svg10.dtd"> -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- <svg width="648" height="918"> -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="648px" height="918px" viewBox="0 0 648 918" enable-background="new 0 0 648 918" xml:space="preserve">
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert PDF to SVG fails to create valid file

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.9.0-6 Beta available by sometime tomorrow. Thanks.
jeffrey.berger
Posts: 12
Joined: 2013-08-16T09:33:28-07:00
Authentication code: 6789

Re: convert PDF to SVG fails to create valid file

Post by jeffrey.berger »

Just getting back to this issue. Where/how can I find info about downloading/installing the Beta? (Mac OS 10.10.1)

Thanks!
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert PDF to SVG fails to create valid file

Post by dlemstra »

This version has been published, you can just download the latest release.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jeffrey.berger
Posts: 12
Joined: 2013-08-16T09:33:28-07:00
Authentication code: 6789

Re: convert PDF to SVG fails to create valid file

Post by jeffrey.berger »

Thanks!
Post Reply