Update sources from 'PyPDF2' to 'PyPDF4', mostly.

This commit is contained in:
Cameron Laird 2018-08-05 16:43:44 -06:00
parent fbb5054dc4
commit 733e6de8b3
9 changed files with 43 additions and 43 deletions

View File

@ -853,13 +853,13 @@ class EncodedStreamObject(StreamObject):
class RectangleObject(ArrayObject):
"""
This class is used to represent *page boxes* in PyPDF2. These boxes include:
This class is used to represent *page boxes* in PyPDF4. These boxes include:
* :attr:`artBox <PyPDF2.pdf.PageObject.artBox>`
* :attr:`bleedBox <PyPDF2.pdf.PageObject.bleedBox>`
* :attr:`cropBox <PyPDF2.pdf.PageObject.cropBox>`
* :attr:`mediaBox <PyPDF2.pdf.PageObject.mediaBox>`
* :attr:`trimBox <PyPDF2.pdf.PageObject.trimBox>`
* :attr:`artBox <PyPDF4.pdf.PageObject.artBox>`
* :attr:`bleedBox <PyPDF4.pdf.PageObject.bleedBox>`
* :attr:`cropBox <PyPDF4.pdf.PageObject.cropBox>`
* :attr:`mediaBox <PyPDF4.pdf.PageObject.mediaBox>`
* :attr:`trimBox <PyPDF4.pdf.PageObject.trimBox>`
"""
def __init__(self, arr):
# must have four points
@ -954,7 +954,7 @@ class RectangleObject(ArrayObject):
class Field(TreeObject):
"""
A class representing a field dictionary. This class is accessed through
:meth:`getFields()<PyPDF2.PdfFileReader.getFields>`
:meth:`getFields()<PyPDF4.PdfFileReader.getFields>`
"""
def __init__(self, data):
DictionaryObject.__init__(self)
@ -994,8 +994,8 @@ class Field(TreeObject):
mappingName = property(lambda self: self.get("/TM"))
"""
Read-only property accessing the mapping name of this field. This
name is used by PyPDF2 as a key in the dictionary returned by
:meth:`getFields()<PyPDF2.PdfFileReader.getFields>`
name is used by PyPDF4 as a key in the dictionary returned by
:meth:`getFields()<PyPDF4.PdfFileReader.getFields>`
"""
flags = property(lambda self: self.get("/Ff"))

View File

