Finishing python comments

This commit is contained in:
John Whitington
2021-09-01 19:41:10 +02:00
parent 301346f23b
commit 0965d8ee54
18 changed files with 371 additions and 406 deletions

View File

@@ -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."""