Open In App

gs command in Linux with Examples

gs command invokes Ghostscript, which is an interpreter of Adobe Systems PostScript and Portable Document Format(PDF) languages. After executing Ghostscript it reads further input from the standard input stream until it encounters ‘quit‘ command. 

Syntax:  



gs [ options ] [ files ] ...

Options: Below are some important options of gs command.  

Devices:  



  1. PDF writer: The pdfwrite device outputs PDF.
  2. PS2 writer: The ps2write device outputs postscript language level 2. It is recommended that this device is used for PostScript output.
  3. EPS writer : The eps2write device outputs encapsulated postscript.
  4. PXL : The pxlmono and pxlcolor devices output HP PCL-XL, a graphic language understood by many laser printers.
  5. Text output : The txtwrite device will output the text contained in the document as Unicode.

Examples:  

gs -dSAFER syllabus.pdf

gs -dSAFER -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 -sOutputFile=front.png a.pdf

See front.png created in the directory.

gs -dSAFER -dNOPAUSE -sDEVICE=png16m -r150 -sOutputFile=front_1.png c.pdf

You can observe the difference between the two images first one is 150 dpi and second is the original image.

gs -dSAFER -dNOPAUSE -sDEVICE=pgmraw -r150 -dTextAlphaBits=4 -sOutputFile=’paper-%d.pgm’ a.pdf

gs -dSAFER -dNOPAUSE -sDEVICE=pdfwrite -r150 -sOutputFile=concatenate.pdf a.pdf b.pdf c.pdf

After executing the above command it will concatenate all three PDFs a.pdf, b.pdf, c.pdf, and save it as concatenate.pdf

 

Article Tags :