@ -4,7 +4,7 @@ Representation and utils for ranges of PDF file pages.
Copyright (c) 2014, Steve Witham <switham_github@mac-guyver.com>.
All rights reserved. This software is available under a BSD license;
see https://github.com/mstamy2/PyPDF2/blob/master/LICENSE
see https://github.com/claird/PyPDF4/blob/master/LICENSE
"""
import re

View File

@ -40,7 +40,7 @@ __author__ = "Mathieu Fenniak"
__author_email__ = "biziqe@mathieu.fenniak.net"
__maintainer__ = "Phaseit, Inc."
__maintainer_email = "PyPDF2@phaseit.net"
__maintainer_email = "PyPDF4@phaseit.net"
import string
import math
@ -97,7 +97,7 @@ class PdfFileWriter(object):
# info object
info = DictionaryObject()
info.update({
NameObject("/Producer"): createStringObject(codecs.BOM_UTF16_BE + u_("PyPDF2").encode('utf-16be'))
NameObject("/Producer"): createStringObject(codecs.BOM_UTF16_BE + u_("PyPDF4").encode('utf-16be'))
})
self._info = self._addObject(info)
@ -133,7 +133,7 @@ class PdfFileWriter(object):
:class:`PdfFileReader<PdfFileReader>` instance.
:param PageObject page: The page to add to the document. Should be
an instance of :class:`PageObject<PyPDF2.pdf.PageObject>`
an instance of :class:`PageObject<PyPDF4.pdf.PageObject>`
"""
self._addPage(page, list.append)
@ -179,7 +179,7 @@ class PdfFileWriter(object):
:param float height: The height of the new page expressed in default
user space units.
:return: the newly appended page
:rtype: :class:`PageObject<PyPDF2.pdf.PageObject>`
:rtype: :class:`PageObject<PyPDF4.pdf.PageObject>`
:raises PageSizeNotDefinedError: if width and height are not defined
and previous page does not exist.
"""
@ -198,7 +198,7 @@ class PdfFileWriter(object):
user space units.
:param int index: Position to add the page.
:return: the newly appended page
:rtype: :class:`PageObject<PyPDF2.pdf.PageObject>`
:rtype: :class:`PageObject<PyPDF4.pdf.PageObject>`
:raises PageSizeNotDefinedError: if width and height are not defined
and previous page does not exist.
"""
@ -903,7 +903,7 @@ class PdfFileWriter(object):
:param int pagenum: index of the page on which to place the URI action.
:param int uri: string -- uri of resource to link to.
:param rect: :class:`RectangleObject<PyPDF2.generic.RectangleObject>` or array of four
:param rect: :class:`RectangleObject<PyPDF4.generic.RectangleObject>` or array of four
integers specifying the clickable rectangular area
``[xLL, yLL, xUR, yUR]``, or string in the form ``"[ xLL yLL xUR yUR ]"``.
:param border: if provided, an array describing border-drawing
@ -960,7 +960,7 @@ class PdfFileWriter(object):
:param int pagenum: index of the page on which to place the link.
:param int pagedest: index of the page to which the link should go.
:param rect: :class:`RectangleObject<PyPDF2.generic.RectangleObject>` or array of four
:param rect: :class:`RectangleObject<PyPDF4.generic.RectangleObject>` or array of four
integers specifying the clickable rectangular area
``[xLL, yLL, xUR, yUR]``, or string in the form ``"[ xLL yLL xUR yUR ]"``.
:param border: if provided, an array describing border-drawing
@ -1258,7 +1258,7 @@ class PdfFileReader(object):
:param fileobj: A file object (usually a text file) to write
a report to on all interactive form fields found.
:return: A dictionary where each key is a field name, and each
value is a :class:`Field<PyPDF2.generic.Field>` object. By
value is a :class:`Field<PyPDF4.generic.Field>` object. By
default, the mapping name is used for keys.
:rtype: dict, or ``None`` if form data could not be located.
"""
@ -1352,7 +1352,7 @@ class PdfFileReader(object):
Retrieves the named destinations present in the document.
:return: a dictionary which maps names to
:class:`Destinations<PyPDF2.generic.Destination>`.
:class:`Destinations<PyPDF4.generic.Destination>`.
:rtype: dict
"""
if retval == None:
@ -1398,7 +1398,7 @@ class PdfFileReader(object):
"""
Retrieves the document outline present in the document.
:return: a nested list of :class:`Destinations<PyPDF2.generic.Destination>`.
:return: a nested list of :class:`Destinations<PyPDF4.generic.Destination>`.
"""
if outlines == None:
outlines = []
@ -1461,7 +1461,7 @@ class PdfFileReader(object):
Retrieve page number of a given PageObject
:param PageObject page: The page to get page number. Should be
an instance of :class:`PageObject<PyPDF2.pdf.PageObject>`
an instance of :class:`PageObject<PyPDF4.pdf.PageObject>`
:return: the page number or -1 if page not found
:rtype: int
"""
@ -1475,7 +1475,7 @@ class PdfFileReader(object):
:param Destination destination: The destination to get page number.
Should be an instance of
:class:`Destination<PyPDF2.pdf.Destination>`
:class:`Destination<PyPDF4.pdf.Destination>`
:return: the page number or -1 if page not found
:rtype: int
"""
@ -2155,8 +2155,8 @@ class PageObject(DictionaryObject):
"""
This class represents a single page within a PDF file. Typically this
object will be created by accessing the
:meth:`getPage()<PyPDF2.PdfFileReader.getPage>` method of the
:class:`PdfFileReader<PyPDF2.PdfFileReader>` class, but it is
:meth:`getPage()<PyPDF4.PdfFileReader.getPage>` method of the
:class:`PdfFileReader<PyPDF4.PdfFileReader>` class, but it is
also possible to create an empty page with the
:meth:`createBlankPage()<PageObject.createBlankPage>` static method.
@ -2689,14 +2689,14 @@ class PageObject(DictionaryObject):
mediaBox = createRectangleAccessor("/MediaBox", ())
"""
A :class:`RectangleObject<PyPDF2.generic.RectangleObject>`, expressed in default user space units,
A :class:`RectangleObject<PyPDF4.generic.RectangleObject>`, expressed in default user space units,
defining the boundaries of the physical medium on which the page is
intended to be displayed or printed.
"""
cropBox = createRectangleAccessor("/CropBox", ("/MediaBox",))
"""
A :class:`RectangleObject<PyPDF2.generic.RectangleObject>`, expressed in default user space units,
A :class:`RectangleObject<PyPDF4.generic.RectangleObject>`, expressed in default user space units,
defining the visible region of default user space. When the page is
displayed or printed, its contents are to be clipped (cropped) to this
rectangle and then imposed on the output medium in some
@ -2705,20 +2705,20 @@ class PageObject(DictionaryObject):
bleedBox = createRectangleAccessor("/BleedBox", ("/CropBox", "/MediaBox"))
"""
A :class:`RectangleObject<PyPDF2.generic.RectangleObject>`, expressed in default user space units,
A :class:`RectangleObject<PyPDF4.generic.RectangleObject>`, expressed in default user space units,
defining the region to which the contents of the page should be clipped
when output in a production enviroment.
"""
trimBox = createRectangleAccessor("/TrimBox", ("/CropBox", "/MediaBox"))
"""
A :class:`RectangleObject<PyPDF2.generic.RectangleObject>`, expressed in default user space units,
A :class:`RectangleObject<PyPDF4.generic.RectangleObject>`, expressed in default user space units,
defining the intended dimensions of the finished page after trimming.
"""
artBox = createRectangleAccessor("/ArtBox", ("/CropBox", "/MediaBox"))
"""
A :class:`RectangleObject<PyPDF2.generic.RectangleObject>`, expressed in default user space units,
A :class:`RectangleObject<PyPDF4.generic.RectangleObject>`, expressed in default user space units,
defining the extent of the page's meaningful content as intended by the
page's creator.
"""
@ -2849,13 +2849,13 @@ class DocumentInformation(DictionaryObject):
"""
A class representing the basic document metadata provided in a PDF File.
This class is accessible through
:meth:`getDocumentInfo()<PyPDF2.PdfFileReader.getDocumentInfo()>`
:meth:`getDocumentInfo()<PyPDF4.PdfFileReader.getDocumentInfo()>`
All text properties of the document metadata have
*two* properties, eg. author and author_raw. The non-raw property will
always return a ``TextStringObject``, making it ideal for a case where
the metadata is being displayed. The raw property can sometimes return
a ``ByteStringObject``, if PyPDF2 was unable to decode the string's
a ``ByteStringObject``, if PyPDF4 was unable to decode the string's
text encoding; this requires additional safety in the caller and
therefore is not as commonly accessed.
"""

