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.
gs [ options ] [ files ] ...
Options: Below are some important options of gs command.
- –P : Makes Ghostscript to look first in the current directory for library files.
- -q : Quiet startup: suppress normal startup messages, and also do the equivalent of -dQUIET.
- -rnumber, -rnumber1xnumber2 : Same as -dDEVICEXRESOLUTION=number1 and -dDEVICEYRESOLUTION=number2.If only one number is given, it is used for both X and Y resolutions.
- -dNOCACHE : Disables character caching. Useful only for debugging.
- -dNOBIND : Disables the “bind” operator. Useful only for debugging.
- -dNODISPLAY : Suppresses the normal initialization of the output device. This may be useful when debugging.
- -dNOPAUSE : Disables the prompt and pause at the end. This may be desirable for applications where another program is driving Ghostscript.
- -dSAFER : Restricts the file operations that job can perform.
- -sDEVICE=device : Selects an alternate initial output device.
- -sOutputFile=filename : Selects an alternate output file (or pipe) for the initial output device.
- PDF writer: The pdfwrite device outputs PDF.
- PS2 writer: The ps2write device outputs postscript language level 2. It is recommnded that this device is used for PostScript output.
- EPS writer : The eps2write device outputs encapsulated postscript.
- PXL : The pxlmono and pxlcolor devices output HP PCL-XL, a graphic language understood by many laser printers.
- Text output : The txtwrite device will output the text contained in the document as Unicode.
- To view a PDF :
gs -dSAFER syllabus.pdf
- To convert a figure into png :
gs -dSAFER -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 -sOutputFile=front.png a.pdf
See front.png created in the directory.
- To convert image to 150 dpi :
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.
- To convert all pages to image :
gs -dSAFER -dNOPAUSE -sDEVICE=pgmraw -r150 -dTextAlphaBits=4 -sOutputFile=’paper-%d.pgm’ a.pdf
- To concatenate two PDFs :
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
- 'IPCS' command in Linux with examples
- select command in Linux with examples
- Sed Command in Linux/Unix with examples
- ZIP command in Linux with examples
- SORT command in Linux/Unix with examples
- Cat command in Linux with examples
- Head command in Linux with examples
- Tail command in Linux with examples
- wc command in Linux with examples
- tar command in Linux with examples
- atrm command in Linux with examples
- bc command in Linux with examples
- AWK command in Unix/Linux with examples
- tr command in Unix/Linux with examples
- mv command in Linux with examples
- Paste command in Linux with examples
- comm command in Linux with examples
- cmp Command in Linux with examples
- cut command in Linux with examples
- cp command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : VivekAgrawal3