Wikipedia:Graphics Lab/Resources/PDF conversion to SVG: Difference between revisions
Content deleted Content added
→Conversion with PDF2SVG: adding updated info |
→Extracting part of a PDF: making instructions clearer |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 14:
See also [[commons:Category:PDF maps]].
=== How to convert a PDF to SVG ===
==== Convert a single page of a pdf to .svg ====
====Conversion with Inkscape====▼
▲===== Conversion with Inkscape =====
#Download [[Inkscape]] from [https://www.inkscape.org www.inkscape.org] (version 0.46 and above)
Line 32 ⟶ 34:
#Upload the SVG to Wikimedia Commons and tag it with {{Tld|Extracted with Inkscape|v}}
''Note: Some versions of Inkscape do not have PDF support compiled in; also, text importing does not always produce satisfactory results in Inkscape.''
====Conversion with PDF2SVG====▼
Large and complex PDFs such as some of the maps from the USGS are sometimes difficult for PDF2SVG or Inkscape to convert. For PDFs that are not able to be converted by these tools, <
To convert a PDF to SVG with dvisvgm, run the following command:▼
#Get PDF2SVG from Github [https://github.com/dawbarton/pdf2svg here], additional info [http://www.cityinthesky.co.uk/opensource/pdf2svg/ here]. If you are using Windows, Linux or FreeBSD or OSX, PDF2SVG is installable via the package installer.▼
#Convert the PDF with <tt>pdf2svg file.pdf file.svg</tt>, to extract all pages of a multiple page pdf use <tt>pdf2svg file.pdf output-%02d.svg all</tt>▼
#If necessary use Inkscape to edit the resulting SVG.▼
If you want to make your SVG smaller, you can add <
====Conversion with dvisvgm====▼
==== Convert a multiple page pdf to svg ====
▲Large and complex PDFs such as some of the maps from the USGS are sometimes difficult for PDF2SVG or Inkscape to convert. For PDFs that are not able to be converted by these tools, <tt>dvisvgm</tt> seems to do a better job, and even results in smaller SVGs in some cases. <tt>dvisvgm</tt> is often distributed as part of TexLive, and instructions for obtaining it are available on [https://dvisvgm.de/ their website].
Inkscape currently doesn't support extracting multiple pages of a .pdf to svg.
▲To convert a PDF to SVG with dvisvgm, run the following command:
pdf2svg is a command line tool which allows you to extract multiple or all pages of a pdf to a series of .svg files. To install:
▲<tt>dvisvgm --pdf --output=file.svg file.pdf</tt>
▲#Get
## '''Ubuntu/Debian/Chromebook with Linux support''': Use <code>sudo apt-get update</code> followed by <code>sudo apt-get install pdf2svg</code> in the command line. (''Note: [https://askubuntu.com/questions/1230902/what-is-the-correct-way-to-create-a-persistent-ubuntu-20-04-usb you can run a 'persistent' version of Ubuntu on a USB stick without installing it on your hard drive]'').
## '''Windows''': Binaries can be downloaded from [https://github.com/jalios/pdf2svg-windows here].
To convert a pdf:
▲#Convert the first page of a PDF file with <
▲#If necessary use Inkscape to edit the resulting SVG.
''Note: It requires that [[Poppler (software)|Poppler]], [[cairo (graphics)|Cairo]], and [[X_Window_System|X]] are installed on your system.''
▲If you want to make your SVG smaller, you can add <tt>--optimize=all</tt> to <tt>dvisvgm</tt> and additionally run the resulting SVG through [https://github.com/RazrFalcon/svgcleaner svgcleaner] to further shrink the file without perceptual quality loss.
===Extracting part of a PDF===
Line 53 ⟶ 64:
Inkscape often produces [[#BadSVG|unreasonably large]] SVG files from PDFs, especially if you are only trying to use a small part of the PDF (such as a single vector image or logo on a larger page). In order to reduce the size of the resulting image, it is almost always better to copy and paste the portion of interest into a new Inkscape document rather than try to delete the unwanted content and crop the canvas. To do this:
#Open the PDF in Inkscape
#Delete any backgrounds or surrounding text/images near the image you are trying to extract
#Select the entire image you are trying to extract by holding the SHIFT key and dragging
|