Finishing python comments
This commit is contained in:
parent
301346f23b
commit
0965d8ee54
|
@ -2,8 +2,8 @@
|
|||
let demo = false
|
||||
let noncomp = false
|
||||
let major_version = 2
|
||||
let minor_version = 4
|
||||
let version_date = "(21st June 2021)"
|
||||
let minor_version = 5
|
||||
let version_date = "(devel, 1st Sept 2021)"
|
||||
|
||||
open Pdfutil
|
||||
open Pdfio
|
||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -2951,7 +2951,7 @@ In a PDF file, optional content groups are used to group graphical elements toge
|
|||
\clearpage
|
||||
\section*{C Interface}
|
||||
\begin{small}\tt
|
||||
\lstinputlisting{splits/c16}
|
||||
\lstinputlisting{splits/c17}
|
||||
\end{small}
|
||||
\end{cpdflib}
|
||||
|
||||
|
@ -2959,7 +2959,7 @@ In a PDF file, optional content groups are used to group graphical elements toge
|
|||
\clearpage
|
||||
\section*{Python Interface}
|
||||
\begin{small}\tt
|
||||
\lstinputlisting{pysplits/c16}
|
||||
\lstinputlisting{pysplits/c17}
|
||||
\end{small}
|
||||
\end{pycpdflib}
|
||||
|
||||
|
|
|
@ -12,5 +12,4 @@ A 'range' is a list of integers specifying page numbers.
|
|||
Text arguments and results are in UTF8.
|
||||
|
||||
Any function may raise the exception CPDFError, carrying a string describing
|
||||
the error.
|
||||
"""
|
||||
the error. """
|
||||
|
|
110
pysplits/c01.tex
110
pysplits/c01.tex
|
@ -1,14 +1,98 @@
|
|||
# CHAPTER 0. Preliminaries
|
||||
Loading the libpypcdf and libcpdf DLLs
|
||||
--------------------------------------
|
||||
|
||||
def loadDLL(f):
|
||||
"""Load the libpycpdf DLL from a given file, and set up pycpdflib."""
|
||||
Before using the library, you must load the ``libpycpdf`` and ``libcpdf`` DLLs.
|
||||
This is achieved with the ``pycpdf.loadDLL`` function, given the filename or
|
||||
full path of the ``libpycpdf`` DLL.
|
||||
|
||||
On Windows, you may have to call ``os.add_dll_directory`` first. On MacOS, you
|
||||
may need to give the full path, and you may need to install ``libcpdf.so`` in a
|
||||
standard location ``/usr/local/lib/``, or use the ``install_name_tool`` command
|
||||
to tell ``libpycpdf.so`` where to find ``libcpdf.so``.
|
||||
|
||||
Conventions
|
||||
-----------
|
||||
|
||||
Any function may raise the exception ``CPDFError``, carrying a string describing
|
||||
the error.
|
||||
|
||||
A 'range' is a list of integers specifying page numbers. Page numbers start at
|
||||
1. Range arguments are called `r`.
|
||||
|
||||
Text arguments and results are in UTF8.
|
||||
|
||||
Units are in PDF points (1/72 inch).
|
||||
|
||||
Angles are in degrees.
|
||||
|
||||
|
||||
Built-in values
|
||||
---------------
|
||||
|
||||
Paper sizes:
|
||||
|
||||
a0portrait a1portrait a2portrait a3portrait a4portrait a5portrait a0landscape
|
||||
a1landscape a2landscape a3landscape a4landscape a5landscape usletterportrait
|
||||
usletterlandscape uslegalportrait uslegallandscape
|
||||
|
||||
Permissions:
|
||||
|
||||
noEdit noPrint noCopy noAnnot noForms noExtract noAssemble noHqPrint
|
||||
|
||||
Encryption methods:
|
||||
|
||||
pdf40bit pdf128bit aes128bitfalse aes128bittrue aes256bitfalse aes256bittrue
|
||||
aes256bitisofalse aes256bitisotrue
|
||||
|
||||
Positions:
|
||||
|
||||
Positions with two numbers in a tuple e.g (posLeft, 10.0, 20.0)
|
||||
|
||||
posCentre posLeft posRight
|
||||
|
||||
Positions with one number in a tuple e.g (top, 5.0)
|
||||
|
||||
top topLeft topRight left bottomLeft bottomRight right
|
||||
|
||||
Positions with no numbers e.g diagonal
|
||||
|
||||
diagonal reverseDiagonal
|
||||
|
||||
Fonts:
|
||||
|
||||
timesRoman timesBold timesItalic timesBoldItalic helvetica helveticaBold
|
||||
helveticaOblique helveticaBoldOblique courier courierBold courierOblique
|
||||
courierBoldOblique
|
||||
|
||||
Justification:
|
||||
|
||||
leftJustify centreJustify rightJustify
|
||||
|
||||
Page layouts:
|
||||
|
||||
singlePage oneColumn twoColumnLeft twoColumnRight twoPageLeft twoPageRight
|
||||
|
||||
Page modes:
|
||||
|
||||
useNone useOutlines useThumbs useOC useAttachments
|
||||
|
||||
Page label styles:
|
||||
|
||||
decimalArabic uppercaseRoman lowercaseRoman uppercaseLetters lowercaseLetters
|
||||
|
||||
|
||||
# CHAPTER 0. Preliminaries
|
||||
|
||||
class Pdf:
|
||||
"""The type of PDF documents."""
|
||||
|
||||
def loadDLL(f):
|
||||
"""Load the libpycpdf DLL from a given file, and set up pycpdflib. Must be
|
||||
called prior to using any other function in the library."""
|
||||
|
||||
class CPDFError(Exception):
|
||||
"""Any function may raise an exception CPDFError, carrying a string
|
||||
describing what went wrong"""
|
||||
describing what went wrong."""
|
||||
|
||||
def lastError():
|
||||
"""Return the last error. Not usually used directly, since pycpdflib
|
||||
|
@ -24,22 +108,22 @@ def checkerror():
|
|||
directly."""
|
||||
|
||||
def version():
|
||||
"""Returns the version number of the pycpdflib library."""
|
||||
"""Return the version number of the pycpdflib library."""
|
||||
|
||||
def setFast():
|
||||
""" Some operations have a fast mode. The default is 'slow' mode, which
|
||||
works even on old-fashioned files. For more details, see section 1.13 of
|
||||
the CPDF manual. These functions set the mode globally. """
|
||||
""" Set fast mode. Some operations have a fast mode. The default is 'slow'
|
||||
mode, which works even on old-fashioned files. For more details, see
|
||||
section 1.13 of the CPDF manual. This function sets the mode globally. """
|
||||
|
||||
def setSlow():
|
||||
""" Some operations have a fast mode. The default is 'slow' mode, which
|
||||
works even on old-fashioned files. For more details, see section 1.13 of
|
||||
the CPDF manual. These functions set the mode globally. """
|
||||
""" Set slow mode. Some operations have a fast mode. The default is 'slow'
|
||||
mode, which works even on old-fashioned files. For more details, see
|
||||
section 1.13 of the CPDF manual. This function sets the mode globally. """
|
||||
|
||||
def clearError():
|
||||
""" clearError clears the current error state. """
|
||||
""" Clear the current error state. """
|
||||
|
||||
def onExit():
|
||||
""" onExit is a debug function which prints some information about
|
||||
""" A debug function which prints some information about
|
||||
resource usage. This can be used to detect if PDFs or ranges are being
|
||||
deallocated properly."""
|
||||
|
|
179
pysplits/c02.tex
179
pysplits/c02.tex
|
@ -1,209 +1,174 @@
|
|||
# CHAPTER 1. Basics
|
||||
|
||||
def fromFile(filename, userpw):
|
||||
""" fromFile(filename, userpw) loads a PDF file from a given file.
|
||||
""" Load a PDF file from a given file.
|
||||
Supply a user password (possibly blank) in case the file is encypted. It
|
||||
won't be decrypted, but sometimes the password is needed just to load the
|
||||
file."""
|
||||
|
||||
def fromFileLazy(filename, userpw):
|
||||
""" fromFileLazy(pdf, userpw) loads a PDF from a file, doing only
|
||||
""" Loads a PDF from a file, doing only
|
||||
minimal parsing. The objects will be read and parsed when they are actually
|
||||
needed. Use this when the whole file won't be required. Also supply a user
|
||||
password (possibly blank) in case the file is encypted. It won't be
|
||||
decrypted, but sometimes the password is needed just to load the file."""
|
||||
|
||||
def fromMemory(data, userpw):
|
||||
""" fromMemory(data, length, userpw) loads a file from memory, given a
|
||||
pointer and a length, and the user password."""
|
||||
""" Load a file from a byte array and the user password (blank if none)."""
|
||||
|
||||
def fromMemoryLazy(data, userpw):
|
||||
""" fromMemoryLazy(data, length, userpw) loads a file from memory, given a
|
||||
pointer and a length, and the user password, but lazily like
|
||||
fromFileLazy."""
|
||||
""" Load a file from from a byte array and the user password (blank if
|
||||
none), but lazily like fromFileLazy."""
|
||||
|
||||
def blankDocument(w, h, pages):
|
||||
""" blankDocument(width, height, num_pages) creates a blank document
|
||||
""" Create a blank document
|
||||
with pages of the given width (in points), height (in points), and number
|
||||
of pages."""
|
||||
|
||||
"""Paper sizes."""
|
||||
a0portrait
|
||||
a1portrait
|
||||
a2portrait
|
||||
a3portrait
|
||||
a4portrait
|
||||
a5portrait
|
||||
a0landscape
|
||||
a1landscape
|
||||
a2landscape
|
||||
a3landscape
|
||||
a4landscape
|
||||
a5landscape
|
||||
usletterportrait
|
||||
usletterlandscape
|
||||
uslegalportrait
|
||||
uslegallandscape
|
||||
|
||||
def blankDocumentPaper(papersize, pages):
|
||||
"""blankDocument(width, height, num_pages) creates a blank document
|
||||
with pages of the given width (in points), height (in points), and number
|
||||
"""Create a blank document with pages of the given paper size, and number
|
||||
of pages. """
|
||||
|
||||
def ptOfCm(i):
|
||||
"""Convert a figure in centimetres to points (72 points to 1 inch)"""
|
||||
"""Convert a figure in centimetres to points (72 points to 1 inch)."""
|
||||
|
||||
def ptOfMm(i):
|
||||
"""Convert a figure in millimetres to points (72 points to 1 inch)"""
|
||||
"""Convert a figure in millimetres to points (72 points to 1 inch)."""
|
||||
|
||||
def ptOfIn(i):
|
||||
"""Convert a figure in inches to points (72 points to 1 inch)"""
|
||||
"""Convert a figure in inches to points (72 points to 1 inch)."""
|
||||
|
||||
def cmOfPt(i):
|
||||
"""Convert a figure in points to centimetres (72 points to 1 inch)"""
|
||||
"""Convert a figure in points to centimetres (72 points to 1 inch)."""
|
||||
|
||||
def mmOfPt(i):
|
||||
"""Convert a figure in points to millimetres (72 points to 1 inch)"""
|
||||
"""Convert a figure in points to millimetres (72 points to 1 inch)."""
|
||||
|
||||
def inOfPt(i):
|
||||
"""Convert a figure in points to inches (72 points to 1 inch)"""
|
||||
"""Convert a figure in points to inches (72 points to 1 inch)."""
|
||||
|
||||
def parsePagespec(pdf, pagespec):
|
||||
"""parsePagespec(pdf, pagespec) parses a page specification with reference to
|
||||
"""Parse a page specification such as "1-3,8-end" to a range with reference to
|
||||
a given PDF (the PDF is supplied so that page ranges which reference pages
|
||||
which do not exist are rejected)."""
|
||||
|
||||
def validatePagespec(pagespec):
|
||||
"""validatePagespec(range) validates a page specification so far as is
|
||||
"""Validate a page specification, returning True or False, so far as is
|
||||
possible in the absence of the actual document."""
|
||||
|
||||
def stringOfPagespec(pdf, r):
|
||||
"""stringOfPagespec(pdf, range) builds a page specification from a page
|
||||
"""Build a page specification from a page
|
||||
range. For example, the range containing 1,2,3,6,7,8 in a document of 8
|
||||
pages might yield "1-3,6-end" """
|
||||
|
||||
def blankRange():
|
||||
"""blankRange() creates a range with no pages in."""
|
||||
"""Create a range with no pages in."""
|
||||
|
||||
def pageRange(f, t):
|
||||
""" pageRange(from, to) build a range from one page to another inclusive.
|
||||
For example, pageRange(3,7) gives the range 3,4,5,6,7 """
|
||||
""" Nuild a range from one page to another inclusive.
|
||||
For example, pageRange(3,7) gives the range 3,4,5,6,7. """
|
||||
|
||||
def all(pdf):
|
||||
"""all(pdf) is the range containing all the pages in a given document."""
|
||||
"""The range containing all the pages in a given document."""
|
||||
|
||||
def even(r):
|
||||
"""even(range) makes a range which contains just the even pages of another
|
||||
range"""
|
||||
"""A range which contains just the even pages of another
|
||||
range."""
|
||||
|
||||
def odd(r):
|
||||
"""odd(range) makes a range which contains just the odd pages of another
|
||||
range"""
|
||||
"""A range which contains just the odd pages of another
|
||||
range."""
|
||||
|
||||
def rangeUnion(a, b):
|
||||
"""rangeUnion(a, b) makes the union of two ranges giving a range containing
|
||||
"""The union of two ranges giving a range containing
|
||||
the pages in range a and range b."""
|
||||
|
||||
def difference(a, b):
|
||||
"""difference(a, b) makes the difference of two ranges, giving a range
|
||||
"""The difference of two ranges, giving a range
|
||||
containing all the pages in a except for those which are also in b."""
|
||||
|
||||
def removeDuplicates(r):
|
||||
"""removeDuplicates(range) deduplicates a range, making a new one."""
|
||||
"""Deduplicates a range, returning a new one."""
|
||||
|
||||
def rangeLength(r):
|
||||
"""rangeLength gives the number of pages in a range."""
|
||||
"""The number of pages in a range."""
|
||||
|
||||
def rangeGet(r, n):
|
||||
"""rangeGet(range, n) gets the page number at position n in a range, where
|
||||
n runs from 0 to rangeLength - 1."""
|
||||
"""Get the page number at position n in a range, where
|
||||
|
||||
def rangeAdd(r, p):
|
||||
"""rangeAdd(range, page) adds the page to a range, if it is not already
|
||||
"""Add the page to a range, if it is not already
|
||||
there."""
|
||||
|
||||
def isInRange(r, p):
|
||||
"""isInRange(range, page) returns True if the page is in the range, False
|
||||
otherwise."""
|
||||
"""Returns True if the page p is in the range r, False otherwise."""
|
||||
|
||||
def pages(pdf):
|
||||
"""pages(pdf) returns the number of pages in a PDF."""
|
||||
"""Return the number of pages in a PDF."""
|
||||
r = libc.pycpdf_pages(pdf.pdf)
|
||||
checkerror()
|
||||
return r
|
||||
|
||||
def pagesFast(userpw, filename):
|
||||
"""pagesFast(password, filename) returns the number of pages in a given
|
||||
PDF, with given user encryption password. It tries to do this as fast as
|
||||
"""Return the number of pages in a given
|
||||
PDF, with given user password. It tries to do this as fast as
|
||||
possible, without loading the whole file."""
|
||||
|
||||
def toFile(pdf, filename, linearize, make_id):
|
||||
"""toFile (pdf, filename, linearize, make_id) writes the file to a given
|
||||
filename. If linearize is True, it will be linearized. If make_id is True,
|
||||
it will be given a new ID."""
|
||||
"""Write the file to a given filename. If linearize is True, it will be
|
||||
linearized, if supported by libcpdf. If make_id is True, it will be given a
|
||||
new ID."""
|
||||
|
||||
def toFileExt(pdf, filename, linearize, make_id, preserve_objstm,
|
||||
generate_objstm, compress_objstm):
|
||||
"""toFileExt (pdf, filename, linearize, make_id, preserve_objstm,
|
||||
generate_objstm, compress_objstm) writes the file to a given filename. If
|
||||
make_id is True, it will be given a new ID. If preserve_objstm is True,
|
||||
existing object streams will be preserved. If generate_objstm is True,
|
||||
object streams will be generated even if not originally present. If
|
||||
compress_objstm is True, object streams will be compressed (what we usually
|
||||
want). WARNING: the pdf argument will be invalid after this call and should
|
||||
not be used again."""
|
||||
"""Write the file to a given filename. If linearize is True, it will be
|
||||
linearized, if supported by libcpdf. If make_id is True, it will be given a
|
||||
new ID. If preserve_objstm is True, existing object streams will be
|
||||
preserved. If generate_objstm is True, object streams will be generated
|
||||
even if not originally present. If compress_objstm is True, object streams
|
||||
will be compressed (what we usually want). WARNING: the pdf argument will
|
||||
be invalid after this call and should not be used again."""
|
||||
|
||||
|
||||
def toMemory(pdf, linearize, make_id):
|
||||
"""Given a buffer of the correct size, toMemory (pdf, linearize,
|
||||
make_id) writes it and returns the buffer as a byte array of type bytes."""
|
||||
"""Write a file to memory, returning the buffer as a byte array of type
|
||||
bytes."""
|
||||
|
||||
def isEncrypted(pdf):
|
||||
"""isEncrypted(pdf) returns True if a documented is encrypted, False
|
||||
otherwise."""
|
||||
|
||||
"""Permissions."""
|
||||
noEdit
|
||||
noPrint
|
||||
noCopy
|
||||
noAnnot
|
||||
noForms
|
||||
noExtract
|
||||
noAssemble
|
||||
noHqPrint
|
||||
|
||||
"""Encryption Methods."""
|
||||
pdf40bit
|
||||
pdf128bit
|
||||
aes128bitfalse
|
||||
aes128bittrue
|
||||
aes256bitfalse
|
||||
aes256bittrue
|
||||
aes256bitisofalse
|
||||
aes256bitisotrue
|
||||
"""Returns True if a documented is encrypted, False otherwise."""
|
||||
r = libc.pycpdf_isEncrypted(pdf.pdf)
|
||||
checkerror()
|
||||
return r
|
||||
|
||||
def toFileEncrypted(pdf, method, permissions, ownerpw, userpw, linearize,
|
||||
makeid, filename):
|
||||
"""toFileEncrypted(pdf, encryption_method, permissions, permission_length,
|
||||
owner_password, user password, linearize, makeid, filename) writes a file
|
||||
as encrypted."""
|
||||
"""Write the file to a given filename encrypted with the given encryption
|
||||
method, permissions list, and owener and user passwords. If linearize is
|
||||
True, it will be linearized, if supported by libcpdf. If make_id is True,
|
||||
it will be given a new ID."""
|
||||
|
||||
def toFileEncryptedExt(pdf, method, permissions, ownerpw, userpw, linearize,
|
||||
makeid, preserve_objstm, generate_objstm,
|
||||
compress_objstm, filename):
|
||||
"""toFileEncryptedExt(pdf, encryption_method, permissions,
|
||||
permission_length, owner_password, user_password, linearize, makeid,
|
||||
preserve_objstm, generate_objstm, compress_objstm, filename) WARNING: the
|
||||
pdf argument will be invalid after this call, and should be discarded."""
|
||||
"""Write the file to a given filename encrypted with the given encryption
|
||||
method, permissions list, and owener and user passwords. If linearize is
|
||||
True, it will be linearized, if supported by libcpdf. If make_id is True,
|
||||
it will be given a new ID. If preserve_objstm is True, existing object
|
||||
streams will be preserved. If generate_objstm is True, object streams will
|
||||
be generated even if not originally present. If compress_objstm is True,
|
||||
object streams will be compressed (what we usually want). WARNING: the pdf
|
||||
argument will be invalid after this call and should not be used again."""
|
||||
|
||||
def decryptPdf(pdf, userpw):
|
||||
"""decryptPdf(pdf, userpw) attempts to decrypt a PDF using the given user
|
||||
password."""
|
||||
"""Attempts to decrypt a PDF using the given user password. An exception is
|
||||
raised in the event of a bad password."""
|
||||
|
||||
def decryptPdfOwner(pdf, ownerpw):
|
||||
"""decryptPdfOwner(pdf, ownerpw) attempts to decrypt a PDF using the given
|
||||
owner password."""
|
||||
"""Attempts to decrypt a PDF using the given owner password. An exception
|
||||
is raised in the event of a bad password."""
|
||||
|
||||
def hasPermission(pdf, perm):
|
||||
"""hasPermission(pdf, permission) returns True if the given permission
|
||||
(restriction) is present."""
|
||||
"""Returns True if the given permission (restriction) is present."""
|
||||
|
||||
def encryptionKind(pdf):
|
||||
"""encryptionMethod(pdf) return the encryption method currently in use on
|
||||
a document."""
|
||||
"""Return the encryption method currently in use on a document."""
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
# CHAPTER 2. Merging and Splitting
|
||||
|
||||
def mergeSimple(pdfs):
|
||||
"""mergeSimple(pdfs), given a list of PDFs,
|
||||
merges the files into a new one, which is returned."""
|
||||
"""Given a list of PDFs, merges the documents into a new PDF, which is
|
||||
returned."""
|
||||
|
||||
def merge(pdfs, retain_numbering, remove_duplicate_fonts):
|
||||
"""merge(pdfs, retain_numbering, remove_duplicate_fonts) merges
|
||||
the list of PDFs. If retain_numbering is True page labels are not
|
||||
"""Merges the list of PDFs. If retain_numbering is True page labels are not
|
||||
rewritten. If remove_duplicate_fonts is True, duplicate fonts are merged.
|
||||
This is useful when the source documents for merging originate from the
|
||||
same source."""
|
||||
|
||||
def mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges):
|
||||
"""mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges)
|
||||
is the same as merge, except that it has an additional argument
|
||||
- an array of page ranges. This is used to select the pages to pick from
|
||||
"""The same as merge, except that it has an additional argument
|
||||
- a list of page ranges. This is used to select the pages to pick from
|
||||
each PDF. This avoids duplication of information when multiple discrete
|
||||
parts of a source PDF are included."""
|
||||
parts of a single source PDF are included."""
|
||||
|
||||
def selectPages(pdf, r):
|
||||
""" selectPages(pdf, range) returns a new document which just those pages
|
||||
in the page range."""
|
||||
""" Returns a new document which just those pages in the page range."""
|
||||
|
|
|
@ -1,89 +1,70 @@
|
|||
# CHAPTER 3. Pages
|
||||
|
||||
def scalePages(pdf, r, sx, sy):
|
||||
"""scalePages(pdf, range, x scale, y scale) scales the page dimensions
|
||||
and content by the given scale, about (0, 0). Other boxes (crop etc. are
|
||||
altered as appropriate)"""
|
||||
"""Scale the page dimensions and content of the given range of pages by
|
||||
the given scale (sx, sy), about (0, 0). Other boxes (crop etc. are altered
|
||||
as appropriate)."""
|
||||
|
||||
def scaleToFit(pdf, r, sx, sy, scale_to_fit_scale):
|
||||
"""scaleToFit(pdf, range, width height, scale) scales the content to fit
|
||||
new page dimensions (width x height) multiplied by scale (typically 1.0).
|
||||
Other boxed (crop etc. are altered as appropriate)"""
|
||||
def scaleToFit(pdf, r, w, h, scale_to_fit_scale):
|
||||
"""Scales the pages in the range to fit new page dimensions (w and h)
|
||||
multiplied by scale_to_fit_scale (typically 1.0). Other boxes (crop etc.)
|
||||
are altered as appropriate."""
|
||||
|
||||
def scaleToFitPaper(pdf, r, papersize, scale_to_fit_scale):
|
||||
"""scaleToFitPaper(pdf, range, papersize, scale) scales the page content
|
||||
to fit the given page size, possibly multiplied by scale (typically 1.0)"""
|
||||
|
||||
"""Positions with two numbers in a tuple e.g (posLeft, 10.0, 20.0):"""
|
||||
posCentre = 0
|
||||
posLeft = 1
|
||||
posRight = 2
|
||||
"""Positions with one number in a tuple e.g (top, 5.0):"""
|
||||
top = 3
|
||||
topLeft = 4
|
||||
topRight = 5
|
||||
left = 6
|
||||
bottomLeft = 7
|
||||
bottomRight = 8
|
||||
right = 9
|
||||
"""Positions with no numbers e.g diagonal:"""
|
||||
diagonal = 10
|
||||
reverseDiagonal = 11
|
||||
"""Scales the given pages to fit the given page size, possibly multiplied
|
||||
by scale_to_fit_scale (typically 1.0)"""
|
||||
|
||||
def scaleContents(pdf, r, pos, scale):
|
||||
"""scaleContents(pdf, range, position, scale) scales the contents of the
|
||||
pages in the range about the point given by the position, by the
|
||||
scale given."""
|
||||
"""Scales the contents of the pages in the range about the point given by
|
||||
the position, by the scale given."""
|
||||
|
||||
def shiftContents(pdf, r, dx, dy):
|
||||
"""shiftContents(pdf, range, dx, dy) shifts the content of the pages in
|
||||
the range."""
|
||||
"""Shift the content of the pages in the range by (dx, dy)."""
|
||||
|
||||
def rotate(pdf, r, rotation):
|
||||
"""rotate(pdf, range, rotation) changes the viewing rotation to an
|
||||
"""Change the viewing rotation of the pages in the range to an
|
||||
absolute value. Appropriate rotations are 0, 90, 180, 270."""
|
||||
|
||||
def rotateBy(pdf, r, rotation):
|
||||
"""rotateBy(pdf, range, rotation) changes the viewing rotation by a
|
||||
"""Change the viewing rotation of the pages in the range by a
|
||||
given number of degrees. Appropriate values are 90, 180, 270."""
|
||||
|
||||
def rotateContents(pdf, r, rotation):
|
||||
"""rotateContents(pdf, range, angle) rotates the content about the centre
|
||||
"""Rotate the content about the centre
|
||||
of the page by the given number of degrees, in a clockwise direction."""
|
||||
|
||||
def upright(pdf, r):
|
||||
"""upright(pdf, range) changes the viewing rotation of the pages in the
|
||||
range, counter-rotating the dimensions and content such that there is no
|
||||
visual change."""
|
||||
"""Change the viewing rotation of the pages in the range, counter-rotating
|
||||
the dimensions and content such that there is no visual change."""
|
||||
|
||||
def hFlip(pdf, r):
|
||||
"""hFlip(pdf, range) flips horizontally the pages in the range."""
|
||||
"""Flip horizontally the pages in the range."""
|
||||
|
||||
def vFlip(pdf, r):
|
||||
"""vFlip(pdf, range) flips vertically the pages in the range."""
|
||||
"""Flip vertically the pages in the range."""
|
||||
|
||||
def crop(pdf, r, x, y, w, h):
|
||||
"""crop(pdf, range, x, y, w, h) crops a page, replacing any existing
|
||||
crop box. The dimensions are in points."""
|
||||
"""Crop a page to the box defined by (x, y, w, h), replacing any existing
|
||||
crop box."""
|
||||
|
||||
def removeCrop(pdf, r):
|
||||
"""removeCrop(pdf, range) removes any crop box from pages in the range."""
|
||||
"""Remove any crop box from pages in the range."""
|
||||
|
||||
def removeTrim(pdf, r):
|
||||
"""removeTrim(pdf, range) removes any crop box from pages in the range."""
|
||||
"""Remove any trim box from pages in the range."""
|
||||
|
||||
def removeArt(pdf, r):
|
||||
"""removeArt(pdf, range) removes any crop box from pages in the range."""
|
||||
"""Remove any art box from pages in the range."""
|
||||
|
||||
def removeBleed(pdf, r):
|
||||
"""removeBleed(pdf, range) removes any crop box from pages in the range."""
|
||||
"""Remove any bleed box from pages in the range."""
|
||||
|
||||
def trimMarks(pdf, r):
|
||||
"""trimMarks(pdf, range) adds trim marks to the given pages, if the trimbox
|
||||
exists."""
|
||||
"""Add trim marks to the given pages, if the trimbox exists."""
|
||||
|
||||
def showBoxes(pdf, r):
|
||||
"""showBoxes(pdf, range) shows the boxes on the given pages, for debug."""
|
||||
"""Show the boxes on the given pages, for debug."""
|
||||
|
||||
def hardBox(pdf, r, boxname):
|
||||
"""hardBox make a given box a 'hard box' i.e clips it explicitly."""
|
||||
"""Make a given box a 'hard box' i.e clip it explicitly. Boxname could be,
|
||||
for example "/TrimBox"."""
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
# CHAPTER 5. Compression
|
||||
|
||||
def compress(pdf):
|
||||
"""compress(pdf) compresses any uncompressed streams in the given PDF
|
||||
using the Flate algorithm."""
|
||||
"""Compress any uncompressed streams in the given PDF using the Flate
|
||||
algorithm."""
|
||||
|
||||
def decompress(pdf):
|
||||
"""uncompress(pdf) uncompresses any streams in the given PDF, so long as
|
||||
the compression method is supported."""
|
||||
"""Decompress any streams in the given PDF, so long as the compression
|
||||
method is supported."""
|
||||
|
||||
def squeezeInMemory(pdf):
|
||||
"""squeezeToMemory(pdf) squeezes a pdf in memory."""
|
||||
"""squeezeToMemory(pdf) squeezes a pdf in memory. Squeezing is a lossless
|
||||
compression method which works be rearrangement of a PDFs internal
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# CHAPTER 6. Bookmarks
|
||||
|
||||
def getBookmarks(pdf):
|
||||
"""Get the bookmarks for a PDF as a list of tuples.
|
||||
"""Get the bookmarks for a PDF as a list of tuples of the form:
|
||||
(level : int, page : int, text : string, openstatus : bool)"""
|
||||
|
||||
def setBookmarks(pdf, marks):
|
||||
"""Set the bookmarks for a PDF as a list of tuples.
|
||||
"""Set the bookmarks for a PDF as a list of tuples of the form:
|
||||
(level : int, page : int, text : string, openstatus : bool)"""
|
||||
|
|
|
@ -1,47 +1,25 @@
|
|||
# CHAPTER 8. Logos, Watermarks and Stamps
|
||||
|
||||
def stampOn(pdf, pdf2, r):
|
||||
"""stampOn(stamp_pdf, pdf, range) stamps stamp_pdf on top of all the
|
||||
pages in the document which are in the range. The stamp is placed with its
|
||||
origin at the origin of the target document."""
|
||||
"""Stamps pdf on top of all the pages in pdf2 which are in the range. The
|
||||
stamp is placed with its origin at the origin of the target document."""
|
||||
|
||||
def stampUnder(pdf, pdf2, r):
|
||||
"""stampUnder(stamp_pdf, pdf, range) stamps stamp_pdf under all the pages
|
||||
in the document which are in the range. The stamp is placed with its origin
|
||||
at the origin of the target document."""
|
||||
"""Stamps pdf under under all the pages in pdf2 which are in the range. The
|
||||
stamp is placed with its origin at the origin of the target document."""
|
||||
|
||||
def stampExtended(pdf, pdf2, r, isover, scale_stamp_to_fit, pos,
|
||||
relative_to_cropbox):
|
||||
"""stampExtended(pdf, pdf2, range, isover, scale_stamp_to_fit, pos,
|
||||
relative_to_cropbox) is a stamping function with extra features.
|
||||
"""A stamping function with extra features:
|
||||
|
||||
- isover True, pdf goes over pdf2, isover False, pdf goes under pdf2
|
||||
- scale_stamp_to_fit scales the stamp to fit the page
|
||||
- pos gives the position to put the stamp
|
||||
- relative_to_cropbox: if True, pos is relative to cropbox not mediabox"""
|
||||
- relative_to_cropbox: if True, pos is relative to crop box not media box"""
|
||||
|
||||
def combinePages(pdf, pdf2):
|
||||
"""combinePages(under, over) combines the PDFs page-by-page, putting
|
||||
each page of 'over' over each page of 'under'"""
|
||||
|
||||
"""Fonts."""
|
||||
timesRoman
|
||||
timesBold
|
||||
timesItalic
|
||||
timesBoldItalic
|
||||
helvetica
|
||||
helveticaBold
|
||||
helveticaOblique
|
||||
helveticaBoldOblique
|
||||
courier
|
||||
courierBold
|
||||
courierOblique
|
||||
courierBoldOblique
|
||||
|
||||
"""Jusitifications."""
|
||||
leftJustify
|
||||
centreJustify
|
||||
rightJustify
|
||||
|
||||
"""Combines the PDFs page-by-page, putting each page of pdf2 over each page
|
||||
of pdf."""
|
||||
|
||||
def addText(metrics, pdf, r, text, p, line_spacing, bates, font, size, red,
|
||||
green, blue, underneath, relative_to_cropbox, outline, opacity,
|
||||
|
@ -105,26 +83,28 @@ def addText(metrics, pdf, r, text, p, line_spacing, bates, font, size, red,
|
|||
|
||||
def addTextSimple(pdf, r, text, p, font, size):
|
||||
"""like addText, but with most parameters default
|
||||
|
||||
* pdf = the document
|
||||
* r = the range
|
||||
* text = the text
|
||||
* p = the position
|
||||
* font = the font
|
||||
* size = the font size"""
|
||||
|
||||
def removeText(pdf, r):
|
||||
"""removeText(pdf, range) will remove any text added by libcpdf from the
|
||||
given pages."""
|
||||
"""Remove any text added by libcpdf from the given pages."""
|
||||
r = range_of_list(r)
|
||||
|
||||
def textWidth(font, string):
|
||||
"""Return the width of a given string in the given font in thousandths of a
|
||||
point."""
|
||||
|
||||
def addContent(content, before, pdf, r):
|
||||
"""addContent(content, before, range, pdf) adds page content before (if
|
||||
True) or after (if False) the existing content to pages in the given range
|
||||
in the given PDF."""
|
||||
"""Add page content before (if True) or after (if False) the existing
|
||||
content to pages in the given range in the given PDF. Warning: this a low
|
||||
level function requiring understanding of the PDF format."""
|
||||
|
||||
def stampAsXObject(pdf, r, stamp_pdf):
|
||||
"""stampAsXObject(pdf, range, stamp_pdf) stamps stamp_pdf onto the pages
|
||||
in the given range in pdf as a shared Form XObject. The name of the
|
||||
newly-created XObject is returned."""
|
||||
"""Stamps stamp_pdf onto the pages in the given range in pdf as a shared
|
||||
Form XObject. The name of the newly-created XObject is returned, for use
|
||||
with addContent. """
|
||||
|
|
|
@ -1,30 +1,26 @@
|
|||
# CHAPTER 9. Mulitpage facilities
|
||||
|
||||
def twoUp(pdf):
|
||||
"""Impose a document two up. twoUp does so by retaining the existing page
|
||||
size, scaling pages down. twoUpStack does so by doubling the page size,
|
||||
to fit two pages on one."""
|
||||
"""Impose a document two up by retaining the existing page
|
||||
size, scaling pages down."""
|
||||
|
||||
def twoUpStack(pdf):
|
||||
"""Impose a document two up. twoUp does so by retaining the existing page
|
||||
size, scaling pages down. twoUpStack does so by doubling the page size,
|
||||
"""Impose a document two up by doubling the page size,
|
||||
to fit two pages on one."""
|
||||
|
||||
def padBefore(pdf, r):
|
||||
"""padBefore(pdf, range) adds a blank page before each page in the given
|
||||
range"""
|
||||
"""Adds a blank page before each page in the given range."""
|
||||
|
||||
def padAfter(pdf, r):
|
||||
"""padAfter(pdf, range) adds a blank page after each page in the given
|
||||
range"""
|
||||
"""Adds a blank page after each page in the given range."""
|
||||
|
||||
def padEvery(pdf, n):
|
||||
"""pageEvery(pdf, n) adds a blank page after every n pages"""
|
||||
"""Adds a blank page after every n pages."""
|
||||
|
||||
def padMultiple(pdf, n):
|
||||
"""padMultiple(pdf, n) adds pages at the end to pad the file to a multiple
|
||||
of n pages in length."""
|
||||
"""Adds pages at the end to pad the file to a multiple of n pages in
|
||||
length."""
|
||||
|
||||
def padMultipleBefore(pdf, n):
|
||||
"""padMultiple(pdf, n) adds pages at the beginning to pad the file to a
|
||||
"""Adds pages at the beginning to pad the file to a
|
||||
multiple of n pages in length."""
|
||||
|
|
219
pysplits/c12.tex
219
pysplits/c12.tex
|
@ -1,298 +1,265 @@
|
|||
# CHAPTER 11. Document Information and Metadata
|
||||
|
||||
def isLinearized(filename):
|
||||
"""isLinearized(filename) finds out if a document is linearized as quickly
|
||||
"""Finds out if a document is linearized as quickly
|
||||
as possible without loading it."""
|
||||
|
||||
def getVersion(pdf):
|
||||
"""vetVersion(pdf) returns the minor version number of a document."""
|
||||
"""Return the minor version number of a document."""
|
||||
|
||||
def getMajorVersion(pdf):
|
||||
"""getMajorVersion(pdf) returns the minor version number of a document."""
|
||||
"""Return the minor version number of a document."""
|
||||
|
||||
def getTitle(pdf):
|
||||
"""getTitle(pdf) returns the title of a document."""
|
||||
"""Return the title of a document."""
|
||||
|
||||
def getAuthor(pdf):
|
||||
"""getSubject(pdf) returns the subject of a document."""
|
||||
"""Return the subject of a document."""
|
||||
|
||||
def getSubject(pdf):
|
||||
"""getSubject(pdf) returns the subject of a document."""
|
||||
"""Return the subject of a document."""
|
||||
|
||||
def getKeywords(pdf):
|
||||
"""getKeywords(pdf) returns the keywords of a document."""
|
||||
"""Return the keywords of a document."""
|
||||
|
||||
def getCreator(pdf):
|
||||
"""getCreator(pdf) returns the creator of a document."""
|
||||
"""Return the creator of a document."""
|
||||
|
||||
def getProducer(pdf):
|
||||
"""getProducer(pdf) returns the producer of a document."""
|
||||
"""Return the producer of a document."""
|
||||
|
||||
def getCreationDate(pdf):
|
||||
"""getCreationDate(pdf) returns the creation date of a document."""
|
||||
"""Return the creation date of a document."""
|
||||
|
||||
def getModificationDate(pdf):
|
||||
"""getModificationDate(pdf) returns the modification date of a document."""
|
||||
"""Return the modification date of a document."""
|
||||
|
||||
def getTitleXMP(pdf):
|
||||
"""getTitleXMP(pdf) returns the XMP title of a document."""
|
||||
"""Return the XMP title of a document."""
|
||||
|
||||
def getAuthorXMP(pdf):
|
||||
"""getAuthorXMP(pdf) returns the XMP author of a document."""
|
||||
"""Return the XMP author of a document."""
|
||||
|
||||
def getSubjectXMP(pdf):
|
||||
"""getSubjectXMP(pdf) returns the XMP subject of a document."""
|
||||
"""Return the XMP subject of a document."""
|
||||
|
||||
def getKeywordsXMP(pdf):
|
||||
"""getKeywordsXMP(pdf) returns the XMP keywords of a document."""
|
||||
"""Return the XMP keywords of a document."""
|
||||
|
||||
def getCreatorXMP(pdf):
|
||||
"""getCreatorXMP(pdf) returns the XMP creator of a document."""
|
||||
"""Returs the XMP creator of a document."""
|
||||
|
||||
def getProducerXMP(pdf):
|
||||
"""getProducerXMP(pdf) returns the XMP producer of a document."""
|
||||
"""Return the XMP producer of a document."""
|
||||
|
||||
def getCreationDateXMP(pdf):
|
||||
"""getCreationDateXMP(pdf) returns the XMP creation date of a document."""
|
||||
"""Return the XMP creation date of a document."""
|
||||
|
||||
def getModificationDateXMP(pdf):
|
||||
"""getModificationDateXMP(pdf) returns the XMP modification date of a
|
||||
document."""
|
||||
"""Return the XMP modification date of a document."""
|
||||
|
||||
def setTitle(pdf, s):
|
||||
"""setTitle(pdf) sets the title of a document."""
|
||||
"""Set the title of a document."""
|
||||
|
||||
def setAuthor(pdf, s):
|
||||
"""setAuthor(pdf) sets the author of a document."""
|
||||
"""Set the author of a document."""
|
||||
|
||||
def setSubject(pdf, s):
|
||||
"""setSubject(pdf) sets the subject of a document."""
|
||||
"""Set the subject of a document."""
|
||||
|
||||
def setKeywords(pdf, s):
|
||||
"""setKeywords(pdf) sets the keywords of a document."""
|
||||
"""Set the keywords of a document."""
|
||||
|
||||
def setCreator(pdf, s):
|
||||
"""setCreator(pdf) sets the creator of a document."""
|
||||
"""Set the creator of a document."""
|
||||
|
||||
def setProducer(pdf, s):
|
||||
"""setProducer(pdf) sets the producer of a document."""
|
||||
"""Set the producer of a document."""
|
||||
|
||||
def setCreationDate(pdf, s):
|
||||
"""setCreationDate(pdf) sets the creation date of a document."""
|
||||
"""Set the creation date of a document."""
|
||||
|
||||
def setModificationDate(pdf, s):
|
||||
"""setModificationDate(pdf) sets the modifcation date of a document."""
|
||||
"""Set the modifcation date of a document."""
|
||||
|
||||
def setTitleXMP(pdf, s):
|
||||
"""setTitleXMP(pdf) set the XMP title of a document."""
|
||||
"""Set the XMP title of a document."""
|
||||
|
||||
def setAuthorXMP(pdf, s):
|
||||
"""setAuthorXMP(pdf) set the XMP author of a document."""
|
||||
"""Set the XMP author of a document."""
|
||||
|
||||
def setSubjectXMP(pdf, s):
|
||||
"""setSubjectXMP(pdf) set the XMP subject of a document."""
|
||||
"""Set the XMP subject of a document."""
|
||||
|
||||
def setKeywordsXMP(pdf, s):
|
||||
"""setKeywordsXMP(pdf) set the XMP keywords of a document."""
|
||||
"""Set the XMP keywords of a document."""
|
||||
|
||||
def setCreatorXMP(pdf, s):
|
||||
"""setCreatorXMP(pdf) set the XMP creator of a document."""
|
||||
"""Set the XMP creator of a document."""
|
||||
|
||||
def setProducerXMP(pdf, s):
|
||||
"""setProducerXMP(pdf) set the XMP producer of a document."""
|
||||
"""Set the XMP producer of a document."""
|
||||
|
||||
def setCreationDateXMP(pdf, s):
|
||||
"""setCreationDateXMP(pdf) set the XMP creation date of a document."""
|
||||
"""Set the XMP creation date of a document."""
|
||||
|
||||
def setModificationDateXMP(pdf, s):
|
||||
"""setModificationDateXMP(pdf) set the XMP modification date of a
|
||||
document."""
|
||||
"""Set the XMP modification date of a document."""
|
||||
|
||||
def getDateComponents(string):
|
||||
"""Dates: Month 1-31, day 1-31, hours (0-23), minutes (0-59), seconds
|
||||
(0-59), hour_offset is the offset from UT in hours (-23 to 23);
|
||||
minute_offset is the offset from UT in minutes (-59 to 59).
|
||||
"""Return the components (year, month, day, hour, minute, second,
|
||||
hour_offset, minute_offset) from a PDF date string.
|
||||
|
||||
getDateComponents(datestring, year, month, day, hour, minute, second,
|
||||
hour_offset, minute_offset) returns the components from a PDF date
|
||||
string."""
|
||||
Month 1-31, day 1-31, hours (0-23), minutes (0-59), seconds
|
||||
(0-59), hour_offset is the offset from UT in hours (-23 to 23);
|
||||
minute_offset is the offset from UT in minutes (-59 to 59)."""
|
||||
|
||||
def dateStringOfComponents(cs):
|
||||
"""Dates: Month 1-31, day 1-31, hours (0-23), minutes (0-59), seconds
|
||||
"""Build a PDF date string a (year, month, day, hour, minute, second,
|
||||
hour_offset, minute_offset) tuple.
|
||||
|
||||
Dates: Month 1-31, day 1-31, hours (0-23), minutes (0-59), seconds
|
||||
(0-59), hour_offset is the offset from UT in hours (-23 to 23);
|
||||
minute_offset is the offset from UT in minutes (-59 to 59).
|
||||
|
||||
dateStringOfComponents(year, month, day, hour, minute, second,
|
||||
hour_offset, minute_offset) builds a PDF date string from individual
|
||||
components."""
|
||||
minute_offset is the offset from UT in minutes (-59 to 59)."""
|
||||
|
||||
def getPageRotation(pdf, pagenumber):
|
||||
"""getPageRotation(pdf, pagenumber) gets the viewing rotation for a given
|
||||
page."""
|
||||
"""Get the viewing rotation for a given page."""
|
||||
|
||||
def hasBox(pdf, pagenumber, boxname):
|
||||
"""hasBox(pdf, pagenumber, boxname) returns True, if that page has the
|
||||
given box. E.g "/CropBox" """
|
||||
"""Returns True, if the page has the given box. E.g "/CropBox" """
|
||||
|
||||
def getMediaBox(pdf, pagenumber):
|
||||
"""These functions get a box given the document, page range, min x, max x,
|
||||
"""Get a mediabox box given the document, page range, min x, max x,
|
||||
min y, max y in points. Only suceeds if such a box exists, as checked by
|
||||
hasBox"""
|
||||
|
||||
def getCropBox(pdf, pagenumber):
|
||||
"""These functions get a box given the document, page range, min x, max x,
|
||||
"""Get a crop box given the document, page range, min x, max x,
|
||||
min y, max y in points. Only suceeds if such a box exists, as checked by
|
||||
hasBox"""
|
||||
|
||||
def getTrimBox(pdf, pagenumber):
|
||||
"""These functions get a box given the document, page range, min x, max x,
|
||||
"""Get a trim box given the document, page range, min x, max x,
|
||||
min y, max y in points. Only suceeds if such a box exists, as checked by
|
||||
hasBox"""
|
||||
|
||||
def getArtBox(pdf, pagenumber):
|
||||
"""These functions get a box given the document, page range, min x, max x,
|
||||
"""Get an art box given the document, page range, min x, max x,
|
||||
min y, max y in points. Only suceeds if such a box exists, as checked by
|
||||
hasBox"""
|
||||
|
||||
def getBleedBox(pdf, pagenumber):
|
||||
"""These functions get a box given the document, page range, min x, max x,
|
||||
"""Get a bleed box given the document, page range, min x, max x,
|
||||
min y, max y in points. Only suceeds if such a box exists, as checked by
|
||||
hasBox"""
|
||||
|
||||
def setMediaBox(pdf, r, minx, maxx, miny, maxy):
|
||||
"""These functions set a box given the document, page range, min x, max x,
|
||||
"""Set the media box given the document, page range, min x, max x,
|
||||
min y, max y in points."""
|
||||
|
||||
def setCropBox(pdf, r, minx, maxx, miny, maxy):
|
||||
"""These functions set a box given the document, page range, min x, max x,
|
||||
"""Set the crop box given the document, page range, min x, max x,
|
||||
min y, max y in points."""
|
||||
|
||||
def setTrimBox(pdf, r, minx, maxx, miny, maxy):
|
||||
"""These functions set a box given the document, page range, min x, max x,
|
||||
"""Set the trim box given the document, page range, min x, max x,
|
||||
min y, max y in points."""
|
||||
|
||||
def setArtBox(pdf, r, minx, maxx, miny, maxy):
|
||||
"""These functions set a box given the document, page range, min x, max x,
|
||||
"""Set the art box given the document, page range, min x, max x,
|
||||
min y, max y in points."""
|
||||
|
||||
def setBleedBox(pdf, r, minx, maxx, miny, maxy):
|
||||
"""These functions set a box given the document, page range, min x, max x,
|
||||
"""Set the bleed box given the document, page range, min x, max x,
|
||||
min y, max y in points."""
|
||||
|
||||
def markTrapped(pdf):
|
||||
"""markTrapped(pdf) marks a document as trapped."""
|
||||
"""Mark a document as trapped."""
|
||||
|
||||
def markUntrapped(pdf):
|
||||
"""markUntrapped(pdf) marks a document as untrapped."""
|
||||
"""Mark a document as untrapped."""
|
||||
|
||||
def markTrappedXMP(pdf):
|
||||
"""markTrappedXMP(pdf) marks a document as trapped in XMP metadata."""
|
||||
"""Mark a document as trapped in XMP metadata."""
|
||||
|
||||
def markUntrappedXMP(pdf):
|
||||
"""markUntrappedXMP(pdf) marks a document as untrapped in XMP metadata."""
|
||||
|
||||
"""Page layouts."""
|
||||
singlePage
|
||||
oneColumn
|
||||
twoColumnLeft
|
||||
twoColumnRight
|
||||
twoPageLeft
|
||||
twoPageRight
|
||||
"""Mark a document as untrapped in XMP metadata."""
|
||||
|
||||
def setPageLayout(pdf, layout):
|
||||
"""setPageLayout(pdf, layout) sets the page layout for a document."""
|
||||
|
||||
"""Page modes."""
|
||||
useNone
|
||||
useOutlines
|
||||
useThumbs
|
||||
useOC
|
||||
useAttachments
|
||||
|
||||
"""Set the page layout for a document."""
|
||||
|
||||
def setPageMode(pdf, mode):
|
||||
"""setPageMode(pdf, mode) sets the page mode for a document."""
|
||||
"""Set the page mode for a document."""
|
||||
|
||||
def hideToolbar(pdf, flag):
|
||||
"""hideToolbar(pdf, flag) sets the hide toolbar flag"""
|
||||
"""Sets the hide toolbar flag."""
|
||||
|
||||
def hideMenubar(pdf, flag):
|
||||
"""hideMenubar(pdf, flag) sets the hide menu bar flag"""
|
||||
"""Set the hide menu bar flag."""
|
||||
|
||||
def hideWindowUi(pdf, flag):
|
||||
"""hideWindowUi(pdf, flag) sets the hide window UI flag"""
|
||||
"""Set the hide window UI flag."""
|
||||
|
||||
def fitWindow(pdf, flag):
|
||||
"""fitWindow(pdf, flag) sets the fit window flag"""
|
||||
"""Set the fit window flag."""
|
||||
|
||||
def centerWindow(pdf, flag):
|
||||
"""centerWindow(pdf, flag) sets the center window flag"""
|
||||
"""Set the center window flag."""
|
||||
|
||||
def displayDocTitle(pdf, flag):
|
||||
"""displayDocTitle(pdf, flag) sets the display doc title flag"""
|
||||
"""Set the display document title flag."""
|
||||
|
||||
def openAtPage(pdf, flag, pagenumber):
|
||||
"""openAtPage(pdf, fit, pagenumber)"""
|
||||
def openAtPage(pdf, fitflag, pagenumber):
|
||||
"""Set the PDF to open, possibly with zoom-to-fit, at the given page
|
||||
number. """
|
||||
|
||||
def setMetadataFromFile(pdf, filename):
|
||||
"""setMetadataFromFile(pdf, filename) set the XMP metadata of a document,
|
||||
given a file name."""
|
||||
"""Set the XMP metadata of a document, given a file name."""
|
||||
|
||||
def setMetadataFromByteArray(pdf, data):
|
||||
"""setMetadataFromByteArray(pdf, data, length) set the XMP metadata from
|
||||
an array of bytes."""
|
||||
"""Set the XMP metadata from an array of bytes."""
|
||||
|
||||
def getMetadata(pdf):
|
||||
"""getMetadata(pdf, &length) returns the XMP metadata as a byte array of
|
||||
type bytes"""
|
||||
"""Return the XMP metadata as a byte array of type bytes"""
|
||||
|
||||
def removeMetadata(pdf):
|
||||
"""removeMetadata(pdf) removes the XMP metadata from a document"""
|
||||
"""Remove the XMP metadata from a document"""
|
||||
|
||||
def createMetadata(pdf):
|
||||
"""createMetadata(pdf) builds fresh metadata as best it can from existing
|
||||
"""Builds fresh XMP metadata as good as possible from existing
|
||||
metadata in the document."""
|
||||
|
||||
def setMetadataDate(pdf, date):
|
||||
"""setMetadataDate(pdf, date) sets the metadata date for a PDF. The date
|
||||
is given in PDF date format -- cpdf will convert it to XMP format. The date
|
||||
'now' means now."""
|
||||
|
||||
"""Label styles."""
|
||||
decimalArabic
|
||||
uppercaseRoman
|
||||
lowercaseRoman
|
||||
uppercaseLetters
|
||||
lowercaseLetters
|
||||
|
||||
"""Set the metadata date for a PDF. The date is given in PDF date format --
|
||||
cpdf will convert it to XMP format. The date 'now' means now."""
|
||||
|
||||
def getPageLabels(pdf):
|
||||
"""Get page labels as a list of tuples (style, prefix, offset, startvalue)
|
||||
|
||||
For example, a document might have five pages of introduction with roman
|
||||
numerals, followed by the rest of the pages in decimal arabic, numbered
|
||||
from one:
|
||||
from one. First label:
|
||||
|
||||
labelstyle = LowercaseRoman
|
||||
labelprefix = ""
|
||||
startpage = 1
|
||||
startvalue = 1
|
||||
* labelstyle = LowercaseRoman
|
||||
* labelprefix = ""
|
||||
* startpage = 1
|
||||
* startvalue = 1
|
||||
|
||||
labelstyle = DecimalArabic
|
||||
labelprefix = ""
|
||||
startpage = 6
|
||||
startvalue = 1 """
|
||||
Second label:
|
||||
|
||||
* labelstyle = DecimalArabic
|
||||
* labelprefix = ""
|
||||
* startpage = 6
|
||||
* startvalue = 1 """
|
||||
|
||||
def addPageLabels(pdf, label, progress):
|
||||
"""Add page labels.
|
||||
|
||||
addPageLabels(pdf, style, prefix, offset, range, progress)
|
||||
"""Add one group of page labels from a tuple (style, prefix, offset, range).
|
||||
|
||||
The prefix is prefix text for each label. The range is the page range the
|
||||
labels apply to. Offset can be used to shift the numbering up or down."""
|
||||
|
||||
def removePageLabels(pdf):
|
||||
"""removePageLabels(pdf) removes the page labels from the document."""
|
||||
"""Removes all page labels from the document."""
|
||||
|
||||
def getPageLabelStringForPage(pdf, pagenumber):
|
||||
"""getPageLabelStringForPage(pdf, page number) calculates the full label
|
||||
"""Calculate the full label string for a given page, and return it."""
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
# CHAPTER 12. File Attachments
|
||||
|
||||
def attachFile(filename, pdf):
|
||||
"""attachFile(filename, pdf) attaches a file to the pdf. It is attached at
|
||||
document level."""
|
||||
"""Attach a file to the pdf. It is attached at document level."""
|
||||
|
||||
def attachFileToPage(filename, pdf, pagenumber):
|
||||
"""attachFileToPage(filename, pdf, pagenumber) attaches a file, given its
|
||||
file name, pdf, and the page number to which it should be attached."""
|
||||
"""Attach a file, given its file name, pdf, and the page number to which
|
||||
it should be attached."""
|
||||
|
||||
def attachFileFromMemory(data, filename, pdf):
|
||||
"""attachFileFromMemory(memory, length, filename, pdf) attaches from
|
||||
memory, just like attachFile."""
|
||||
"""Attach a file from a byte array. It is attached at document level."""
|
||||
|
||||
def attachFileToPageFromMemory(data, filename, pdf, pagenumber):
|
||||
"""attachFileToPageFromMemory(memory, length, filename, pdf, pagenumber)
|
||||
attaches from memory, just like attachFileToPage."""
|
||||
"""Attach a file to a given pag from a byte array. It is attached at
|
||||
document level."""
|
||||
|
||||
def removeAttachedFiles(pdf):
|
||||
"""Remove all page- and document-level attachments from a document"""
|
||||
"""Remove all page- and document-level attachments from a document."""
|
||||
|
||||
def getAttachments(pdf):
|
||||
"""List information about attachements. Returns a list of tuples
|
||||
(name, page number, byte array of data)"""
|
||||
(name, page number, byte array of data). Page 0 = document-level
|
||||
attachment."""
|
||||
|
|
|
@ -5,9 +5,8 @@ def getFontInfo(pdf):
|
|||
showing each font used on each page."""
|
||||
|
||||
def removeFonts(pdf):
|
||||
"""removeFonts(pdf) removes all font data from a file."""
|
||||
"""Remove all font data from a file."""
|
||||
|
||||
def copyFont(pdf, pdf2, r, pagenumber, fontname):
|
||||
"""copyFont(from, to, range, pagenumber, fontname) copies the given font
|
||||
from the given page in the 'from' PDF to every page in the 'to' PDF. The
|
||||
new font is stored under it's font name."""
|
||||
"""Copy the given font from the given page in the pdf PDF to every page in
|
||||
the pdf2 PDF. The new font is stored under its font name."""
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# CHAPTER 15. PDF and JSON
|
||||
|
||||
def outputJSON(filename, parse_content, no_stream_data, pdf):
|
||||
"""outputJSON(filename, parse_content, no_stream_data, pdf) outputs a PDF
|
||||
in JSON format to the given filename. If parse_content is True, page
|
||||
content is parsed. If no_stream_data is True, all stream data is suppressed
|
||||
entirely."""
|
||||
"""Output a PDF in JSON format to the given filename. If parse_content is
|
||||
True, page content is parsed. If no_stream_data is True, all stream data is
|
||||
suppressed entirely."""
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# CHAPTER 16. Optional Content Groups
|
||||
|
||||
def getOCGList(pdf):
|
||||
"""Return a list of Optional Content Groups in the given pdf."""
|
||||
"""Return a list of Optional Content Groups in the given pdf as strings."""
|
||||
|
||||
def OCGRename(pdf, n_from, n_to):
|
||||
"""OCGRename(pdf, n_from, n_to) will rename an optional content group."""
|
||||
"""Rename an optional content group."""
|
||||
|
||||
def OCGOrderAll(pdf):
|
||||
"""Ensure that every optional content group appears in the OCG order list."""
|
||||
|
|
|
@ -1,43 +1,41 @@
|
|||
# CHAPTER 17. Miscellaneous
|
||||
|
||||
def draft(pdf, r, boxes):
|
||||
"""draft(pdf, range, boxes) removes images on the given pages, replacing
|
||||
them with crossed boxes if 'boxes' is true"""
|
||||
"""Remove images on the given pages, replacing
|
||||
them with crossed boxes if 'boxes' is True."""
|
||||
|
||||
def removeAllText(pdf, r):
|
||||
"""removeAllText(pdf, range) removes all text from the given pages in a
|
||||
given document."""
|
||||
"""Remove all text from the given pages in a document."""
|
||||
|
||||
def blackText(pdf, r):
|
||||
"""blackText(pdf, range) blackens all text on the given pages."""
|
||||
"""Blacken all text on the given pages."""
|
||||
|
||||
def blackLines(pdf, r):
|
||||
"""blackLines(pdf, range) blackens all lines on the given pages."""
|
||||
"""Blacken all lines on the given pages."""
|
||||
|
||||
def blackFills(pdf, r):
|
||||
"""blackFills(pdf, range) blackens all fills on the given pages."""
|
||||
"""Blacken all fills on the given pages."""
|
||||
|
||||
def thinLines(pdf, r, linewidth):
|
||||
"""thinLines(pdf, range, min_thickness) thickens every line less than
|
||||
min_thickness to min_thickness. Thickness given in points."""
|
||||
"""Thicken every line less than
|
||||
linewidth to linewidth. Thickness given in points."""
|
||||
|
||||
def copyId(pdf, pdf2):
|
||||
"""copyId(from, to) copies the /ID from one document to another."""
|
||||
"""Copy the /ID from one pdf to pdf2."""
|
||||
|
||||
def removeId(pdf):
|
||||
"""removeId(pdf) removes a document's /ID"""
|
||||
"""Remove a document's /ID"""
|
||||
|
||||
def setVersion(pdf, version):
|
||||
"""setVersion(pdf, version) sets the minor version number of a document."""
|
||||
"""Set the minor version number of a document."""
|
||||
|
||||
def setFullVersion(pdf, major, minor):
|
||||
"""setFullVersion(pdf, version) sets the major and minor version number of
|
||||
"""Set the major and minor version number of
|
||||
a document."""
|
||||
|
||||
def removeDictEntry(pdf, key):
|
||||
"""removeDictEntry(pdf, key) removes any dictionary entry with the given
|
||||
key anywhere in the document"""
|
||||
"""Remove any dictionary entry with the given
|
||||
key anywhere in the document."""
|
||||
|
||||
def removeClipping(pdf, r):
|
||||
"""removeClipping(pdf, range) removes all clipping from pages in the given
|
||||
range"""
|
||||
"""Remove all clipping from pages in the given range"""
|
||||
|
|
Loading…
Reference in New Issue