0

So I'm familiar with Python but not exactly an expert. What I've been doing is looking into tools that I can use to convert an existing PDF into a PNG of higher quality/zoom, draw the trim & bleed boxes, and simulate overprinting. I want to make sure that stuff like existing text in the PDF that isn't easily visible or grainy can have overprint applied to the rendered image so that it comes through clearly.

PyMuPDF so far does great with creating a PNG and drawing the trim/bleed boxes and runs quickly. I noticed that with the MuPDF (not PyMuPDF) the documentation lists an option to control overprint simulation with MUTOOL. Is there some way I can simulate overprinting using PyMuPDF? I've been digging through the docs but I'm a little lost.

I'm open to other tools, but so far things I've seen seem to only apply overprint when drawing new content onto the PDF instead of applying to existing content. I'm brand new to PDF manipulation so I could just be missing something completely.

My little code snippet of what I'm doing to read in the image & draw trim/bleed. Just not sure where to go from here to get overprinting on the existing PDF text.

import glob, fitz

path = 'resources/'
all_files = glob.glob(path + "*.pdf")

for filename in all_files:
   doc = fitz.open(filename)
   for page in doc:
      fname, ext = os.path.splitext(filename)
      fname = fname[len(path)::]
      process_pdf(page, fname)

def process_pdf(page, fname):
   matx = fitz.Matrix(2.0, 2.0)
   bleed_box_dim = fitz.Rect( page.bleedbox)
   trim_box_dim = fitz.Rect( page.trimbox)

   page.draw_rect(bleed_box_dim, color=[1,0,0,0], overlay=True, width=0.5)
   page.draw_rect(trim_box_dim, color=[0,1,0,0], overlay=True, width=0.5)

   pix = page.get_pixmap(matrix=matx)
   pix.save("outputs/%s-page-%i.png" % (fname, page.number+1))

Xanodus
  • 1
  • 3

0 Answers0