View File

@ -194,7 +194,7 @@ def markLocation(stream):
# Mainly for debugging
RADIUS = 5000
stream.seek(-RADIUS, 1)
outputDoc = open('PyPDF2_pdfLocation.txt', 'w')
outputDoc = open('PyPDF4_pdfLocation.txt', 'w')
outputDoc.write(stream.read(RADIUS))
outputDoc.write('HERE')
outputDoc.write(stream.read(RADIUS))

View File

@ -54,7 +54,7 @@ iso8601 = re.compile("""
class XmpInformation(PdfObject):
"""
An object that represents Adobe XMP metadata.
Usually accessed by :meth:`getXmpMetadata()<PyPDF2.PdfFileReader.getXmpMetadata>`
Usually accessed by :meth:`getXmpMetadata()<PyPDF4.PdfFileReader.getXmpMetadata>`
"""
def __init__(self, stream):

View File

@ -1,4 +1,4 @@
from PyPDF2 import PdfFileWriter, PdfFileReader
from PyPDF4 import PdfFileWriter, PdfFileReader
import sys
import math
@ -25,7 +25,7 @@ def main():
if __name__ == "__main__":
main()
from PyPDF2 import PdfFileWriter, PdfFileReader
from PyPDF4 import PdfFileWriter, PdfFileReader
import sys
import math

View File

@ -6,7 +6,7 @@ http://stackoverflow.com/questions/2693820/extract-images-from-pdf-without-resam
'''
import sys
import PyPDF2
import PyPDF4
from PIL import Image
if (len(sys.argv) != 2):
@ -16,7 +16,7 @@ if (len(sys.argv) != 2):
pdf = sys.argv[1]
if __name__ == '__main__':
input1 = PyPDF2.PdfFileReader(open(pdf, "rb"))
input1 = PyPDF4.PdfFileReader(open(pdf, "rb"))
page0 = input1.getPage(30)
if '/XObject' in page0['/Resources']:

View File

@ -3,7 +3,7 @@ import sys
import unittest
import binascii
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF4 import PdfFileReader, PdfFileWriter
# Configure path environment

View File

@ -20,7 +20,7 @@ objects rather than file streams, allowing for PDF manipulation in memory.
It is therefore a useful tool for websites that manage or manipulate PDFs.
"""
VERSIONFILE="PyPDF2/_version.py"
VERSIONFILE="PyPDF4/_version.py"
verstrline = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
@ -30,15 +30,15 @@ else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE))
setup(
name="PyPDF2",
name="PyPDF4",
version=verstr,
description="PDF toolkit",
long_description=long_description,
author="Mathieu Fenniak",
author_email="biziqe@mathieu.fenniak.net",
maintainer="Phaseit, Inc.",
maintainer_email="PyPDF2@phaseit.net",
url="http://mstamy2.github.com/PyPDF2",
maintainer_email="PyPDF4@phaseit.net",
url="http://claird.github.com/PyPDF4",
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
@ -48,5 +48,5 @@ setup(
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
],
packages=["PyPDF2"],
packages=["PyPDF4"],
)