Global

Members

noEdit

Cannot edit the document
Source:

noPrint

Cannot print the document
Source:

noCopy

Cannot copy the document
Source:

noAnnot

Cannot annotate the document
Source:

noForms

Cannot edit forms in the document
Source:

noExtract

Cannot extract information
Source:

noAssemble

Cannot assemble into a bigger document
Source:

noHqPrint

Cannot print high quality
Source:

pdf40bit

40 bit RC4 encryption
Source:

pdf128bit

128 bit RC4 encryption
Source:

aes128bitfalse

128 bit AES encryption, do not encrypt metadata
Source:

aes128bittrue

128 bit AES encryption, encrypt metadata
Source:

aes256bitfalse

Deprecated. Do not use for new files
Source:

aes256bittrue

Deprecated. Do not use for new files
Source:

aes256bitisofalse

256 bit AES encryption, do not encrypt metadata
Source:

aes256bitisotrue

256 bit AES encryption, encrypt metadata
Source:

a0portrait

A0 Portrait paper
Source:

a1portrait

A1 Portrait paper
Source:

a2portrait

A2 Portrait paper
Source:

a3portrait

A3 Portrait paper
Source:

a4portrait

A4 Portrait paper
Source:

a5portrait

A5 Portrait paper
Source:

a0landscape

A0 Landscape paper
Source:

a1landscape

A1 Landscape paper
Source:

a2landscape

A2 Landscape paper
Source:

a3landscape

A3 Landscape paper
Source:

a4landscape

A4 Landscape paper
Source:

a5landscape

A5 Landscape paper
Source:

usletterportrait

US Letter Portrait paper
Source:

usletterlandscape

US Letter Landscape paper
Source:

uslegalportrait

US Legal Portrait paper
Source:

uslegallandscape

US Legal Landscape paper
Source:

posCentre

Absolute centre
Source:

posLeft

Absolute left
Source:

posRight

Absolute right
Source:

top

The top centre of the page
Source:

topLeft

The top left of the page
Source:

topRight

The top right of the page
Source:

left

The left hand side of the page, halfway down
Source:

bottomLeft

The bottom left of the page
Source:

bottom

The bottom middle of the page
Source:

bottomRight

The bottom right of the page
Source:
The right hand side of the page, halfway down
Source:

diagonal

Diagonal, bottom left to top right
Source:

reversediagonal

Diagonal, top left to bottom right
Source:

timesRoman

Times Roman
Source:

timesBold

Times Bold
Source:

timesItalic

Times Italic
Source:

timesBoldItalic

Times Bold Italic
Source:

helvetica

Helvetica
Source:

helveticaBold

Helvetica Bold
Source:

helveticaOblique

Helvetica Oblique
Source:

helveticaBoldOblique

Helvetica Bold Oblique
Source:

courier

Courier
Source:

courierBold

Courier Bold
Source:

courierOblique

Courier Oblique
Source:

courierBoldOblique

Courier Bold Oblique
Source:

leftJustify

Left justify
Source:

centreJustify

Centre justify
Source:

rightJustify

Right justify
Source:

singlePage

Single page
Source:

oneColumn

One column
Source:

twoColumnLeft

Two column left
Source:

twoColumnRight

Two column right
Source:

twoPageLeft

Two page left
Source:

twoPageRight

Two page right
Source:

useNone

Use none
Source:

useOutlines

Use outlines
Source:

useThumbs

Use thumbs
Source:

useOC

Use OC
Source:

useAttachments

Use attachments
Source:

decimalArabic

1, 2, 3...
Source:

uppercaseRoman

I, II, III...
Source:

lowercaseRoman

i, ii, iii...
Source:

uppercaseLetters

A, B, C...
Source:

lowercaseLetters

a, b, c...
Source:

Methods

version() → {string}

Returns a string giving the version number of the CPDF library.
Source:
Returns:
version
Type
string

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. This function sets the mode to fast globally.
Source:

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. This function sets the mode to slow globally.
Source:

deletePdf(pdf)

Delete a PDF so the memory representing it may be recovered.
Parameters:
Name Type Description
pdf pdf PDF document to delete
Source:

fromFile(filename, userpw)

Loads a PDF file from a given file. Supply a user password (possibly blank) in case the file is encrypted. It won't be decrypted, but sometimes the password is needed just to load the file.
Parameters:
Name Type Description
filename string File name
userpw string User password, or blank if none
Source:

fromFileLazy(filename, userpw)

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 encrypted. It won't be decrypted, but sometimes the password is needed just to load the file.
Parameters:
Name Type Description
filename string File name
userpw string User password, or blank if none
Source:

fromMemory(data, userpw)

Loads a file from memory given any user password.
Parameters:
Name Type Description
data Uint8Array PDF document as an array of bytes
userpw string User password, or blank if none
Source:

fromMemoryLazy(data, userpw)

Loads a file from memory, given a pointer and a length, and the user password, but lazily like fromFileLazy.
Parameters:
Name Type Description
data Uint8Array PDF document as an array of bytes
userpw string User password, or blank if none
Source:

startEnumeratePDFs() → {number}

To enumerate the list of currently allocated PDFs, call startEnumeratePDFs which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to clean up.
Source:
Returns:
number of PDFs
Type
number

enumeratePDFsKey(index) → {number}

To enumerate the list of currently allocated PDFs, call startEnumeratePDFs which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to clean up.
Parameters:
Name Type Description
index n number
Source:
Returns:
PDF key
Type
number

enumeratePDFsInfo(index) → {number}

To enumerate the list of currently allocated PDFs, call startEnumeratePDFs which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to clean up.
Parameters:
Name Type Description
index n number
Source:
Returns:
PDF information
Type
number

endEnumeratePDFs()

To enumerate the list of currently allocated PDFs, call startEnumeratePDFs which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to clean up.
Source:

