Table des matières

GS - Ghostscript

Manu Fernandes 23/02/2011 08:26 create

ps vers pdf

script linux ps2pdf path convertit tout les .ps qui sont dans path en .pdf

#!/bin/bash
ls $1/ps/*.ps | while read ficname; do
RAC=`echo $ficname | cut -d . -f 1`
/usr/bin/gs -q -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dSAFER -sPAPERSIZE=a4 -sOutputFile=$RAC.pdf $ficname
rm $ficname
done

Merge PDF

Joining PDFs the Ghostscript way

Ghostscript is a package that enables you to view or print PostScript and PDF files to other formats, or to convert those files to other formats. It's a popular tool among Linux users, but what many people don't know is that Ghostscript is also a powerful tool for combining PDF files.

To use Ghostscript to combine PDF files, type something like the following:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf

Unless you're very familiar with Ghostscript, that string of commands won't mean much to you. Here's a quick breakdown:

  • gs – starts the Ghostscript program
  • -dBATCH – once Ghostscript processes the PDF files, it should exit. If you don't include this option, Ghostscript will just keep running
  • -dNOPAUSE – forces Ghostscript to process each page without pausing for user interaction
  • -q – stops Ghostscript from displaying messages while it works
  • -sDEVICE=pdfwrite – tells Ghostscript to use its built-in PDF writer to process the files
  • -sOutputFile=finished.pdf – tells Ghostscript to save the combined PDF file with the name that you specified

When using Ghostscript to combine PDF files, you can add any PDF-related option to the command line. For example, you can compress the file, target it to an eBook reader, or encrypt it. See the Ghostscript documentation for more information.

The biggest advantage to Ghostscript is that it's a standard part of many Linux distributions. If you don't have it on your computer, it's easy to download and install it.

Using Ghostscript has its drawbacks, too. Unless you use Ghostscript's PDF options, the utility produces a barebones merged PDF file, and a large one at that, because by default Ghostscript doesn't compress PDF files. On top of that, some people may find typing long strings of options at the command line to be a bit of a chore.

intools/softtool/post/gs.txt · Dernière modification: 23/02/2011 08:32 par Manu Fernandes
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki