You can go to Print & Scan
in the system preferences and select Options & Supplies
for your printer. In there, you should see an option for Duplex Unit
(if your printer supports it). If that is checked, you can use the automatic double-side printing (by checking the Two-sided
box next to Copies
). If not, or if that option is unavailable, you can't.
In case you can't select that option, here's how you can manually print double-sided pages.
Manual double-side printing
You can control manual double-side printing (i.e., you physically turn the sheets over) using the Paper Handling
setting in the print dialog.
If you select Paper Handling
, you'll find a Pages to Print
option that lets you print either only the odd pages or only the even pages (default is both). To print double side manually, select Odd Only
first and when it finishes printing, flip the pages over and select Even Only
Instead of flipping each page over to its blank side before printing the even pages, you have a more convenient option of flipping the entire block of pages, so that the last sheet is on top (useful when you have a lot of pages to be printed). With this, you can then choose Reverse
in Page Order
to print the even numbered pages backwards. (Note: be careful that if you have an odd-number of pages in total, you might have to leave the last one out before printing the even ones.)
The following python script will Merge one 'template' PDF onto the pages of any PDF file created in the Print dialog. You will need to supply the filepath to the template PDF in the script, then save it in your user Library, inside a folder called "PDF Services" e.g. ~/Library/PDF Services
. (This may need to be created, if not already there.)
The script can then be called from the PDF button of the print dialog.
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
# Merge v. 0.1
# Merges two PDFs
import sys
import os
import Quartz as Quartz
from Foundation import NSURL, kCFAllocatorDefault
from AppKit import NSSavePanel, NSApp
# OPTIONS
watermark = os.path.expanduser("~/Desktop/myTemplate.pdf")
destination = os.path.expanduser("~/Desktop") # Default destination
suffix = " wm.pdf" # Use ".pdf" if no actual suffix required.
# FUNCTIONS
def save_dialog(directory, filename):
panel = NSSavePanel.savePanel()
panel.setTitle_("Save PDF booklet")
myUrl = NSURL.fileURLWithPath_isDirectory_(directory, True)
panel.setDirectoryURL_(myUrl)
panel.setNameFieldStringValue_(filename)
NSApp.activateIgnoringOtherApps_(True)
ret_value = panel.runModal()
if ret_value:
return panel.filename()
else:
return ''
# Loads in PDF document
def createPDFDocumentWithPath(path):
return Quartz.CGPDFDocumentCreateWithURL(Quartz.CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, path, len(path), False))
# Creates a Context for drawing
def createOutputContextWithPath(path, dictarray):
return Quartz.CGPDFContextCreateWithURL(Quartz.CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, path, len(path), False), None, dictarray)
# Gets DocInfo from input file to pass to output.
# PyObjC returns Keywords in an NSArray; they must be tupled.
def getDocInfo(file):
file = file.decode('utf-8')
pdfURL = NSURL.fileURLWithPath_(file)
pdfDoc = Quartz.PDFDocument.alloc().initWithURL_(pdfURL)
if pdfDoc:
metadata = pdfDoc.documentAttributes()
if "Keywords" in metadata:
keys = metadata["Keywords"]
mutableMetadata = metadata.mutableCopy()
mutableMetadata["Keywords"] = tuple(keys)
return mutableMetadata
else:
return metadata
def main(argv):
(title, options, pathToFile) = argv[:]
shortName = os.path.splitext(title)[0]
# If you want to save to a consistent location, use:
# writeFilename = os.path.join(destination, shortName + suffix)
writeFilename = save_dialog(destination, shortName + suffix)
writeFilename = writeFilename.encode('utf-8')
shortName = os.path.splitext(pathToFile)[0]
metaDict = getDocInfo(pathToFile)
writeContext = createOutputContextWithPath(writeFilename, metaDict)
readPDF = createPDFDocumentWithPath(pathToFile)
mergePDF = createPDFDocumentWithPath(watermark)
if writeContext != None and readPDF != None:
numPages = Quartz.CGPDFDocumentGetNumberOfPages(readPDF)
for pageNum in xrange(1, numPages + 1):
page = Quartz.CGPDFDocumentGetPage(readPDF, pageNum)
mergepage = Quartz.CGPDFDocumentGetPage(mergePDF, 1)
if page:
mediaBox = Quartz.CGPDFPageGetBoxRect(page, Quartz.kCGPDFMediaBox)
if Quartz.CGRectIsEmpty(mediaBox):
mediaBox = None
Quartz.CGContextBeginPage(writeContext, mediaBox)
Quartz.CGContextSetBlendMode(writeContext, Quartz.kCGBlendModeOverlay)
Quartz.CGContextDrawPDFPage(writeContext, page)
Quartz.CGContextDrawPDFPage(writeContext, mergepage)
Quartz.CGContextEndPage(writeContext)
Quartz.CGPDFContextClose(writeContext)
del writeContext
else:
print "A valid input file and output file must be supplied."
sys.exit(1)
if __name__ == "__main__":
main(sys.argv[1:])
Currently, this uses the first page of the template PDF file and puts it on all pages of the output PDF.
Best Answer
You can do this with Markdown.pl and htmldoc(1), both of which can be installed with Homebrew. The basic flow for making a PDF is:
As for your filename-per-page, you coul incorporate echo to add it as an HTML element:
And for printing, the lpr(1) command will send a file to your default printer.
Tying this altogether: