Skip to content

Instantly share code, notes, and snippets.

@vanzaj
Created June 27, 2013 09:42
Show Gist options
  • Save vanzaj/5875261 to your computer and use it in GitHub Desktop.
Save vanzaj/5875261 to your computer and use it in GitHub Desktop.
testing PyPDF2
import sys
from pathlib import Path
# add local (unpiped) PyPDF2
p = Path(str(__file__)).absolute().parent(level=2)
sys.path.append(p.join('dld', 'PyPDF2').as_posix())
from PyPDF2 import PdfFileReader
from PyPDF2 import PdfFileWriter
pdf_file = p.join('pdf_samples', 'test.pdf').as_posix()
input = PdfFileReader(file(pdf_file, 'rb'))
output = PdfFileWriter()
output.addPage(input.getPage(0))
output.write(file('toto.pdf', 'wb'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment