I’ve recently completed a series of print projects in python. I learned a few things that might help others. I’ll share what I’ve learned here.

Keep in mind that my experience with print is fairly limited. If you are familiar with printing and have suggestions for this blog, let me know.


Fixing Adobe Error 14

Imagine this: working on a data visualization book for close to a year with a client, sending it to the printing service, and getting an adobe-equivalent of “computer says no”. This error stressed me out. The printer turned out to use a stricter PDF reader than me and my client did.

Somehow, the setup of my PDF triggered an error. I think it originated from the way I merge the PDFs for the book. The PDF for the book is rendered using a programmatic merge of a collection of about 60 PDFs.

This resulted in the first page’s meta data saying something like:

He Adobe, I’m a document with a single page

While the actual document was larger:

Don’t tell Adobe, but I’m actually a 60 page book.

To fix the issue, I built a ‘open PDF and save as a new PDF’ script, using a different PDF package than I use for my book (that one was PyPDF2):

from pypdf import PdfWriter, PdfReader

def flatten_pdf(input_pdf_path, output_pdf_path):
    writer = PdfWriter()
    writer.clone_document_from_reader(PdfReader(input_pdf_path))
    with open(output_pdf_path, "wb") as f:
        writer.write(f)

Running this code fixed the issue.


Print preview artifacts

When I got the PDF working, I got a digital proof from the friendly people print service. This turns the PDF into a PDF that is ready to print. I checked the file and ran into some weird rendering issues. Lines that appeared and shouldn’t be there or lines that somehow change width.

I had two types of visualisations to fix

1: Inkscape drawings

I designed some visualizations in Inkscape. I changed the way I save them to fix the rendering issues.

  • Old version: a simple ‘save as PDF’.
  • New versions: save image as a JPG images with the dpi set to 300 (required for print), inserted the JPG into a blank PDF page (also Inkscape), and saved that new PDF+JPG combination as a PDF to use for printing.

2: Matloplib illustrations

The visualizations I made with Matplotlib were PDF files and also had a rendering issue here and there. I fixed these by setting the rasterized parameter to true for all data visualization code (e.g. ax.scatter) and text annotations (e.g. ax.text).

This changes the visual elements in the output PDFs from SVGs (vector graphics) to the JPGs (rasterized images). Make sure to set dpi=300 when calling savefig.


Color corrections

Images designed for computer screens are rendered with RGB color codes. Print images are different and often require CMYK codes, though I learned that some printer services actually do request RGB colours. Whatever you end up using, always check the desired format with your printing service.

If I do need to convert my colors from RGB to CMYK, I do so in 2 ways:

  1. Quick / depend on automatic conversion: if you provide an RGB image to a CMYK printing service, they’ll automatically convert the color codes and there can be small variations in the output. Check if you can get a digital proof of the conversion and review it.
  2. Exact / set CMYK codes manually: I used colors from a dictionary of colour combinations (vol. 2) for a series of data art illustrations. The color codes in the book are all CMYK. So I first had to find RGB-versions of the codes for my digital work. Luckily, this lovely webapp gave me RGB-versions of the colors (consider supporting the app if you use it). The nice thing is that I have the CMYK codes all in a physical book. This makes color conversion easy. I prepare the images for a CMYK printing service in 4 steps:
    • 1) save the image from matplotlib as a PDF.
    • 2) open the PDF using the open source publication software Scribus.
    • 3) Click Edit > Colors and Fills, and set all the colors to the correct CMYK color codes.
    • 4) export to PDF and under the Colors tab, set it to printing.

That last trick only works if you know the CMYK color codes, but if you don’t, you can still use it to change the color profile of your PDF from RGB to CMYK.


That’s it.