domenica 5 novembre 2017

UBUNTU - Reduce PDF file size with pdf2gs and gs2pdf

First convert pdf to ghostscript:
pdf2ps file1.pdf file2.ps
then reconvert ghostscript to pdf:
ps2pdf file2.ps file3.pdf
file3.pdf is smaller about 50% than file1.pdf bye

UBUNTU - Batch convert SVG files to PDF and join them in a single PDF

I extracted SVG pictures from a site that allow me only to see the files and not to download it with Chrome browser and this extension:

https://chrome.google.com/webstore/detail/export-svg-with-style/dkjdcaddoplepioppogpckelchefhddi?utm_source=chrome-app-launcher-info-dialog

The result is a bunch of SVG files numbered progressively (e.g saved0.svg,saved1.svg....,saved45.svg).
I renamed the first 10 files saved0.svg to saved9.svg to saved00.svg..saved09.svg to avoid problems when merging all pages together. I moved all in a folder and applied this little bash script:



paste it in new file give it execution permission ( chmod 755 filename)
 I dropped the script in the same folder but you can put in /usr/bin to have it always ready ..
The script simply check all files on the folder, verify if they are svg files and attempt comversion to pdf.
The result should be a bunch of pdf files numbered progressively (e.g saved0.pdf,saved1.pdf....,saved45.pdf).


Now with pdftk we can join all single pdf pages lying in the folder in one single file (You need an ordered sequence of files to do it).

pdftk *.pdf cat output FILE.pdf

That's all