Using the GTK Print Dialog #

The GTK Print Dialog is a universal interface for printing used in various GTK applications except LibreOffice. These are my skills and techniques in printing using the GTK Print Dialog.

Printing consecutive pages #

These are the steps for printing 2 pages per side, 2 sides per sheet:

  1. Open the Print dialog for the file to be printed.
  2. In General tab, select the printer, and select All Pages for Range.
  3. In Page Setup tab, adjust the settings as follows:
    • Pages per side: 2,
    • Page ordering: Left to right,
    • Only print: Odd sheets,
    • Paper size: A4 (or adjust to your needs),
    • Adjust Scale to your needs.
  4. In Advanced tab, adjust Print Quality to your needs and choose whether to print in color or not.
  5. Click on Print, and wait for the printing to be completed.
  6. Vertically flip over the pile of printed sheets, making its bottom facing up. Then load the pile of paper again. (Don't shuffle the sheets.)
  7. Redo steps 1-5, but adjust Only Print to Even Sheets in step 3.

Note: to ensure pages are set up correctly, you may choose to "Print to file" in step 2 and preview your setup.

Printing a brochure #

In printing, saddle stitching refers to folding a pile of paper and driving staples though the centerfold, making it a booklet.

Since all pages in a document need to be rearranged in a certain way, which can't be done directly in the print dialog, I wrote a Python 3 script for this:

import PyPDF2
import math

reader = PyPDF2.PdfReader(open('input.pdf', 'rb'))
pages = len(reader.pages)
pieces = math.ceil(pages / 4)

front_writer = PyPDF2.PdfWriter()
back_writer = PyPDF2.PdfWriter()

def get_page(index):
	if(index >= pages):
		return PyPDF2.PageObject.create_blank_page(reader)
	return reader.pages[index]

for i in range(pieces):
	front_writer.add_page(get_page(pieces * 4 - i * 2 - 1))
	front_writer.add_page(get_page(i * 2))
	back_writer.add_page(get_page(i * 2 + 1))
	back_writer.add_page(get_page(pieces * 4 - i * 2 - 2))

front_writer.write(open('output_front.pdf', 'wb'))
back_writer.write(open('output_back.pdf', 'wb'))
print("Done. Pieces of paper needed: %s" % pieces)

The script converts input.pdf to output_front.pdf and output_back.pdf, and outputs the pieces of paper needed. Ensure that there is sufficient paper and ink before you start printing:

  1. For output_front.pdf, do steps 1-5 described above, but adjust Only Print to All Sheets in step 3.
  2. Vertically flip over the pile of printed sheets, making its bottom facing up. Then load the pile of paper again. (Don't shuffle the sheets.)
  3. For output_back.pdf, do steps 1-5 described above, but adjust Only Print to All Sheets in step 3.

This page is released into the public domain under CC0 1.0.