4

I'm quite new to shell scripting.

I need to create a script or reuse a script that converts PDF to PS (Post Script) files, is there anyway this can be done?

7

I need to create a script or reuse a script that converts PDF to PS (Post Script) files

There are tools but there are also pros and cons for each tool.

pdf2ps is my go to tool since my needs are pretty low. It is a simple one line command.

pdf2ps [options] input.pdf [output.ps]

if you don't give a output.ps it will keep the input file name and just change the extension from pdf to ps.

pdf2ps will convert the files and the file maybe larger and will take longer then pdftops. pdf2ps converts the fonts to bitmap fonts.

Poppler's pdftops is the successor to Xpdf (poppler-utils in Ubuntu). It runs fast, represents the fonts better and has a ton of neat tools.

pdftops[options] input.pdf [output.ps]

poppler-utils is a collection of tools builds on poppler library API, to manage PDF and extract contents. pdfdetach extract embedded documents from a PDF pdffonts lists the fonts used in a PDF pdfimages extract all embedded images at native resolution from a PDF pdfinfo list all infos of a PDF pdfseparate extract single pages from a PDF pdftocairo convert single pages from a PDF to vector or bitmap formats using cairo pdftohtml convert PDF to HTML format retaining formatting pdftoppm convert a PDF page to a bitmap pdftops convert PDF to printable PS format pdftotext extract all text from PDF pdfunite merges several PDF I use wget instead of curl not because wget is better, but because I learned wget first. I do use many of the poppler's tools.

To make it a bash script to convert all pdf to ps converting the extensions only:

#1/bin/bash

clear

find . -type f -iname '*.pdf' -print0 |
   while IFS= read -r -d '' file
      do pdftop "${file}" "${file%.*}.ps"
done
1

From: https://stackoverflow.com/questions/3403485/pdf-to-ps-conversion

Apparently there is a utility called pdf2ps (part of ghostscript) which can do this. There is also another utility called pdftops (part of xPDF) which can do the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.