PostScript libraries for C/C++
- Ghostscript is the PostScript interpreter. Its C API (
gsapi_*) runs Ghostscript inside your process with the same arguments as thegscommand: convert PS to PDF, render pages to PNG, extract text, compute bounding boxes. AGPL-3.0 or commercial. - libspectre sits on top of Ghostscript and gives a document/page API for viewers: page count from DSC comments, title and creator, render one page to an RGB buffer. Evince and Okular use it. GPL-2.0.
- cairo draws vector graphics and text and writes them as PostScript (Level 2 or 3), PDF, SVG or PNG. It can’t read PostScript. LGPL-2.1 or MPL-1.1.
Pick Ghostscript to process existing files, libspectre when you build a viewer and want pages and metadata without Ghostscript command lines, and cairo to generate PostScript.
- cairo cairo is a 2D graphics library for C with a PostScript output surface. How to install it, write multi-page PostScript files, set page sizes, add DSC comments.
- Ghostscript Use the Ghostscript C API (libgs) to convert PostScript to PDF, render PS pages to PNG, extract text and get the bounding box from C or C++. Installation.
- libspectre libspectre is a small C library on top of Ghostscript for PostScript viewers. How to install it, read page count and DSC metadata, render a PS page to RGB.