ptOfCm(i) → {number}

Converts a figure in centimetres to points (72 points to 1 inch)
Parameters:
Name Type Description
i number figure in centimetres
Source:
Returns:
figure in points
Type
number

ptOfMm(i) → {number}

Converts a figure in millimetres to points (72 points to 1 inch)
Parameters:
Name Type Description
i number figure in millimetres
Source:
Returns:
figure in points
Type
number

ptOfIn(i) → {number}

Converts a figure in inches to points (72 points to 1 inch)
Parameters:
Name Type Description
i number figure in inches
Source:
Returns:
figure in points
Type
number

cmOfPt(i) → {number}

Converts a figure in points to centimetres (72 points to 1 inch)
Parameters:
Name Type Description
i number figure in points
Source:
Returns:
figure in centimetres
Type
number

mmOfPt(i) → {number}

Converts a figure in points to millimetres (72 points to 1 inch)
Parameters:
Name Type Description
i number figure in points
Source:
Returns:
figure in millimetres
Type
number

inOfPt(i) → {number}

Converts a figure in points to inches (72 points to 1 inch)
Parameters:
Name Type Description
i number figure in points
Source:
Returns:
figure in inches
Type
number

parsePagespec(pdf, pagespec) → {array}

Parses a page specification with reference to a given PDF (the PDF is supplied so that page ranges which reference pages which do not exist are rejected).
Parameters:
Name Type Description
pdf pdf PDF document
pagespec string Page specification
Source:
Returns:
page range
Type
array

validatePagespec(pagespec) → {boolean}

Validates a page specification so far as is possible in the absence of the actual document. Result is true if valid.
Parameters:
Name Type Description
pagespec string Page specification
Source:
Returns:
validity or otherwise of page specification
Type
boolean

stringOfPagespec(pdf, r) → {string}

Builds 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"
Parameters:
Name Type Description
pdf pdf PDF document
r array Page range
Source:
Returns:
Page specifcation
Type
string

blankRange() → {array}

Creates a range with no pages in.
Source:
Returns:
Page range
Type
array

range(f, t) → {array}

Builds a range from one page to another inclusive. For example, range(3,7) gives the range 3,4,5,6,7
Parameters:
Name Type Description
f number begining of page range
t number end of page range
Source:
Returns:
page range
Type
array

all(pdf) → {array}

The range containing all the pages in a given document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
page range
Type
array

even(r_in) → {array}

Makes a range which contains just the even pages of another range.
Parameters:
Name Type Description
r_in array page range
Source:
Returns:
page range
Type
array

odd(r_in) → {array}

Makes a range which contains just the odd pages of another range.
Parameters:
Name Type Description
r_in array page range
Source:
Returns:
page range
Type
array

rangeUnion(a, b) → {array}

Makes the union of two ranges giving a range containing the pages in range a and range b.
Parameters:
Name Type Description
a array page range
b array page range
Source:
Returns:
page range
Type
array

difference(a, b) → {array}

Makes the difference of two ranges, giving a range containing all the pages in a except for those which are also in b.
Parameters:
Name Type Description
a array page range
b array page range
Source:
Returns:
page range
Type
array

removeDuplicates(a) → {array}

Deduplicates a range, making a new one.
Parameters:
Name Type Description
a array page range
Source:
Returns:
page range
Type
array

rangeLength(r) → {number}

Gives the number of pages in a range.
Parameters:
Name Type Description
r array page range
Source:
Returns:
length
Type
number

rangeGet(r, n) → {number}

Gets the page number at position n in a range, where n runs from 0 to rangeLength - 1.
Parameters:
Name Type Description
r array page range
n number position
Source:
Returns:
page at given position
Type
number

rangeAdd(r, page)

Adds the page to a range, if it is not already there.
Parameters:
Name Type Description
r array page range
page number page number
Source:

isInRange(r, page) → {boolean}

Returns true if the page is in the range, false otherwise.
Parameters:
Name Type Description
r array page range
page number page number
Source:
Returns:
true if page in range, false otherwise
Type
boolean

pages(pdf) → {number}

Returns the number of pages in a PDF.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
number of pages
Type
number

pagesFast(password, filename) → {number}

Returns 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.
Parameters:
Name Type Description
password string user password
filename string file name
Source:
Returns:
number of pages
Type
number

pagesFastMemory(password, data) → {number}

Returns 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.
Parameters:
Name Type Description
password string user password
data Uint8Array PDF file as a byte array
Source:
Returns:
number of pages
Type
number

toFile(pdf, filename, linearize, make_id)

Writes the file to a given filename. If linearize is true, it will be linearized if a linearizer is available. If make_id is true, it will be given a new ID.
Parameters:
Name Type Description
pdf pdf PDF document
filename string file name
linearize boolean linearize if a linearizer is available
make_id boolean make a new /ID
Source:

toFileExt(pdf, filename, linearize, 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 be not be used again.
Parameters:
Name Type Description
pdf pdf PDF document
filename string file name
linearize boolean linearize if a linearizer is available
preserve_objstm boolean preserve existing object streams
generate_objstm boolean create new object streams
compress_objstm boolean compress new object streams
Source:

toMemory(pdf, linearize, make_id)

Writes a PDF file and returns as an array of bytes.
Parameters:
Name Type Description
pdf pdf PDF document
linearize boolean linearize if a linearizer is available
make_id boolean make a new /ID
Source:

toMemoryExt(pdf, linearize, preserve_objstm, generate_objstm, compress_objstm)

Writes the file to memory. 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 be not be used again.
Parameters:
Name Type Description
pdf pdf PDF document
linearize boolean linearize if a linearizer is available
preserve_objstm boolean preserve existing object streams
generate_objstm boolean create new object streams
compress_objstm boolean compress new object streams
Source:

isEncrypted(pdf) → {boolean}

Returns true if a document is encrypted, false otherwise.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
true if document encrypted, false otherwise
Type
boolean

decryptPdf(pdf, userpw)

Attempts to decrypt a PDF using the given user password. An exception is raised if the decryption fails.
Parameters:
Name Type Description
pdf pdf PDF document
userpw string user password, or empty if none
Source:

decryptPdfOwner(pdf, ownerpw)

Attempts to decrypt a PDF using the given owner password. Raises an exception if the decryption fails.
Parameters:
Name Type Description
pdf pdf PDF document
ownerpw string owner password, or empty if none
Source:

toFileEncrypted(pdf, encryption_method, array, ownerpw, userpw, linearize, makeid, filename)

Writes a file as encrypted.
Parameters:
Name Type Description
pdf pdf PDF document
encryption_method "encryption method" encryption method
array "permission array" of permissions
ownerpw string owner password
userpw string user password
linearize boolean linearize if a linearizer is available
makeid boolean make a new /ID
filename string file name
Source:

toMemoryEncrypted(pdf, encryption_method, array, ownerpw, userpw, linearize, makeid) → {Uint8Array}

Writes to memory as encrypted.
Parameters:
Name Type Description
pdf pdf PDF document
encryption_method "encryption method" encryption method
array "permission array" of permissions
ownerpw string owner password
userpw string user password
linearize boolean linearize if a linearizer is available
makeid boolean make a new /ID
Source:
Returns:
PDF file as a byte array
Type
Uint8Array

toFileEncryptedExt(pdf, encryption_method, array, ownerpw, userpw, linearize, makeid, preserve_objstm, generate_objstm, compress_objstm, filename)

Writes a file as encrypted with extra parameters. WARNING: the pdf argument will be invalid after this call, and should not be used again.
Parameters:
Name Type Description
pdf pdf PDF document
encryption_method "encryption method" encryption method
array "permission array" of permissions
ownerpw string owner password
userpw string user password
linearize boolean linearize if a linearizer is available
makeid boolean make a new /ID
preserve_objstm boolean preserve existing object streams
generate_objstm boolean generate new object streams
compress_objstm boolean compress object streams
filename string file name
Source:

toMemoryEncryptedExt(pdf, encryption_method, array, ownerpw, userpw, linearize, makeid, preserve_objstm, generate_objstm, compress_objstm) → {Uint8Array}

Writes a file as encrypted with extra parameters. WARNING: the pdf argument will be invalid after this call, and should not be used again.
Parameters:
Name Type Description
pdf pdf PDF document
encryption_method "encryption method" encryption method
array "permission array" of permissions
ownerpw string owner password
userpw string user password
linearize boolean linearize if a linearizer is available
makeid boolean make a new /ID
preserve_objstm boolean preserve existing object streams
generate_objstm boolean generate new object streams
compress_objstm boolean compress object streams
Source:
Returns:
PDF file as a byte array
Type
Uint8Array

hasPermission(pdf, permission) → {boolean}

Returns true if the given permission (restriction) is present.
Parameters:
Name Type Description
pdf pdf PDF document
permission permission permission
Source:
Returns:
true if permission present
Type
boolean

encryptionKind(pdf) → {"encryption method"}

Returns the encryption method currently in use on a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
encryption method
Type
"encryption method"

mergeSimple(pdfs) → {pdf}

Given a list of PDFs, merges the files into a new one, which is returned.
Parameters:
Name Type Description
pdfs "array of pdfs" array of PDF documents to merge
Source:
Returns:
merged PDF document
Type
pdf

merge(pdfs, retain_numbering, remove_duplicate_fonts)

Merges the 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.
Parameters:
Name Type Description
pdfs "array of pdfs" array of PDF documents to merge
retain_numbering boolean keep page numbering
remove_duplicate_fonts boolean remove duplicate font data
Source:

mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges)

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.
Parameters:
Name Type Description
pdfs "array of pdfs" array of PDF documents to merge
retain_numbering boolean keep page numbering
remove_duplicate_fonts boolean remove duplicate font data
ranges "array of arrays of numbers" page ranges, one for each input PDF
Source:

selectPages(pdf, page)

Returns a new document with just those pages in the page range.
Parameters:
Name Type Description
pdf pdf PDF document
page range range
Source:

scalePages(pdf, range, sx, sy)

Scales the page dimensions and content by the given scale, about (0, 0). Other boxes (crop etc. are altered as appropriate)
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
sx number x scale
sy number y scale
Source:

scaleToFit(pdf, range, sx, sy, scale)

Scales the content to fit new page dimensions (width x height) multiplied by scale (typically 1.0). Other boxes (crop etc. are altered as appropriate).
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
sx number x scale
sy number y scale
scale number scale
Source:

scaleToFitPaper(pdf, range, papersize, s)

Scales the page content to fit the given page size, possibly multiplied by scale (typically 1.0)
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
papersize "paper size" paper size
s number scale
Source:

scaleContents(pdf, range, anchor, p1, p2, scale)

Scales the contents of the pages in the range about the point given by the position, by the scale given.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
anchor anchor anchor to scale contents about
p1 number position argument 1
p2 number position argument 2
scale number scale
Source:

shiftContents(pdf, range, dx, dy)

Shifts the content of the pages in the range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
dx number x shift
dy number y shift
Source:

rotate(pdf, range, rotation)

Changes the viewing rotation to an absolute value. Appropriate rotations are 0, 90, 180, 270.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
rotation number rotation
Source:

rotateBy(pdf, range, rotation)

Rotates the content about the centre of the page by the given number of degrees, in a clockwise direction. Appropriate rotations are 0, 90, 180, 270.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
rotation number rotation
Source:

rotateContents(pdf, range, angle)

Rotates the content about the centre of the page by the given number of degrees, in a clockwise direction.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
angle number angle
Source:

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.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

