9

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?

0

2 Answers 2

13

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 an 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 may be 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.  Its invocation synopsys is identical to that of pdf2ps:

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

Wikipedia says:

poppler-utils is a collection of command-line utilities built on Poppler's library API, to manage PDF and extract contents:

  • pdfattach – add a new embedded file (attachment) to an existing PDF
  • 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 information 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

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 pdftops "${file}" "${file%.*}.ps"
done
5

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .