Choosing Between Ghostscript and MuPDF
Robin Watts & Lisa Fenn·December 15, 2020

Whether you need a simple PDF rendering tool or a cloud print engine, choosing the right tools for your product is critical to your project’s success. Ghostscript and MuPDF are both excellent choices when considering PDF, document management, and print technology solutions. While there is considerable overlap in their abilities, each product is tailored for slightly different requirements.
Ghostscript and MuPDF are both high-quality renderers for a number of file types from PDLs (Page Description Languages including PDF, PostScript, PCL, and XPS) or raster, vector, and ePUB files, to name a few. It can therefore sometimes be hard to know which technology to use in a given situation. First, let’s look under the hood and explore the technical merits of each product, and then we’ll dive into practical use cases for each.
Technical Overview
Input Formats
The Ghostscript family* of interpreters offers native, high-performance rendering of all major page description languages.
If you need the ability to handle PostScript or PCL input, then turn to Ghostscript. Ghostscript is distributed with PostScript “helper files” to handle JPEG, GIF, MIFF (ImageMagick format), and raw files and can be extended to handle other formats using this type of PostScript program.
Unlike other PDF SDKs, MuPDF goes beyond just PDF and is the most versatile product in its category when it comes to document formats. Like Ghostscript, it can handle PDF, XPS, and various image and raster formats (including JPEG, PNG, TIF, PWG, etc). It can also handle formats such as ePUB, FictionBook, and CBZ.
Output Formats
For high-level PostScript, PCL/XL, or XPS output, or to connect with an MS Windows printer, you must use Ghostscript. Both MuPDF and Ghostscript are capable of outputting to PDF (though Ghostscript’s PDF generation is more mature). Both MuPDF and Ghostscript can produce PCLm output (basically bitmaps wrapped into PDF format) and simple bitmap-based PCL output too.
Printer Output
As a rule of thumb, Ghostscript is the better choice when printer output is a critical feature.
With printer output, it’s a question of whether Ghostscript or MuPDF supports your printer out of the box. Ghostscript has support for many printers that MuPDF does not, including a “uniprint” (Universal Printer) output module that allows many more printers to be supported by creating “upp” parameter files.
MuPDF does have support for some printer outputs (such as PCL and CUPS), however, to print to something other than a PCL printer, you’ll have to add some C code yourself.
Both MuPDF and Ghostscript can produce PWG format output (aka CUPS format, used for printing on Linux systems), but Ghostscript can handle more of the possible output color spaces.
If you want to output for a printer type that is not currently supported by either Ghostscript, CUPS, or the existing “upp” files then you are going to need to add some code yourself (possibly an “upp” file or C code).
Adding a new printer type – via bitmap output
The easiest mechanism for outputting to a printer that is not already supported or that cannot be supported using the “uniprint” module is to get Ghostscript or MuPDF to render to a bitmap, and then convert that bitmap into a data stream for your printer.
Ghostscript has the ability to do a range of different halftoning techniques for Monochrome printers including ordered (spot) dither based on threshold arrays or functions and error diffusion. MuPDF renders in contone and then has code in it to do simple thresholding based halftoning to give a monochrome bitmap. Other such conversions can, of course, be added by the integrator.
Both MuPDF and Ghostscript can render in RGB, Greyscale, CMYK, and CMYK + Spots are capable of overprint simulation, and also of handling color separations and DeviceN colors.
Adding a new printer type – via high-level output
By ‘high-level output’ we mean making use of vector, text, or image objects rather than breaking everything down into simple rasterized bitmaps.
If you wish to drive a printer with some different type of high-level format, then both Ghostscript and MuPDF can handle this. Both products require you to implement a ‘device’ to perform graphics operations on a virtual page.
Ghostscript has high-level devices to output PostScript (Level 2) and PCL-6 (aka PCL/XL).
While MuPDF does not currently offer any fully functional high-level output devices, it has both SVG output and PDF output modules that demonstrate its abilities. A third-party has implemented a GDI-based output for doing rendering on Windows.
It is beyond the scope of this document to talk more about this here. Please contact Artifex if you would like further information.
Bitmap Output
If you are outputting to a bitmap other than monochrome, greyscale, RGB, CMYK, or CMYK+Spots, or if you need JPEG, TIFF, MIFF, BMP, PCX, PSD (Photoshop), or raw output use Ghostscript. While only MuPDF supports Truevision TGA output.
Both Ghostscript and MuPDF support PBM, PGM, PPM, PAM, PNG, and both have the ability to do anti-aliased rendering, but MuPDF has this embedded in the renderer at a lower level than Ghostscript. If anti-aliased output is important to you, then MuPDF is probably a better bet.
MuPDF is the better choice when rendering PDF, XPS, or Image input for display based use.
Color Management
Both MuPDF and Ghostscript offer color-managed workflows, both use ICC profiles and (by default) LCMS. The Ghostscript color management options are more extensive (refer to http://www.ghostscript.com/doc/current/GS9_Color_Management.pdf), supporting different color management for object types (text, images, and vector graphics) and separations.
Banded Rendering
Ghostscript and MuPDF are both capable of rendering pages in bands to keep memory usage down. Ghostscript can be built with the ability to make use of RAM or disc-based storage for its display list, whereas MuPDF runs entirely using RAM.
Ghostscript can make its own decisions about how big a band buffer to use (though it can be told explicitly by the caller), whereas MuPDF always leaves this to the caller to specify.
Multithreaded Operation
Both Ghostscript and MuPDF interpret pages using a single thread, but both can use multiple threads to actually render the page content.
Both allow for one page to be rendered in background threads while the display list for the next page is created by the interpreter.
The decision of how to handle threads is divorced from the core of MuPDF. It is possible to implement both of the above schemes with MuPDF, as well as many others (such as rendering thumbnails for pages on a background thread, while rendering current pages at different zoom levels).
Ghostscript offers certain common tasks in a ready rolled package. MuPDF requires slightly more integration but is ultimately more flexible for it.
Manipulation of PDF files
Ghostscript has the ability to read PDF (or other formats) files, break them down into graphical objects, and to make completely new PDF files from them. Some users make use of this to ‘sanitize’ PDF files, reduce the size, extract pages, change the color model, etc. Some (non-graphical) information in the PDFs (such as structural information, bookmarks, etc) may be lost during this process. The type of PDF file created by Ghostscript can be PDF/A-1, PDF/A-2, or PDF/X-3, and a PDF (1.4 and above) that has transparency can be “flattened” to make a PDF 1.3 that does not use transparency. Ghostscript can also encrypt the resulting PDF file allowing for separate “owner” and “user” passwords so that users can be given a restricted set of permissions.
MuPDF has the ability to directly manipulate PDF files. While it cannot convert a non-PDF file to a PDF file, it can perform operations such as page deletions, linearisation, or addition of annotations without losing the existing information within the file.
Interactive Behaviour
Viewers can be built either with Ghostscript or MuPDF, but MuPDF is much better suited to this task.
Ghostscript cannot handle interactive features such as form filling, whereas MuPDF can, and MuPDF has support for incremental loading of Linearized (Web optimized) PDFs from websites which can improve viewers’ response times. MuPDF supports a variety of interactive features including annotations, form filling, digital signatures, redactions, text search, and progressive loading.
Porting
Both Ghostscript and MuPDF are highly portable. Opinions differ between engineers as to which is easier to embed. Ghostscript (and GhostPCL) have been embedded in several printers and MuPDF has been embedded in many tablets and smartphones.
Use Cases
Now that you better understand the technical similarities and differences between Ghostscript and MuPDF, let’s walk through use cases for each product.
Mobile
When developing for mobile, MuPDF is the clear choice. MuPDF has been used as the PDF engine in thousands of Android and iOS applications for it’s high-quality and fast rendering, conversion capabilities, and interactive features.
MuPDF is also an outstanding rendering tool for eBook readers. The viewer is small, fast, yet complete and supports ePUB and CBZ file formats.
Cloud and SaaS Solutions
Artifex technologies provide secure, flexible print and document management solutions. Both Ghostscript and MuPDF are appropriate for cloud and SaaS deployments. Which you choose will depend on your particular project.
For high performing document management solutions, or the ability to normalize a bad PDF document, Ghostscript is the way to go. Ghostscript provides real-time viewing and rendering, file manipulation capabilities, data extraction, and customizable document output.
Integrate Ghostscript into your cloud print or SaaS solution to enable fast, reliable, and flexible printing solutions. Centralized cloud printing platforms need to have the flexibility to accommodate the thousands of printers in the world with their variety of driver capabilities.
MuPDF’s interactive PDF features, form filling, redactions, and digital signatures combine for an efficient and collaborative cloud workflow. Connect to your PDF files from any location, on any device. MuPDF’s high-fidelity rendering, tiny footprint, and exceptionally fast performance make MuPDF a perfect fit when size is key.
Document Management
Ghostscript’s interpreter and conversion capabilities aid document management systems by converting a wide range of language inputs into readily usable documents for enterprise workflow. Conversion capabilities include PDF/A for archiving files and PDF/X to facilitate graphics exchange.
We’ve added OCR device support to Ghostscript as of the 9.53 release, and MuPDF as of 1.19. Convert printed paper documents, scanned raster images, digital camera images, etc. into searchable PDF text documents. Searchable text is then accessible to annotation features, screen readers, text extraction, and automation workflows.
RIP/Printers/MFAs
For printer and RIP projects, Ghostscript is the clear choice. Ghostscript handles a broader array of language formats and is highly customizable, delivering greater versatility to RIP solution providers. Ghostscript offers excellent print quality with our patented color management technology, band-at-a-time rendering, and opacity and blending controls.
The Power of Productivity
Artifex technologies drive enterprise solutions and product development for large companies as well as startups and individual developers. Artifex is dedicated to providing prompt and professional technical support and consulting services to our customers. We are deeply committed to product quality and service. So whether you choose Ghostscript or MuPDF, when you partner with Artifex, you are assured outstanding service and a commitment to invest in our partnership.
* For this discussion we’ll use “Ghostscript” when we actually mean “Ghostscript, GhostPCL, and GhostXPS”; information regarding Ghostscript applies to the others as they share the same basic structure and devices. In other documents, you may see all three of these referred to collectively as “GhostPDL”. To make matters more confusing, we now have an actual product called “GhostPDL” that pulls the functionality from all three together into a single executable.