hFlip(pdf, range)

Flips horizontally the pages in the range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

vFlip(pdf, range)

Flips vertically the pages in the range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

crop(pdf, range, x, y, w, h)

Crops a page, replacing any existing crop box. The dimensions are in points.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
x number x position
y number y position
w number width
h number height
Source:

removeCrop(pdf, range)

Removes any crop box from pages in the range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

removeTrim(pdf, range)

Removes any trim box from pages in the range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

removeArt(pdf, range)

Removes any art box from pages in the range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

removeBleed(pdf, range)

Removes any bleed box from pages in the range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

trimMarks(pdf, range)

Adds trim marks to the given pages, if the trimbox exists.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

showBoxes(pdf, range)

Shows the boxes on the given pages, for debug.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

hardBox(pdf, range, boxname)

Makes a given box a 'hard box' i.e clips it explicitly.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
boxname string box name
Source:

compress(pdf)

Compresses any uncompressed streams in the given PDF using the Flate algorithm.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

decompress(pdf)

Decompresses any streams in the given PDF, so long as the compression method is supported.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

squeezeInMemory(pdf)

Squeezes a pdf in memory.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

startGetBookmarkInfo(pdf)

Starts the bookmark retrieval process for a given PDF.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

numberBookmarks() → {number}

Gets the number of bookmarks for the PDF given to startGetBookmarkInfo.
Source:
Returns:
number of bookmarks
Type
number

getBookmarkLevel(n) → {number}

Gets the bookmark level for the given bookmark (0...(n - 1)).
Parameters:
Name Type Description
n number serial number
Source:
Returns:
bookmark level
Type
number

getBookmarkPage(pdf, n) → {number}

Gets the bookmark target page for the given PDF (which must be the same as the PDF passed to startSetBookmarkInfo) and bookmark (0...(n - 1)).
Parameters:
Name Type Description
pdf pdf PDF document
n number serial number
Source:
Returns:
bookmark page
Type
number

getBookmarkText(n) → {string}

Returns the text of bookmark (0...(n - 1)).
Parameters:
Name Type Description
n number serial number
Source:
Returns:
bookmark text
Type
string

getBookmarkOpenStatus(n) → {boolean}

True if the bookmark is open.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
open status
Type
boolean

endGetBookmarkInfo()

Ends the bookmark retrieval process, cleaning up.
Source:

startSetBookmarkInfo(n)

Starts the bookmark setting process for n bookmarks.
Parameters:
Name Type Description
n number number of bookmarks required
Source:

setBookmarkLevel(n, level)

Set bookmark level for the given bookmark (0...(n - 1)).
Parameters:
Name Type Description
n number serial number
level number bookmark level
Source:

setBookmarkPage(pdf, n, targetpage)

Sets the bookmark target page for the given PDF (which must be the same as the PDF to be passed to endSetBookmarkInfo) and bookmark (0...(n - 1)).
Parameters:
Name Type Description
pdf pdf PDF document
n number serial number
targetpage number target page
Source:

setBookmarkOpenStatus(n, status)

Sets the open status of bookmark (0...(n - 1)).
Parameters:
Name Type Description
n number serial number
status boolean open status
Source:

setBookmarkText(n, text)

Sets the text of bookmark (0...(n - 1)).
Parameters:
Name Type Description
n number serial number
text string bookmark text
Source:

endSetBookmarkInfo(pdf)

Ends the bookmark setting process, writing the bookmarks to the given PDF.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

getBookmarksJSON(pdf)

Returns the bookmark data in JSON format.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

setBookmarksJSON(pdf, byte)

Sets the bookmarks from JSON bookmark data.
Parameters:
Name Type Description
pdf pdf PDF document
byte Uint8Array array of JSON bookmark data
Source:

tableOfContents(pdf, font, fontsize, title, bookmark)

Typesets a table of contents from existing bookmarks and prepends it to the document. If bookmark is set, the table of contents gets its own bookmark.
Parameters:
Name Type Description
pdf pdf PDF document
font font font
fontsize number font size
title string title
bookmark boolean table of contents gets its own bookmark
Source:

stampOn(stamp_pdf, pdf, range)

Stamps stamp_pdf on 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.
Parameters:
Name Type Description
stamp_pdf pdf stamp
pdf pdf PDF document
range range page range
Source:

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.
Parameters:
Name Type Description
stamp_pdf pdf stamp
pdf pdf PDF document
range range page range
Source:

stampExtended(pdf, pdf, isover, scale_stamp_to_fit, anchor, p1, p2, relative_to_cropbox)

A stamping function with extra features.
Parameters:
Name Type Description
pdf pdf first PDF document
pdf pdf second PDF document
isover boolean pdf goes over pdf2, otherwise under
scale_stamp_to_fit boolean scales the stamp to fit the page
anchor anchor for position of stamp
p1 number position argument 1
p2 number position argument 2
relative_to_cropbox boolean pos is relative to cropbox not mediabox.
Source:

combinePages(under, over)

Combines the PDFs page-by-page, putting each page of 'over' over each page of 'under'.
Parameters:
Name Type Description
under pdf PDF document
over pdf PDF document
Source:

addText(metrics, pdf, range, text, anchor, p1, p2, linespacing, bates, font, fontsize, r, g, b, underneath, relative_to_cropbox, outline, opacity, justification, midline, topline, filename, linewidth, embed_fonts)

Adds text to the pages in the given range.
Parameters:
Name Type Description
metrics boolean collect metrics only
pdf pdf PDF document
range range page range
text string text to add \\n for newline
anchor anchor anchor to add text at
p1 number position argument 1
p2 number position argument 2
linespacing number line spacing
bates number starting bates number
font font font
fontsize number font size
r number red component of colour 0..1
g number green component of colour 0..1
b number blue component of colour 0..1
underneath boolean put text under the page rather than over
relative_to_cropbox boolean position is relative to crop box not media box
outline boolean text is outline
opacity number opacity 0..1
justification justification justification
midline boolean position is relative to midline not baseline
topline boolean position is relative to topline not baseline
filename string file name
linewidth number line width
embed_fonts boolean add font information
Source:

