2022-05-18 18:47:31 +02:00
|
|
|
// CHAPTER 11. Document Information and Metadata
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Finds out if a document is linearized as quickly as possible without
|
|
|
|
loading it. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function isLinearized(filename)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the minor version number of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getVersion(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the major version number of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getMajorVersion(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the title of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getTitle(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the author of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getAuthor(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the subject of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getSubject(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the keywords of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getKeywords(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the creator of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getCreator(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the producer of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getProducer(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the creation date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getCreationDate(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the modification date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getModificationDate(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP title of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getTitleXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP author of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getAuthorXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP subject of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getSubjectXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP keywords of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getKeywordsXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP creator of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getCreatorXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP producer of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getProducerXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP creation date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getCreationDateXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP modification date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getModificationDateXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the title of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setTitle(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the author of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setAuthor(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the subject of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setSubject(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the keywords of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setKeywords(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the creator of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setCreator(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the producer of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setProducer(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the creation date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setCreationDate(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the modification date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setModificationDate(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP title of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setTitleXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP author of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setAuthorXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Sets the XMP author of a document. */
|
|
|
|
function setSubjectXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP keywords of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setKeywordsXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP creator of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setCreatorXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP producer of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setProducerXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP creation date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setCreationDateXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP modification date of a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setModificationDateXMP(pdf, s)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Returns the components from a PDF date string. */
|
|
|
|
function getDateComponents(string)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Builds a PDF date string from individual components. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function dateStringOfComponents(y, m, d, h, min, sec, hour_offset, minute_offset)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Gets the viewing rotation for a given page. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getPageRotation(pdf, page)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Returns true, if that page has the given box. E.g "/CropBox". */
|
|
|
|
function hasBox(pdf, page, box)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions get a box given the document, page number, min x, max x,
|
|
|
|
min y, max y in points. Only succeeds if such a box exists, as checked by
|
|
|
|
hasBox. */
|
|
|
|
function getMediaBox(pdf, pagenumber)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions get a box given the document, page number, min x, max x,
|
|
|
|
min y, max y in points. Only succeeds if such a box exists, as checked by
|
|
|
|
hasBox. */
|
|
|
|
function getCropBox(pdf, pagenumber)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions get a box given the document, page number, min x, max x,
|
|
|
|
min y, max y in points. Only succeeds if such a box exists, as checked by
|
|
|
|
hasBox. */
|
|
|
|
function getArtBox(pdf, pagenumber)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions get a box given the document, page number, min x, max x,
|
|
|
|
min y, max y in points. Only succeeds if such a box exists, as checked by
|
|
|
|
hasBox. */
|
|
|
|
function getBleedBox(pdf, pagenumber)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions get a box given the document, page number, min x, max x,
|
|
|
|
min y, max y in points. Only succeeds if such a box exists, as checked by
|
|
|
|
hasBox. */
|
|
|
|
function getTrimBox(pdf, pagenumber)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions set a box given the document, page range, min x, max x,
|
2022-05-12 17:57:13 +02:00
|
|
|
min y, max y in points. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setMediabox(pdf, range, minx, maxx, miny, maxy)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions set a box given the document, page range, min x, max x,
|
|
|
|
min y, max y in points. */
|
|
|
|
function setCropBox(pdf, range, minx, maxx, miny, maxy)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions set a box given the document, page range, min x, max x,
|
|
|
|
min y, max y in points. */
|
|
|
|
function setTrimBox(pdf, range, minx, maxx, miny, maxy)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions set a box given the document, page range, min x, max x,
|
|
|
|
min y, max y in points. */
|
|
|
|
function setBleedBox(pdf, range, minx, maxx, miny, maxy)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** These functions set a box given the document, page range, min x, max x,
|
|
|
|
min y, max y in points. */
|
|
|
|
function setArtBox(pdf, range, minx, maxx, miny, maxy)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Marks a document as trapped. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function markTrapped(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Marks a document as untrapped. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function markUntrapped(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Marks a document as trapped in XMP metadata. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function markTrappedXMP(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Marks a document as untrapped in XMP metadata. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function markUntrappedXMP(pdf)
|
|
|
|
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Sets the page layout for a document. */
|
|
|
|
function setPageLayout(pdf, layout)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Sets the page mode for a document. */
|
|
|
|
function setPageMode(pdf, mode)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the hide toolbar flag. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function hideToolbar(pdf, flag)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the hide menubar flag. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function hideMenubar(pdf, flag)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the hide window UI flag. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function hideWindowUi(pdf, flag)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the fit window flag. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function fitWindow(pdf, flag)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the center window flag. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function centerWindow(pdf, flag)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Sets the display doc title flag. */
|
|
|
|
function displayDocTitle(pdf, flag)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the PDF to open, possibly with zoom-to-fit, at the given page
|
2022-05-18 18:47:31 +02:00
|
|
|
number. */
|
|
|
|
function openAtPage(pdf, fit, pagenumber)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP metadata of a document, given a file name. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setMetadataFromFile(pdf, filename)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Sets the XMP metadata from an array of bytes. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function setMetadataFromByteArray(pdf, data)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Removes the XMP metadata from a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function removeMetadata(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
|
|
|
/** Returns the XMP metadata from a document. */
|
2022-05-18 18:47:31 +02:00
|
|
|
function getMetadata(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Builds fresh XMP metadata as best it can from existing metadata in the
|
|
|
|
document. */
|
|
|
|
function createMetadata(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** 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. */
|
|
|
|
function setMetadataDate(pdf, date)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Adds page labels. 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. */
|
|
|
|
function addPageLabels(pdf, style, prefix, offset, range, progress)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Removes the page labels from the document. */
|
|
|
|
function removePageLabels(pdf)
|
2022-05-12 17:57:13 +02:00
|
|
|
|
2022-05-18 18:47:31 +02:00
|
|
|
/** Calculates the full label string for a given page, and returns it. */
|
|
|
|
function getPageLabelStringForPage(pdf, pagenumber)
|
|
|
|
|
|
|
|
/** Gets page label data. Call startGetPageLabels to find out how many
|
|
|
|
there are, then use these serial numbers to get the style, prefix, offset
|
|
|
|
and start value (note not a range). Call endGetPageLabels to clean up.
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
labelstyle = LowercaseRoman
|
|
|
|
labelprefix = ""
|
|
|
|
startpage = 1
|
|
|
|
startvalue = 1
|
|
|
|
|
|
|
|
labelstyle = DecimalArabic
|
|
|
|
labelprefix = ""
|
|
|
|
startpage = 6
|
|
|
|
startvalue = 1 */
|
|
|
|
function startGetPageLabels(pdf)
|
|
|
|
function getPageLabelStyle(n)
|
|
|
|
function getPageLabelPrefix(n)
|
|
|
|
function getPageLabelOffset(n)
|
|
|
|
function getPageLabelRange(n)
|
|
|
|
function endGetPageLabels()
|