Wikipedia:Graphics Lab/Resources/PDF conversion to SVG
Please see commons:Category:PDF maps.
This is a tutorial in various formats. Some parts are in question-and-answer format, as in FAQs. Parts of this were copied and adapted from this discussion:
Before learning how to convert PDF images to SVG images it may be useful to learn how to extract images from PDF documents and create PNG, GIF, and JPG images. By using Adobe Reader many images in PDF documents can be right-clicked, copied, and then pasted into any image editor. A popular, free image editor good for beginners using Microsoft Windows is IrfanView (if you use GNU/Linux you may have Gimp in your distribution). Launch it and paste the image into it. Then use the image editor to save the image in any format. You can also select almost any area of a PDF document with Adobe Reader's cropping and selection tools, and then copy that selected area by right-clicking it. Then paste it into any image editor for conversion to other image formats. The PrintScreen key on your keyboard is a good last resort, too. Click that key, and then open an image editor and click "paste" (usually in the edit menu). Finally, Wikipedia:Graphic Lab/Image workshop can create, extract, or edit almost any image. Just leave a request for help or advice there.
Now here is some info on how to convert PDF image to SVG images. This page covers conversion using free tools. To convert using Adobe Illustrator go to the following two pages:
- Wikipedia:Graphic Lab/Resources/PDF conversion to SVG/Adobe Illustrator
- Wikipedia:Graphic Lab/Images to improve/Archive/Jul 2008#Image:APISmap1.pdf
It takes only a few seconds to convert a PDF to an SVG, using nothing but free software. Go open source and free software! This tutorial assumes familiarity with installing programs and downloading, saving, opening and uploading files.
How to convert a PDF to SVG
Conversion with Inkscape
- Download Inkscape from www.inkscape.org (version 0.46 and above)
- Download the PDF you want to convert
- Run Inkscape
- Open the PDF file you want convert in Inkscape (not Acrobat)
- Click OK on the box that comes up
- Wait a little while as Inkscape converts it
- Click File>Save As..
- Click Save in the bottom right corner
- Done! You now have an SVG file with the same name as the PDF, but with the .svg extension
- Upload the SVG and check that it displays properly
Conversion with PDF2SVG
Some versions of Inkscape do not have PDF support compiled in. In that case you might try conversion with the PDF2SVG command line tool. (It depends on Poppler, Cairo, and X to be installed on your system.)
- Get PDF2SVG from http://www.cityinthesky.co.uk/pdf2svg.html and compile it. If you are using Linux or FreeBSD or MacPorts, PDF2SVG might also be installable via the package installer.
- Convert the PDF with pdf2svg file.pdf file.svg
- If necessary use Inkscape to edit the resulting SVG.
Online conversion with misc2svg
- Select your local AI, CDR, EPS, PDF or PS file with "Browse" dialog at misc2svg (max. file size 4 Megabyte)
- Enter a page number if you upload PDF or PS
- Click "senden" to upload your file. Upload fails if SVG file is larger 10 Megabyte or unknown file type or uploaded file is broken. Misc2svg converts fonts in PDF files to paths
- Download your SVG file on next page
If you can't see the SVG on Wikipedia/Commons
This should work for most PDF to SVG conversions, but if it doesn't there are some things you can do:
- Check that you have the 0.46 or later version of Inkscape. Earlier versions do not have PDF support.
- There may be compatibility problems between the Wikipedia / Media rendering engine and Inkscape:
- Select everything (Ctrl-A) and choose the Path>Object to Path command.
- Select everything (Ctrl-A) and choose the Path>Stroke to Path command.
- In the File>Save As.. dialog look for the drop-down menu just above the Save button and save as a Plain SVG.
- If that doesn't work, call your local friendly WikiGraphist at Wikipedia:Graphic Lab/Images to improve or Wikipedia talk:WikiProject Maps.
Basic navigation in Inkscape
If you want to take a look at your SVG in Inkscape hold Ctrl and roll the mouse wheel forward and back to zoom in and out. Use the scroll-bars on the right and bottom to scroll.
Warning
Some PDFs create very "bad" SVG files when converted automatically. A "bad" SVG can be identified because it will convert slowly (more than 5 seconds), it will be very large for an SVG (over 1MB) and it will render very slowly on WP - there is a long wait while the text and other images on the page are loaded, but the SVG image does not show up. Bad SVGs put a lot of strain on the Wiki servers. If you suspect you have a "bad" file, go to a Wikigraphist for a manual conversion. These will almost always be much better than the automated versions in terms of being smaller, better drawn and easier to translate because the text is created properly.
Images in PDFs
This is excellent if the PDF has vector graphics, but not so useful if it has a photograph or raster graphics inside. Inkscape won't magically convert any raster graphics included in the document into vector graphics.
However, Inkscape can help you to extract the photo.
You can tell that a graphic is a raster image in Inkscape 0.47 if after selecting the graphic and choosing Object > Ungroup, you cannot select individual elements. Also, when you click the graphic Inkscape's status bar will show "Image" and its context menu will have an Image Properties item. If the raster graphic is the only element you want from the PDF, there is no point in saving the file as SVG—it isn't a Scalable Vector Graphic. However, Inkscape can give you an exact lossless copy of the original image from the PDF at its original size in pixels. One way to do so is to use Extensions > Images > Extract Image... Another is to save as SVG, view the SVG in Firefox, right-click on the image in the SVG, choose View Image from the context menu, then use Firefox's File > Save As... to save the image as a PNG file.
For interest
Inkscape is FOSS software. For additional comments see this discussion:
If you have comments about this tutorial or it doesn't work for you, please comment on the talk page.
Can you clarify what a "PDF map" is, for this purpose?
I feel ignorant - but a quick wiki-search and Google-search did not enlighten me. I know how to put any graphic file into a pdf - but my strong hunch is that it takes more than this to make it a "pdf map"!
- Good Q. An example of a (vector) PDF map ready for conversion to SVG is this. PDFs can contain practically any type of information, the most common ones being text, raster images (ordinary images like bitmaps) and vector graphics. The vector information has to be coded into the PDF as such. Quite a lot of organizations publish vector information (like maps) this way, so it's handy to be able to convert out of PDF, but putting things into PDFs is pointless for us, it doesn't change the type. If you need a raster image converted, best to speak to a WikiGraphist - MissMJ is the resident pro and very approachable.