addTextSimple(pdf, range, text, anchor, p1, p2, font, fontsize)

Adds text with most parameters default.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
text string text to add. \\n for newline
anchor anchor anchor to add text at
p1 number position argument 1
p2 number position argument 2
font font font
fontsize number font size
Source:

removeText(pdf, range)

Removes any text added by cpdf from the given pages.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

textWidth(font, text)

Returns the width of a given string in the given font in thousandths of a point.
Parameters:
Name Type Description
font font font
text string text
Source:

addContent(content, before, pdf, range)

Adds page content before (if true) or after (if false) the existing content to pages in the given range in the given PDF.
Parameters:
Name Type Description
content string content to add
before boolean rather than after
pdf pdf PDF document
range range page range
Source:

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.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
stamp_pdf pdf stamp pdf
Source:

impose(pdf, x, y, fit, rtl, btt, center, margin, spacing, linewidth)

Imposes a PDF. There are two modes: imposing x * y, or imposing to fit a page of size x * y. This is controlled by fit. Columns imposes by columns rather than rows. rtl is right-to-left, btt bottom-to-top. Center is unused for now. Margin is the margin around the output, spacing the spacing between imposed inputs.
Parameters:
Name Type Description
pdf pdf PDF document
x number (explained above)
y number (explained above)
fit boolean (explained above)
rtl boolean impose right to left
btt boolean impose bottom to top
center boolean unused
margin number margin around output pages
spacing number spacing between imposed pages
linewidth number line width
Source:

twoUp(pdf)

Imposes a document two up. twoUp does so by shrinking the page size, to fit two pages on one.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

twoUpStack(pdf)

Impose a document two up. twoUpStack does so by doubling the page size, to fit two pages on one.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

padBefore(pdf, range)

Adds a blank page before each page in the given range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

padAfter(pdf, range)

Adds a blank page after every n pages.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

padEvery(pdf, interval)

Adds a blank page after every n pages.
Parameters:
Name Type Description
pdf pdf PDF document
interval number
Source:

padMultiple(pdf, multiple)

Adds pages at the end to pad the file to a multiple of n pages in length.
Parameters:
Name Type Description
pdf pdf PDF document
multiple number to pad to
Source:

padMultipleBefore(pdf, multiple)

Adds pages at the beginning to pad the file to a multiple of n pages in length.
Parameters:
Name Type Description
pdf pdf PDF document
multiple number to pad to
Source:

annotationsJSON(pdf) → {Uint8Array}

Returns the annotations from a PDF in JSON format.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
results as an array of bytes
Type
Uint8Array

isLinearized(filename)

Finds out if a document is linearized as quickly as possible without loading it.
Parameters:
Name Type Description
filename string file name
Source:

isLinearizedMemory(PDF)

Finds out if a document in memory is linearized as quickly as possible without loading it.
Parameters:
Name Type Description
PDF Uint8Array file as a byte array
Source:

getVersion(pdf) → {number}

Returns the minor version number of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
version number
Type
number

getMajorVersion(pdf) → {number}

Returns the major version number of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
major version number
Type
number

getTitle(pdf) → {string}

Returns the title of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
title
Type
string

getAuthor(pdf) → {string}

Returns the author of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
author
Type
string

getSubject(pdf) → {string}

Returns the subject of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
subject
Type
string

getKeywords(pdf) → {string}

Returns the keywords of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
keywords
Type
string

getCreator(pdf) → {string}

Returns the creator of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
creator
Type
string

getProducer(pdf) → {string}

Returns the producer of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
producer
Type
string

getCreationDate(pdf) → {string}

Returns the creation date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
creation date
Type
string

getModificationDate(pdf) → {string}

Returns the modification date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
modification date
Type
string

getTitleXMP(pdf) → {string}

Returns the XMP title of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP title
Type
string

getAuthorXMP(pdf) → {string}

Returns the XMP author of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP author
Type
string

getSubjectXMP(pdf) → {string}

Returns the XMP subject of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP subject
Type
string

getKeywordsXMP(pdf) → {string}

Returns the XMP keywords of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP keywords
Type
string

getCreatorXMP(pdf) → {string}

Returns the XMP creator of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP creator
Type
string

getProducerXMP(pdf) → {string}

Returns the XMP producer of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP producer
Type
string

getCreationDateXMP(pdf) → {string}

Returns the XMP creation date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP creation date
Type
string

getModificationDateXMP(pdf) → {string}

Returns the XMP modification date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
XMP modification date
Type
string

setTitle(pdf, s)

Sets the title of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string title
Source:

setAuthor(pdf, s)

Sets the author of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string author
Source:

setSubject(pdf, s)

Sets the subject of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string subject
Source:

setKeywords(pdf, s)

Sets the keywords of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string keywords
Source:

setCreator(pdf, s)

Sets the creator of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string creator
Source:

setProducer(pdf, s)

Sets the producer of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string producer
Source:

setCreationDate(pdf, s)

Sets the creation date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string creation date
Source:

setModificationDate(pdf, s)

Sets the modification date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string modification date
Source:

setTitleXMP(pdf, s)

Sets the XMP title of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP title
Source:

setAuthorXMP(pdf, s)

Sets the XMP author of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP author
Source:

setSubjectXMP(pdf, s)

Sets the XMP author of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP subject
Source:

setKeywordsXMP(pdf, s)

Sets the XMP keywords of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP keywords
Source:

setCreatorXMP(pdf, s)

Sets the XMP creator of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP creator
Source:

