Friday, August 14, 2015

Convert problematic .ps files into pdf

Especially those dynamic pdfs that do not allow to save. So an option is to print the into a .ps. However, those files aren't unable to be reconverted back into pdf (which is a problem is they are going to be printed in Windows). So in Linux the trick to force the conversion into pdf is:

$ gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 -sOutputFile=page_%02d.png -r600 problem_file.ps

this creates png files at 600ppi (don't worry, due to the -r600 the document won't be pixelated). Then, the png are converted into pdfs:

$ convert page_01.png page_01.pdf

do this for each png generated by gs. Finally, assemble everything into a single pdf:

$  pdftk page_01.pdf page_02.pdf page_0n.pdf  cat output fixed_file.pdf

No comments: