diff --git a/getannotations b/getannotations index 548e17a..44da1ed 100755 --- a/getannotations +++ b/getannotations @@ -27,7 +27,7 @@ highlights, and highlights with text notes are supported. import os import sys -import pyPdf +import PyPDF2 from prsannots.prst1 import Reader from prsannots.misc import u_raw_input, u_print, u_argv diff --git a/prsannots/generic.py b/prsannots/generic.py index f5c608f..3825f45 100644 --- a/prsannots/generic.py +++ b/prsannots/generic.py @@ -7,7 +7,7 @@ from xml.dom import minidom from StringIO import StringIO import hashlib -import pyPdf +import PyPDF2 from pagetext import PageText, get_layouts, NoSubstringError, MultipleSubstringError from pdfannotation import highlight_annotation, text_annotation, add_annotation from pdfcontent import pdf_add_content, svg_to_pdf_content @@ -92,7 +92,7 @@ def hash(self): @property def pdf(self): """A pyPdf.PdfFileReader instance of the PDF file.""" - return pyPdf.PdfFileReader(open(os.path.join(self.reader.path, self.file), 'rb')) + return PyPDF2.PdfFileReader(open(os.path.join(self.reader.path, self.file), 'rb'),strict=False) def pdf_layout(self, page): """Get a pdfminer.LTPage object for page.""" @@ -125,7 +125,7 @@ def write_annotated_pdf(self, outfd, pdf=None, dice_map=None, **kw): if dice_map is None: dice_map = OneToOneMap(len(self.pdf.pages)) - outpdf = pyPdf.PdfFileWriter() + outpdf = PyPDF2.PdfFileWriter() j = k = 0 for i, page in enumerate(pdf.pages): while j < len(dice_map) and dice_map[j][0] == i: diff --git a/prsannots/pagetext.py b/prsannots/pagetext.py index 0f02753..dbd901e 100644 --- a/prsannots/pagetext.py +++ b/prsannots/pagetext.py @@ -56,7 +56,6 @@ def get_layouts(fd): parser = PDFParser(fd) doc = new_doc(parser) - doc.initialize() laparams = LAParams() rsrcmgr = PDFResourceManager() diff --git a/prsannots/pdfannotation.py b/prsannots/pdfannotation.py index d2c2f47..2f7764b 100644 --- a/prsannots/pdfannotation.py +++ b/prsannots/pdfannotation.py @@ -4,7 +4,7 @@ # the LGPL license. See the file COPYING for full details. from datetime import datetime -from pyPdf.generic import * +from PyPDF2.generic import * YELLOW = [0.95, 0.9, 0.2] diff --git a/prsannots/pdfcontent.py b/prsannots/pdfcontent.py index 18d6ec7..d563e29 100644 --- a/prsannots/pdfcontent.py +++ b/prsannots/pdfcontent.py @@ -3,8 +3,8 @@ # This file is part of prsannots and is distributed under the terms of # the LGPL license. See the file COPYING for full details. -from pyPdf.pdf import ContentStream -from pyPdf.generic import ArrayObject, NameObject +from PyPDF2.pdf import ContentStream +from PyPDF2.generic import ArrayObject, NameObject class StupidSVGInterpreterError(Exception): pass