setProducerXMP(pdf, s)

Sets the XMP producer of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP producer
Source:

setCreationDateXMP(pdf, s)

Sets the XMP creation date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP creation date
Source:

setModificationDateXMP(pdf, s)

Sets the XMP modification date of a document.
Parameters:
Name Type Description
pdf pdf PDF document
s string XMP modification date
Source:

getDateComponents(string) → {"array of numbers"}

Returns the components from a PDF date string.
Parameters:
Name Type Description
string string date string
Source:
Returns:
date components
Type
"array of numbers"

dateStringOfComponents(y, m, d, h, min, sec, hour_offset, minute_offset) → {string}

Builds a PDF date string from individual components.
Parameters:
Name Type Description
y number year
m number month
d number day
h number hour
min number minute
sec number second
hour_offset number hour offset
minute_offset number minute offset
Source:
Returns:
date string
Type
string

getPageRotation(pdf, page)

Gets the viewing rotation for a given page.
Parameters:
Name Type Description
pdf pdf PDF document
page number page number
Source:

hasBox(pdf, page, box)

Returns true if that page has the given box. E.g "/CropBox".
Parameters:
Name Type Description
pdf pdf PDF document
page number page number
box string box name
Source:

getMediaBox(pdf, pagenumber) → {"array of numbers"}

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.
Parameters:
Name Type Description
pdf pdf PDF document
pagenumber number page number
Source:
Returns:
media box
Type
"array of numbers"

getCropBox(pdf, pagenumber) → {"array of numbers"}

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.
Parameters:
Name Type Description
pdf pdf PDF document
pagenumber number page number
Source:
Returns:
crop box
Type
"array of numbers"

getArtBox(pdf, pagenumber) → {"array of numbers"}

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.
Parameters:
Name Type Description
pdf pdf PDF document
pagenumber number page number
Source:
Returns:
art box
Type
"array of numbers"

getBleedBox(pdf, pagenumber) → {"array of numbers"}

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.
Parameters:
Name Type Description
pdf pdf PDF document
pagenumber number page number
Source:
Returns:
bleed box
Type
"array of numbers"

getTrimBox(pdf, pagenumber) → {"array of numbers"}

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.
Parameters:
Name Type Description
pdf pdf PDF document
pagenumber number page number
Source:
Returns:
trim box
Type
"array of numbers"

setMediabox(pdf, range, minx, maxx, minx, maxx)

These functions set a box given the document, page range, min x, max x, min y, max y in points.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
minx number min x
maxx number max x
minx number min y
maxx number max y
Source:

setCropBox(pdf, range, minx, maxx, minx, maxx)

These functions set a box given the document, page range, min x, max x, min y, max y in points.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
minx number min x
maxx number max x
minx number min y
maxx number max y
Source:

setTrimBox(pdf, range, minx, maxx, minx, maxx)

These functions set a box given the document, page range, min x, max x, min y, max y in points.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
minx number min x
maxx number max x
minx number min y
maxx number max y
Source:

setBleedBox(pdf, range, minx, maxx, minx, maxx)

These functions set a box given the document, page range, min x, max x, min y, max y in points.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
minx number min x
maxx number max x
minx number min y
maxx number max y
Source:

setArtBox(pdf, range, minx, maxx, minx, maxx)

These functions set a box given the document, page range, min x, max x, min y, max y in points.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
minx number min x
maxx number max x
minx number min y
maxx number max y
Source:

markTrapped(pdf)

Marks a document as trapped.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

markUntrapped(pdf)

Marks a document as untrapped.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

markTrappedXMP(pdf)

Marks a document as trapped in XMP metadata.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

markUntrappedXMP(pdf)

Marks a document as untrapped in XMP metadata.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

setPageLayout(pdf, layout)

Sets the page layout for a document.
Parameters:
Name Type Description
pdf pdf PDF document
layout layout page layout
Source:

setPageMode(pdf, mode)

Sets the page mode for a document.
Parameters:
Name Type Description
pdf pdf PDF document
mode mode page mode
Source:

hideToolbar(pdf, flag)

Sets the hide toolbar flag.
Parameters:
Name Type Description
pdf pdf PDF document
flag boolean hide toolbar
Source:

hideMenubar(pdf, flag)

Sets the hide menubar flag.
Parameters:
Name Type Description
pdf pdf PDF document
flag boolean hide menubar
Source:

hideWindowUi(pdf, flag)

Sets the hide window UI flag.
Parameters:
Name Type Description
pdf pdf PDF document
flag boolean hide UI
Source:

fitWindow(pdf, flag)

Sets the fit window flag.
Parameters:
Name Type Description
pdf pdf PDF document
flag boolean fit window
Source:

centerWindow(pdf, flag)

Sets the center window flag.
Parameters:
Name Type Description
pdf pdf PDF document
flag boolean center window
Source:

displayDocTitle(pdf, flag)

Sets the display doc title flag.
Parameters:
Name Type Description
pdf pdf PDF document
flag boolean display doc title
Source:

openAtPage(pdf, fit, pagenumber)

Sets the PDF to open, possibly with zoom-to-fit, at the given page number.
Parameters:
Name Type Description
pdf pdf PDF document
fit boolean zoom-to-fit
pagenumber number page number
Source:

setMetadataFromFile(pdf, filename)

Sets the XMP metadata of a document, given a file name.
Parameters:
Name Type Description
pdf pdf PDF document
filename string file name
Source:

setMetadataFromByteArray(pdf, data)

Sets the XMP metadata from an array of bytes.
Parameters:
Name Type Description
pdf pdf PDF document
data Uint8Array XMP metadata as an array of bytes
Source:

removeMetadata(pdf)

Removes the XMP metadata from a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

getMetadata(pdf)

Returns the XMP metadata from a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

createMetadata(pdf)

Builds fresh XMP metadata as best it can from existing metadata in the document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

setMetadataDate()

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.
Source:

addPageLabels(pdf, style, prefix, offset, range, progress)

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.
Parameters:
Name Type Description
pdf pdf PDF document
style style page label style
prefix string label prefix
offset number offset
range range page range
progress boolean labels progress
Source:

removePageLabels(pdf)

Removes the page labels from the document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

getPageLabelStringForPage(pdf, pagenumber)

Calculates the full label string for a given page, and returns it.
Parameters:
Name Type Description
pdf pdf PDF document
pagenumber number page number
Source:

startGetPageLabels(pdf)

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
Parameters:
Name Type Description
pdf pdf PDF document
Source:

getPageLabelStyle(n)

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
Parameters:
Name Type Description
n number serial number
Source:

getPageLabelPrefix(n)

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
Parameters:
Name Type Description
n number serial number
Source:

getPageLabelOffset(n)

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
Parameters:
Name Type Description
n number serial number
Source:

getPageLabelRange(n)

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
Parameters:
Name Type Description
n number serial number
Source:

endGetPageLabels()

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
Source:

attachFile(filename, pdf)

Attaches a file to the pdf. It is attached at document level.
Parameters:
Name Type Description
filename string file name
pdf pdf PDF document
Source:

attachFileToPage(filename, pdf, pagenumber)

Attaches a file, given its file name, pdf, and the page number to which it should be attached.
Parameters:
Name Type Description
filename string file name
pdf pdf PDF document
pagenumber number page number
Source:

attachFileFromMemory(data, filename, pdf)

Attaches data from memory, just like attachFile.
Parameters:
Name Type Description
data Uint8Array file as a byte array
filename string file name to call it in the PDF
pdf pdf PDF document
Source:

attachFileToPageFromMemory(data, filename, pdf, pagenumber)

Attaches to a page from memory, just like attachFileToPage.
Parameters:
Name Type Description
data Uint8Array file as a byte array
filename string file name to call it in the PDF
pdf pdf PDF document
pagenumber number page number
Source:

removeAttachedFiles(pdf)

Removes all page- and document-level attachments from a document.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

startGetAttachments(pdf)

Lists information about attachments. Call startGetAttachments(pdf) first, then numberGetAttachments to find out how many there are. Then getAttachmentName etc. to return each one 0...(n - 1). Finally, call endGetAttachments to clean up.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

numberGetAttachments() → {number}

Lists information about attachments. Call startGetAttachments(pdf) first, then numberGetAttachments to find out how many there are. Then getAttachmentName etc. to return each one 0...(n - 1). Finally, call endGetAttachments to clean up.
Source:
Returns:
number of attachments
Type
number

getAttachmentName(n) → {string}

Gets the name of an attachment.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
attachment name
Type
string

getAttachmentPage(n) → {number}

Gets the page number. 0 = document level.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
attachment page
Type
number

getAttachmentData(n) → {Uint8Array}

Gets the attachment data itself.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
attachment data
Type
Uint8Array

endGetAttachments()

Cleans up after getting attachments.
Source:

startGetImageResolution(pdf, min_required_resolution) → {number}

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Parameters:
Name Type Description
pdf pdf PDF document
min_required_resolution number minimum required resolution
Source:
Returns:
number of uses
Type
number

getImageResolutionPageNumber(n) → {number}

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
page number
Type
number

getImageResolutionImageName(n) → {string}

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
image name
Type
string

getImageResolutionXPixels(n) → {number}

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
X pixels
Type
number

getImageResolutionYPixels(n) → {number}

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
Y pixels
Type
number

getImageResolutionXRes(n) → {number}

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
X Res
Type
number

getImageResolutionYRes(n) → {number}

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
Y Res
Type
number

endGetImageResolution()

Gets image data, including resolution at all points of use. Call startGetImageResolution(pdf, min_required_resolution) to begin the process of obtaining data on all image uses below min_required_resolution, returning the total number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean up.
Source:

startGetFontInfo()

Retrieves font information. First, call startGetFontInfo(pdf). Now call numberFonts to return the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial number 0..n - 1 to return information. Finally, call endGetFontInfo to clean up. @ {pdf} pdf PDF document
Source:

numberFonts()

Retrieves font information. First, call startGetFontInfo(pdf). Now call numberFonts to return the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial number 0..n - 1 to return information. Finally, call endGetFontInfo to clean up.
Source:

getFontPage(n) → {number}

Retrieves font information. First, call startGetFontInfo(pdf). Now call numberFonts to return the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial number 0..n - 1 to return information. Finally, call endGetFontInfo to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
page number
Type
number

getFontName(n) → {string}

Retrieves font information. First, call startGetFontInfo(pdf). Now call numberFonts to return the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial number 0..n - 1 to return information. Finally, call endGetFontInfo to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
font name
Type
string

getFontType(n) → {string}

Retrieves font information. First, call startGetFontInfo(pdf). Now call numberFonts to return the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial number 0..n - 1 to return information. Finally, call endGetFontInfo to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
font type
Type
string

getFontEncoding(n) → {string}

Retrieves font information. First, call startGetFontInfo(pdf). Now call numberFonts to return the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial number 0..n - 1 to return information. Finally, call endGetFontInfo to clean up.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
font encoding
Type
string

endGetFontInfo()

Retrieves font information. First, call startGetFontInfo(pdf). Now call numberFonts to return the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial number 0..n - 1 to return information. Finally, call endGetFontInfo to clean up.
Source:

removeFonts(pdf)

Removes all font data from a file.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

copyFont(docfrom, docto, page, pagenumber, fontname)

Copies the given font from the given page in the 'from' PDF to every page in the range of the 'to' PDF. The new font is stored under its font name.
Parameters:
Name Type Description
docfrom pdf source document
docto pdf destination document
page range range
pagenumber number source page number
fontname string font name
Source:

