Browse Source

pdf layout post

master
sipp11 9 years ago
parent
commit
72cbc7466a
  1. 35
      _posts/2015-08-02-pdf-layout-python.md
  2. 3
      sync_to_prod.sh

35
_posts/2015-08-02-pdf-layout-python.md

@ -0,0 +1,35 @@
---
layout: post
title: "Save x page per sheet PDF in python"
author:
display_name: sipp11
login: sipp11
email: sipp11@gmail.com
url: ''
author_login: sipp11
author_email: sipp11@gmail.com
date: Aug 2, 2015
categories:
- coding
tags:
- python
- pdf
---
Reportlab is my go-to PDF library in `python`; however, it doesn't do multiple page layout well. The solution is to do regular multiple pages PDF with `reportlab`, then process that PDF file afterward to have any layout you want (2-page per sheet, 4-page per sheet, 9-page per sheet, ...)
What you need?
`pdfnup` -- it's available via `pip` but an ImportError always there. As a result, you need to download [that](https://bitbucket.org/deeplook/pdfnup/overview) and do install by yourself.
$ python setup.py install
Simple enough. You also have a command line to work on too.
>>> from pdfnup import generateNup
>>>
>>> generateNup("multiple-pages.pdf", 2, verbose=True)
written: file-2up.pdf
There you go.

3
sync_to_prod.sh

@ -1,7 +1,8 @@
#!/bin/sh
RUSER=sipp11
RHOST=do3
#RHOST=do3
RHOST=bb-aws-micro-1
PORT=22
RPATH=/opt/www/10ninox_blog
LPATH=./_site/

Loading…
Cancel
Save