I'm attempting to convert a PDF to SVG. However, the one I am using currently maps a path for every letter in every piece of text, meaning if I change the text in its source file, it looks ugly.
I was wondering what the cleanest PDF to SVG converter is, hopefully one that doesn't have a path for it's text areas that simply don't need one. As we know, PDF and SVG are fairly similar, so I assume there's some good converters out there.
Bash script to convert each page of a PDF into its own SVG file.
To generate in png, use
--export-png
, etc...Inkscape is used by many people on Wikipedia to convert PDF to SVG.
http://inkscape.org/
They even have a handy guide on how to do so!
http://en.wikipedia.org/wiki/Wikipedia:Graphic_Lab/Resources/PDF_conversion_to_SVG#Conversion_with_Inkscape
I found that
xfig
did an excellent job:It did much better job than inkscape. Actually it was probably pdtoedit that did it.
This topic is quite old, but here is a handy solution that I found:
http://www.cityinthesky.co.uk/opensource/pdf2svg/
It offers a tool, pdf2png, which once installed does exactly the job in command line. I've tested it with irreproachable results so far, including with bitmaps.
EDIT : My mistake, this tool also converts letters to paths, so it does not address the initial question. However it does a good job anyway, and can be useful to anyone who does not intend to modify the code in the svg file, so I'll leave the post.
Here is the process that I ended up using. The main tool I used was Inkscape which was able to convert text alright.
Separate Pages: Adobe Acrobat Pro with JavaScript
Using Adobe Acrobat Pro Actions (formerly Batch Processing) create a custom action to separate PDF pages into separate files. Alternatively you may be able to split up PDFs with GhostScript
Acrobat JavaScript Action to split pages
PDF to SVG Conversion: Inkscape with Windows CMD batch file
Using Windows Cmd created batch file to loop through all PDF files in a folder and convert them to SVG
Batch file to convert PDF to SVG in current folder
Cleanup attributes: Windows Cmd and PowerShell
I realize it is not best practice to manually brute force edit SVG or XML tags or attributes due to potential variations and should use an XML parser instead. However I had a simple issue where the stroke width on one drawing was very small, and on another the font family was being incorrectly identified, so I basically modified the previous Windows Cmd batch script to do a simple find and replace. The only changes were to the search string definitions and changing to call a PowerShell command. The PowerShell command will perform a find and replace and save the modified file with an added suffix. I did find some other references that could be better used to parse or modify the resultant SVG files if some other minor cleanup is needed to be performed.
Modifications to manually find and replace SVG XML data
powershell -Command "(Get-Content '%~n1.%_work_x1%') | ForEach-Object {$_ -replace 'stroke-width:0.06', 'stroke-width:1'} | ForEach-Object {$_ -replace 'font-family:Times Roman','font-family:Times New Roman'} | Set-Content '%~n1%_work_s2%.%_work_x2%'"
Hope this might help someone
References
Adobe Acrobat Pro Actions and JavaScript references to Separate Pages
GhostScript references to Separate Pages
Inkscape Command Line references for PDF to SVG Conversion
Windows Cmd Batch File Script references
XML tag/attribute replacement research
Here is the NodeJS REST api for two PDF render scripts. https://github.com/pumppi/pdf2images
Scripts are: pdf2svg and Imagemagicks convert