outputJSON(filename, parse_content, no_stream_data, decompress_streams, 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. If decompress_streams is true, streams are decompressed.
Parameters:
Name Type Description
filename string file name
parse_content boolean parse page content
no_stream_data boolean suppress stream data
decompress_streams boolean decompress streams
pdf pdf PDF document
Source:

outputJSONMemory(parse_content, no_stream_data, decompress_streams, pdf) → {Uint8Array}

Like outputJSON, but it writes to a byte array in memory.
Parameters:
Name Type Description
parse_content boolean parse page content
no_stream_data boolean suppress stream data
decompress_streams boolean decompress streams
pdf pdf PDF document
Source:
Returns:
JSON data as a byte array
Type
Uint8Array

fromJSON(filename) → {pdf}

Loads a PDF from a JSON file given its filename.
Parameters:
Name Type Description
filename string file name
Source:
Returns:
PDF document
Type
pdf

fromJSONMemory(data) → {pdf}

Loads a PDF from a JSON file in memory.
Parameters:
Name Type Description
data Uint8Array JSON data as a byte array
Source:
Returns:
PDF document
Type
pdf

startGetOCGList(pdf) → {number}

Begins retrieving optional content group names. The number of entries is returned.
Parameters:
Name Type Description
pdf pdf PDF document
Source:
Returns:
number of entries
Type
number

ocgListEntry(n) → {string}

Retrieves an OCG name, given its serial number 0..n - 1.
Parameters:
Name Type Description
n number serial number
Source:
Returns:
OCG name
Type
string

endGetOCGList()

Ends retrieval of optional content group names.
Source:

ocgRename(pdf, name_from, name_to)

Renames an optional content group.
Parameters:
Name Type Description
pdf pdf PDF document
name_from string source name
name_to string destination name
Source:

ocgOrderAll(pdf)

Ensures that every optional content group appears in the OCG order list.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

ocgCoalesce(pdf)

Coalesces optional content groups. For example, if we merge or stamp two files both with an OCG called "Layer 1", we will have two different optional content groups. This function will merge the two into a single optional content group.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

blankDocument(w, h, number) → {pdf}

Creates a blank document with pages of the given width (in points), height (in points), and number of pages.
Parameters:
Name Type Description
w number page width
h number page height
number number of pages
Source:
Returns:
PDF document
Type
pdf

blankDocumentPaper(papersize, pages) → {pdf}

Makes a blank document given a page size and number of pages.
Parameters:
Name Type Description
papersize "paper size" paper size
pages number number of pages
Source:
Returns:
PDF document
Type
pdf

textToPDF(w, h, font, fontsize, filename)

Typesets a UTF8 text file ragged right on a page of size w * h in points in the given font and font size.
Parameters:
Name Type Description
w number page width
h number page height
font font font
fontsize number font size
filename string file name
Source:

textToPDFMemory(w, h, font, fontsize, data)

Typesets a UTF8 text file ragged right on a page of size w * h in points in the given font and font size.
Parameters:
Name Type Description
w number page width
h number page height
font font font
fontsize number font size
data Uint8Array text
Source:

textToPDFPaper(papersize, font, fontsize, filename)

Typesets a UTF8 text file ragged right on a page of the given size in the given font and font size.
Parameters:
Name Type Description
papersize "paper size" paper size
font font font
fontsize number font size
filename string file name
Source:

textToPDFPaperMemory(papersize, font, fontsize, data)

Typesets a UTF8 text file ragged right on a page of the given size in the given font and font size.
Parameters:
Name Type Description
papersize "paper size" paper size
font font font
fontsize number font size
data Uint8Array text
Source:

draft(pdf, range, boxes)

Removes images on the given pages, replacing them with crossed boxes if 'boxes' is true.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
boxes boolean replace with crossed boxes
Source:

removeAllText(pdf, range)

Removes all text from the given pages in a given document.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

blackLines(pdf, range)

Blackens all lines on the given pages.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

blackFills(pdf, range)

Blackens all fills on the given pages.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source:

thinLines(pdf, range, min_thickness)

Thickens every line less than min_thickness to min_thickness. Thickness given in points.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
min_thickness number minimum required thickness
Source:

copyId(pdf_from, pdf_to)

Copies the /ID from one document to another.
Parameters:
Name Type Description
pdf_from pdf source document
pdf_to pdf destination document
Source:

removeId(pdf)

Removes a document's /ID.
Parameters:
Name Type Description
pdf pdf PDF document
Source:

setVersion(pdf, version)

Sets the minor version number of a document.
Parameters:
Name Type Description
pdf pdf PDF document
version number
Source:

setFullVersion(pdf, major, minor)

Sets the full version number of a document.
Parameters:
Name Type Description
pdf pdf PDF document
major number version
minor number version
Source:

removeDictEntry(pdf, key)

Removes any dictionary entry with the given key anywhere in the document.
Parameters:
Name Type Description
pdf pdf PDF document
key string key to remove
Source:

removeDictEntrySearch(pdf, key, searchterm)

Removes any dictionary entry with the given key whose value matches the given search term.
Parameters:
Name Type Description
pdf pdf PDF document
key string key to remove
searchterm string search term
Source:

replaceDictEntry(pdf, key, newval)

Replaces the value associated with the given key.
Parameters:
Name Type Description
pdf pdf PDF document
key string key to remove
newval string new value
Source:

replaceDictEntrySearch(pdf, key, newval, searchterm)

Replaces the value associated with the given key if the existing value matches the search term.
Parameters:
Name Type Description
pdf pdf PDF document
key string key to remove
newval string new value
searchterm string search term
Source:

removeClipping(pdf, range)

Removes all clipping from pages in the given range.
Parameters:
Name Type Description
pdf pdf PDF document
range range page range
Source: