| 1 |
The Ghostscript family of products |
| 2 |
================================== |
| 3 |
|
| 4 |
GhostPDL contains the complete Artifex document processing suite: |
| 5 |
a unified package of interpreters and a shared graphics library for rendering, |
| 6 |
converting, and manipulating documents across every major page description |
| 7 |
language and many image formats. |
| 8 |
|
| 9 |
It includes Ghostscript (PostScript/PDF), GhostPDF, GhostPCL (PCL/PXL), |
| 10 |
GhostXPS (XPS) and GhostPDL as a single source tree. |
| 11 |
|
| 12 |
|
| 13 |
CONTENTS |
| 14 |
-------- |
| 15 |
1. What's in this repository |
| 16 |
2. Getting pre-built binaries |
| 17 |
3. Requirements |
| 18 |
4. Quick start |
| 19 |
5. Key capabilities |
| 20 |
6. Command-line examples |
| 21 |
7. Language bindings |
| 22 |
8. Building from source |
| 23 |
9. Documentation |
| 24 |
10. License |
| 25 |
|
| 26 |
|
| 27 |
1. WHAT'S IN THIS REPOSITORY |
| 28 |
----------------------------- |
| 29 |
GhostPDL is the umbrella source distribution for the entire Ghostscript family |
| 30 |
of products. Each interpreter is built on the same shared Ghostscript graphics |
| 31 |
library and can be compiled individually or together. |
| 32 |
|
| 33 |
Ghostscript PostScript Level 3 and PDF interpreter and renderer |
| 34 |
GhostPDF Standalone C-based PDF interpreter (default since 9.55) |
| 35 |
GhostPCL PCL5 and PCL/XL (PXL) interpreter |
| 36 |
GhostXPS XPS (XML Paper Specification) interpreter |
| 37 |
GhostPDL Multi-language framework; auto-detects PS, PDF, PCL, XPS, |
| 38 |
and image formats |
| 39 |
|
| 40 |
When running as GhostPDL, the interpreter automatically detects the input |
| 41 |
language using file signatures and heuristics — no flag is required for |
| 42 |
mixed-language job streams. PJL (Printer Job Language) framing is also |
| 43 |
supported for separating jobs. |
| 44 |
|
| 45 |
|
| 46 |
2. GETTING PRE-BUILT BINARIES |
| 47 |
------------------------------ |
| 48 |
For most users, pre-built binaries are the fastest way to get started. |
| 49 |
Source compilation is only needed when embedding Ghostscript as a library |
| 50 |
or customising the build. |
| 51 |
|
| 52 |
Linux (Debian/Ubuntu): |
| 53 |
|
| 54 |
sudo apt-get install ghostscript |
| 55 |
|
| 56 |
macOS (MacPorts): |
| 57 |
|
| 58 |
sudo port install ghostscript |
| 59 |
|
| 60 |
macOS (Homebrew): |
| 61 |
|
| 62 |
brew install ghostscript |
| 63 |
|
| 64 |
Windows: |
| 65 |
|
| 66 |
Download the installer from: |
| 67 |
https://github.com/ArtifexSoftware/ghostpdl-downloads/releases |
| 68 |
|
| 69 |
Both 32-bit and 64-bit command-line executables are provided. |
| 70 |
|
| 71 |
Verify the installation: |
| 72 |
|
| 73 |
gs --version |
| 74 |
|
| 75 |
or on Windows: |
| 76 |
|
| 77 |
gswin64c --version |
| 78 |
|
| 79 |
|
| 80 |
3. REQUIREMENTS |
| 81 |
--------------- |
| 82 |
Runtime: |
| 83 |
|
| 84 |
OS Linux, macOS, Windows, BSD, and other Unix-like platforms |
| 85 |
Architecture x86, x86-64, ARM, and others (platform-dependent builds) |
| 86 |
|
| 87 |
Build dependencies (source compilation only): |
| 88 |
|
| 89 |
C compiler GCC, Clang, or MSVC (Visual Studio 2015 or later) |
| 90 |
make / nmake GNU make on Unix; nmake via Visual Studio on Windows |
| 91 |
autoconf Required when building from a git checkout (run autogen.sh) |
| 92 |
FreeType Bundled in freetype/; external version also accepted |
| 93 |
libjpeg, zlib, |
| 94 |
libpng Bundled or system-provided |
| 95 |
libtiff Optional; required for TIFF output |
| 96 |
OpenJPEG Optional; required for JPEG 2000 support |
| 97 |
|
| 98 |
Note: The PCL/XL fonts in pcl/urwfonts/ are required for GhostPCL to |
| 99 |
function and are distributed under the AFPL licence, which prohibits |
| 100 |
commercial use. They are not free software. See pcl/COPYING.AFPL in the |
| 101 |
source distribution for details. |
| 102 |
|
| 103 |
|
| 104 |
4. QUICK START |
| 105 |
-------------- |
| 106 |
Convert a PDF to PNG images (one per page): |
| 107 |
|
| 108 |
gs -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 \ |
| 109 |
-sOutputFile=page_%03d.png input.pdf |
| 110 |
|
| 111 |
-dBATCH -dNOPAUSE Run non-interactively and exit when done |
| 112 |
-sDEVICE=png16m 24-bit color PNG output device |
| 113 |
-r300 300 DPI output resolution |
| 114 |
-sOutputFile=page_%03d.png Numbered output files |
| 115 |
|
| 116 |
Convert PostScript to PDF: |
| 117 |
|
| 118 |
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \ |
| 119 |
-sOutputFile=output.pdf input.ps |
| 120 |
|
| 121 |
Or use the convenience wrapper: |
| 122 |
|
| 123 |
ps2pdf input.ps output.pdf |
| 124 |
|
| 125 |
Convert a PDF to a single JPEG: |
| 126 |
|
| 127 |
gs -dBATCH -dNOPAUSE -dFirstPage=1 -dLastPage=1 \ |
| 128 |
-sDEVICE=jpeg -r150 -sOutputFile=page1.jpg input.pdf |
| 129 |
|
| 130 |
|
| 131 |
5. KEY CAPABILITIES |
| 132 |
------------------- |
| 133 |
PostScript Full PostScript Language Level 3 interpreter |
| 134 |
PDF Read and render PDF 1.0-2.0; write PDF via pdfwrite |
| 135 |
device (9.55+: new C-based interpreter) |
| 136 |
PCL / PXL PCL5 and PCL/XL (HP printer language) via GhostPCL |
| 137 |
XPS XML Paper Specification via GhostXPS |
| 138 |
Image formats Input: JPEG (JFIF/EXIF), PNG, TIFF, JBIG2, JPEG 2000, |
| 139 |
PWG. Output: PNG, JPEG, TIFF, BMP, PCX, PBM/PGM/PPM, |
| 140 |
and more |
| 141 |
Rasterisation Render to raster at any DPI; anti-aliasing control |
| 142 |
PDF output Convert PostScript, PCL, XPS, and images to PDF; |
| 143 |
compress and optimise existing PDFs |
| 144 |
PostScript output Convert PDF back to PostScript Level 2 |
| 145 |
N-up imposition Impose multiple pages onto one sheet; works across all |
| 146 |
input types |
| 147 |
OCR Convert scanned raster images to searchable PDF |
| 148 |
(since 9.53) |
| 149 |
PDF compression Reduce PDF file size without quality loss |
| 150 |
Language detection GhostPDL automatically identifies input language |
| 151 |
PJL support Printer Job Language framing for job separation |
| 152 |
Embeddable library Link libgs as a shared/static library; gsapi C |
| 153 |
interface with Python, Java, and C# bindings |
| 154 |
Color management ICC profile support; CMYK, RGB, Gray, DeviceN |
| 155 |
Font support Type 1, TrueType, OpenType, CFF; font substitution |
| 156 |
and embedding |
| 157 |
|
| 158 |
|
| 159 |
6. COMMAND-LINE EXAMPLES |
| 160 |
------------------------ |
| 161 |
Render a specific page range: |
| 162 |
|
| 163 |
gs -dBATCH -dNOPAUSE -sDEVICE=png16m -r150 \ |
| 164 |
-dFirstPage=2 -dLastPage=5 \ |
| 165 |
-sOutputFile=page_%d.png input.pdf |
| 166 |
|
| 167 |
Render in greyscale: |
| 168 |
|
| 169 |
gs -dBATCH -dNOPAUSE -sDEVICE=pnggray -r300 \ |
| 170 |
-sOutputFile=page_%03d.png input.pdf |
| 171 |
|
| 172 |
Compress / optimise a PDF: |
| 173 |
|
| 174 |
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \ |
| 175 |
-dCompatibilityLevel=1.5 -dPDFSETTINGS=/ebook \ |
| 176 |
-sOutputFile=compressed.pdf input.pdf |
| 177 |
|
| 178 |
-dPDFSETTINGS options: |
| 179 |
/screen 72 dpi |
| 180 |
/ebook 150 dpi |
| 181 |
/printer 300 dpi |
| 182 |
/prepress 300 dpi, color-preserving |
| 183 |
/default |
| 184 |
|
| 185 |
Convert a password-protected PDF: |
| 186 |
|
| 187 |
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \ |
| 188 |
-sPDFPassword=secret -sOutputFile=unlocked.pdf input.pdf |
| 189 |
|
| 190 |
Convert XPS to PDF (GhostXPS): |
| 191 |
|
| 192 |
gxps -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \ |
| 193 |
-sOutputFile=output.pdf input.xps |
| 194 |
|
| 195 |
Convert PCL to PDF (GhostPCL): |
| 196 |
|
| 197 |
gpcl6 -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \ |
| 198 |
-sOutputFile=output.pdf input.pcl |
| 199 |
|
| 200 |
Get help and list available devices: |
| 201 |
|
| 202 |
gs -h |
| 203 |
|
| 204 |
|
| 205 |
7. LANGUAGE BINDINGS |
| 206 |
-------------------- |
| 207 |
The gsapi C interface exposes the full Ghostscript engine as an embeddable |
| 208 |
library. Official bindings are included in the repository under demos/. |
| 209 |
|
| 210 |
C psi/iapi.h gsapi_new_instance, gsapi_init_with_args, |
| 211 |
gsapi_exit |
| 212 |
Python demos/python/gsapi.py gsapi_new_instance(), gsapi_run_file() |
| 213 |
Java demos/java/ GSAPI, GSInstance |
| 214 |
C# demos/csharp/ GhostAPI.ghostapi (static methods) |
| 215 |
|
| 216 |
Python example: |
| 217 |
|
| 218 |
import gsapi |
| 219 |
|
| 220 |
instance = gsapi.gsapi_new_instance(0) |
| 221 |
gsapi.gsapi_set_arg_encoding(instance, gsapi.GS_ARG_ENCODING_UTF8) |
| 222 |
gsapi.gsapi_init_with_args(instance, [ |
| 223 |
"gs", |
| 224 |
"-dBATCH", "-dNOPAUSE", |
| 225 |
"-sDEVICE=pdfwrite", |
| 226 |
"-sOutputFile=output.pdf", |
| 227 |
"input.ps" |
| 228 |
]) |
| 229 |
gsapi.gsapi_exit(instance) |
| 230 |
gsapi.gsapi_delete_instance(instance) |
| 231 |
|
| 232 |
C# example: |
| 233 |
|
| 234 |
using GhostAPI; |
| 235 |
|
| 236 |
IntPtr instance; |
| 237 |
ghostapi.gsapi_new_instance(out instance, IntPtr.Zero); |
| 238 |
ghostapi.gsapi_set_arg_encoding(instance, |
| 239 |
(int)gsEncoding.GS_ARG_ENCODING_UTF8); |
| 240 |
|
| 241 |
string[] args = { "gs", "-dBATCH", "-dNOPAUSE", |
| 242 |
"-sDEVICE=pdfwrite", |
| 243 |
"-sOutputFile=output.pdf", "input.ps" }; |
| 244 |
ghostapi.gsapi_init_with_args(instance, args.Length, args); |
| 245 |
ghostapi.gsapi_exit(instance); |
| 246 |
ghostapi.gsapi_delete_instance(instance); |
| 247 |
|
| 248 |
Threading note: Unless compiled with GS_THREADSAFE, only one Ghostscript |
| 249 |
instance may be active at a time. |
| 250 |
|
| 251 |
|
| 252 |
8. BUILDING FROM SOURCE |
| 253 |
----------------------- |
| 254 |
Unix / Linux / macOS: |
| 255 |
|
| 256 |
# 1. Clone the canonical repository |
| 257 |
git clone git://git.ghostscript.com/ghostpdl.git |
| 258 |
cd ghostpdl |
| 259 |
|
| 260 |
# 2. Generate the configure script |
| 261 |
# (git checkout only; not needed for release tarballs) |
| 262 |
./autogen.sh |
| 263 |
|
| 264 |
# 3. Configure |
| 265 |
./configure |
| 266 |
|
| 267 |
# 4. Build |
| 268 |
make |
| 269 |
|
| 270 |
# 5. Install (optional) |
| 271 |
sudo make install |
| 272 |
|
| 273 |
To build as a shared library instead of an executable: |
| 274 |
|
| 275 |
make so # builds libgs.so / libgs.dylib |
| 276 |
|
| 277 |
|
| 278 |
9. DOCUMENTATION |
| 279 |
---------------- |
| 280 |
Documentation index: |
| 281 |
https://ghostscript.readthedocs.io |
| 282 |
|
| 283 |
How to use Ghostscript (command-line reference): |
| 284 |
https://ghostscript.readthedocs.io/en/latest/Use.html |
| 285 |
|
| 286 |
Building from source: |
| 287 |
https://ghostscript.readthedocs.io/en/latest/Make.html |
| 288 |
|
| 289 |
GhostPDL framework: |
| 290 |
https://ghostscript.readthedocs.io/en/latest/GPDL.html |
| 291 |
|
| 292 |
Language bindings (C, Python, Java, C#): |
| 293 |
https://ghostscript.readthedocs.io/en/latest/LanguageBindings.html |
| 294 |
|
| 295 |
Output devices: |
| 296 |
https://ghostscript.readthedocs.io/en/latest/Devices.html |
| 297 |
|
| 298 |
PDF conversion: |
| 299 |
https://ghostscript.readthedocs.io/en/latest/VectorDevices.html |
| 300 |
|
| 301 |
Color management: |
| 302 |
https://ghostscript.readthedocs.io/en/latest/GhostscriptColorManagement.html |
| 303 |
|
| 304 |
Source code architecture: |
| 305 |
https://ghostscript.readthedocs.io/en/latest/Develop.html |
| 306 |
|
| 307 |
Change log: |
| 308 |
https://ghostscript.readthedocs.io/en/latest/News.html |
| 309 |
|
| 310 |
Bug tracker: |
| 311 |
https://bugs.ghostscript.com |
| 312 |
|
| 313 |
Discord (#ghostscript): |
| 314 |
https://artifex.com/discord/artifex |
| 315 |
|
| 316 |
Canonical git repository: |
| 317 |
https://cgit.ghostscript.com/ghostpdl.git |
| 318 |
|
| 319 |
Binary downloads: |
| 320 |
https://ghostscript.com/releases |
| 321 |
|
| 322 |
Third-party library list: |
| 323 |
https://ghostscript.readthedocs.io/en/latest/thirdparty.html |
| 324 |
|
| 325 |
|
| 326 |
10. LICENSE |
| 327 |
----------- |
| 328 |
GhostPDL is available under two licences: |
| 329 |
|
| 330 |
GNU AGPL v3 (https://www.gnu.org/licenses/agpl-3.0.html) |
| 331 |
Free for open-source software. Any application that uses, distributes, |
| 332 |
or provides access to Ghostscript as a network service must release its |
| 333 |
complete source code under a compatible open-source licence. |
| 334 |
|
| 335 |
Commercial licence |
| 336 |
Required for proprietary applications where AGPL compliance is not |
| 337 |
possible. Contact Artifex for licensing: |
| 338 |
https://artifex.com/contact/ghostscript |
| 339 |
|
| 340 |
Third-party libraries |
| 341 |
A complete list of bundled third-party libraries (FreeType, libjpeg, |
| 342 |
zlib, OpenJPEG, and others), their versions, and their licences is |
| 343 |
maintained at: |
| 344 |
https://ghostscript.readthedocs.io/en/latest/thirdparty.html |