Wikipedia:Graphics Lab/Resources/PDF conversion to SVG: Difference between revisions

Content deleted Content added
Trikkiboy (talk | contribs)
No edit summary
Legobot (talk | contribs)
m Bot: Fixing lint errors, replacing obsolete HTML tags: <tt> (10x)
Line 37:
 
==== Conversion with dvisvgm ====
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, <ttcode>dvisvgm</ttcode> seems to do a better job, and even results in smaller SVGs in some cases. <ttcode>dvisvgm</ttcode> is often distributed as part of TexLive, and instructions for obtaining it are available on [https://dvisvgm.de/ their website].
 
To convert a PDF to SVG with dvisvgm, run the following command:
<ttcode>dvisvgm --pdf --output=file.svg file.pdf</ttcode>
 
If you want to make your SVG smaller, you can add <ttcode>--optimize=all</ttcode> to <ttcode>dvisvgm</ttcode> and additionally run the resulting SVG through [https://github.com/RazrFalcon/svgcleaner svgcleaner] to further shrink the file without perceptual quality loss. The main drawback is that <ttcode>dvisvgm</ttcode> cannot embed fonts from PDF, it can only convert them to paths.
 
==== Convert a multiple page pdf to svg ====
Line 51:
 
#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.
## '''Ubuntu/Debian/Chromebook with Linux support''': Use <ttcode>sudo apt-get update</ttcode> followed by <ttcode>sudo apt-get install pdf2svg</ttcode> 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 <ttcode>pdf2svg file.pdf file.svg</ttcode>. To extract all pages of a multiple-page PDF use <ttcode>pdf2svg file.pdf output-%02d.svg all</ttcode>. This generates output files ''output-00.svg'', ''output-01.svg'', etc. where the pattern "%02d" is replaced by the respective two-digit page numbers.
#If necessary use Inkscape to edit the resulting SVG.