User:Ssstephen/imposition

From XPUB & Lens-Based wiki

I just want to print playing cards as an imposed PDF with crop marks why is this so hard. I liked Simon's page where he wrote his process of trying to do something similar, so here is an attempt at a step by step.

The aim: Take two source PDFs, one is a multi page document with 70 x 95mm playing cards (front only) and another is an arbitrary sized single page PDF with the artwork for the common back of all the cards. I would like to convert these into a single PDF which is 4-up on an A4 sheet, with crop marks (both documents currently have no crop marks or bleed).

Breaking the process into steps:

Make the front pages

Break the document into individual pages

As per Simon's page, pdftk did a good job of this:

 #burst the source PDF, keep the name of the source plus page number (-%d)
 $ pdftk source.pdf burst output source-%d.pdf

Impose 4up on a page using pdfimpose

But first I need to install pdfimpose on breadcube, which at the moment is getting stuck building a wheel for PyMuPDF, when I $ pip install pdfimpose I get an error ending like this:

    running install
    running build
    running build_py
    running build_ext
    building 'fitz._fitz' extension
    swigging fitz/fitz.i to fitz/fitz_wrap.c
    swig -python -o fitz/fitz_wrap.c fitz/fitz.i
    error: command 'swig' failed: No such file or directory
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gvmhv_of/pymupdf_2a274ee5eb254f46956890df6daa0bc0/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gvmhv_of/pymupdf_2a274ee5eb254f46956890df6daa0bc0/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vyct1c_5/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/log/.local/include/python3.9/pymupdf Check the logs for full command output.

So I guess I need to install SWIG first.

When it does work what will I need? Crop marks can be added using mark=[‘crop’]. pdfimpose seems to work using schemas, there is already one called cards which is 4-up.

Make the back pages

Resize the document to 70 x 95mm

Image magick can probably do this like below:

#to resize to specific pixel dimensions such as 256x256
$ magick mogrify -resize 256x256 new_source.pdf

Run the same imposition as above

When we get that working. Also the pdfimpose cards schema has an option for back?

Assemble imposed PDFs into a single file

Or not. But could be nice to collate them so the printer can print one doc double sided. Work and turn or tumble? I think the printer in WDKa has the leading edge at the left. Can this be controlled in pdfimpose? From pdfimpose site: "When printing an imposed PDF, it shall be printed two-sided, the binding edge on the left or right."