Class Jcpdf
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Any function in this library may raise theCpdfError
exception, which carries a string describing the nature of the problem.class
A PDF documentclass
A page range, which represents an ordered list of page numbers. -
Field Summary
Modifier and TypeFieldDescriptionstatic int
Paper size: A0 Landscapestatic int
Paper size: A0 Portraitstatic int
Paper size: A1 Landscapestatic int
Paper size: A1 Portraitstatic int
Paper size: A2 Landscapestatic int
Paper size: A2 Portraitstatic int
Paper size: A3 Landscapestatic int
Paper size: A3 Portraitstatic int
Paper size: A4 Landscapestatic int
Paper size: A4 Portraitstatic int
Paper size: A5 Landscapestatic int
Paper size: A5 Portraitstatic int
Encryption method: 128 bit AES encryption, do not encrypt metadatastatic int
Encryption method: 128 bit AES encryption, encrypt metadatastatic int
Encryption method: Deprecated.static int
Encryption method: 256 bit AES encryption, do not encrypt metadatastatic int
Encryption method: 256 bit AES encryption, encrypt metadatastatic int
Encryption method: Deprecated.static int
Position anchor: the bottom middle of the page.static int
Position anchor: the bottom left of the page.static int
Position anchor: the bottomm right of the page.static int
Justification: centrestatic int
Standard font: Courierstatic int
Standard font: Courier Boldstatic int
Standard font: Courier Bold Obliquestatic int
Standard font: Courier Obliquestatic int
Page label style: 1, 2, 3...static int
Position anchor: diagonal, bottom left to top right.static int
Standard font: Helveticastatic int
Standard font: Helvetica Boldstatic int
Standard font: Helvetica Bold Obliquestatic int
Standard font: Helvetica Obliquestatic int
Position anchor: the left hand side of the page, halfway down.static int
Justification: leftstatic int
Page label style: a, b, c...static int
Page label style: i, ii, iii...static int
Permission: cannot annotate the documentstatic int
Permission: cannot assemble into a bigger documentstatic int
Permission: cannot copy the documentstatic int
Permission: cannot edit the documentstatic int
Permission: cannot extract informationstatic int
Permission: cannot edit forms in the documentstatic int
Permission: cannot print high qualitystatic int
Permission: cannot print the documentstatic int
Layout: one columnstatic int
Encryption method: 128 bit RC4 encryptionstatic int
Encryption method: 40 bit RC4 encryptionstatic int
Position anchor: absolute centre.static int
Position anchor: absolute left.static int
Position anchor: absolute right.static int
Position anchor: diagonal, top left to bottom right.static int
Position anchor: the right hand side of the page, halfway down.static int
Justification: rightstatic int
Layout: single pagestatic int
Standard font: Times Boldstatic int
Standard font: Times Bold Italicstatic int
Standard font: Times Italicstatic int
Standard font: Times Romanstatic int
Position anchor: the top centre of the page.static int
Position anchor: the top left of the page.static int
Position anchor: the top right of the page.static int
Layout: two column leftstatic int
Layout: two column rightstatic int
Layout: two page leftstatic int
Layout: two page rightstatic int
Page label style: A, B, C...static int
Page label style: I, II, III...static int
Page mode: use Attachmentsstatic int
Page mode: use nonestatic int
Page mode: use OCstatic int
Page mode: use outlinesstatic int
Page mode: use thumbsstatic int
Paper size: US Legal Landscapestatic int
Paper size: US Legal Portraitstatic int
Paper size: US Letter Landscapestatic int
Paper size: US Letter Portrait -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addContent
(String s, boolean before, Jcpdf.Pdf pdf, Jcpdf.Range range) Adds page content before or after the existing content to pages in the given range in the given PDF.void
addPageLabels
(Jcpdf.Pdf pdf, int style, String prefix, int offset, Jcpdf.Range range, boolean progress) Adds page labels to a document.void
addText
(boolean metrics, Jcpdf.Pdf pdf, Jcpdf.Range range, String text, int anchor, double p1, double p2, double linespacing, int bates, int font, double fontsize, double r, double g, double b, boolean underneath, boolean cropbox, boolean outline, double opacity, int justification, boolean midline, boolean topline, String filename, double linewidth, boolean embed_fonts) Adds text to the pages in the given range.void
addTextSimple
(Jcpdf.Pdf pdf, Jcpdf.Range range, String text, int anchor, double p1, double p2, int font, double fontsize) Adds text with most parameters default.The page range contaning all pages in a given document.byte[]
annotationsJSON
(Jcpdf.Pdf pdf) Returns the annotations from a PDF in JSON format.void
attachFile
(String filename, Jcpdf.Pdf pdf) Attaches a file to the PDF.void
attachFileFromMemory
(byte[] data, String filename, Jcpdf.Pdf pdf) Attaches data from memory to a document.void
attachFileToPage
(String filename, Jcpdf.Pdf pdf, int pagenumber) Attaches a file to a page of the PDF.void
attachFileToPageFromMemory
(byte[] data, String filename, Jcpdf.Pdf pdf, int pagenumber) Attaches data to a page from memory.void
blackFills
(Jcpdf.Pdf pdf, Jcpdf.Range range) Blackens all fills on the given pages.void
blackLines
(Jcpdf.Pdf pdf, Jcpdf.Range range) Blackens all lines on the given pages.void
blackText
(Jcpdf.Pdf pdf, Jcpdf.Range range) Blackens all text on the given pages.blankDocument
(double w, double h, int pages) Creates a blank document with pages of the given width (in points), height (in points), and number of pages.blankDocumentPaper
(int papersize, int pages) Makes a blank document given a page size and number of pages.The range containing no pages.void
centerWindow
(Jcpdf.Pdf pdf, boolean flag) Sets the center window flag.double
cmOfPt
(double f) Converts a figure in points to centimetres.combinePages
(Jcpdf.Pdf under, Jcpdf.Pdf over) Combines the two PDFs page-by-page, putting each page of 'over' over each page of 'under'.void
Compresses any uncompressed streams in the given PDF using the Flate algorithm.void
copyFont
(Jcpdf.Pdf from_pdf, Jcpdf.Pdf to_pdf, Jcpdf.Range range, int pagenumber, String fontname) Copies the given font from the given page in the 'from' PDF to every page in the 'to' PDF.void
Copies the/ID
from one document to another.void
createMetadata
(Jcpdf.Pdf pdf) Builds fresh XMP metadata as best it can from existing metadata in the document.void
crop
(Jcpdf.Pdf pdf, Jcpdf.Range range, double x, double y, double w, double h) Crops a page, replacing any existing crop box.dateStringOfComponents
(int year, int month, int day, int hour, int minute, int second, int hour_offset, int minute_offset) Builds a PDF date string from individual components.void
decompress
(Jcpdf.Pdf pdf) Decompresses any streams in the given PDF, so long as the compression method is supported.void
decryptPdf
(Jcpdf.Pdf pdf, String userpw) Attempts to decrypt a PDF using the given user password.void
decryptPdfOwner
(Jcpdf.Pdf pdf, String ownerpw) Attempts to decrypt a PDF using the given owner password.difference
(Jcpdf.Range r, Jcpdf.Range s) The range containing all pages in the first given range which are not in the second.void
displayDocTitle
(Jcpdf.Pdf pdf, boolean flag) Sets the display document title flag.void
draft
(Jcpdf.Pdf pdf, Jcpdf.Range range, boolean boxes) Removes images on the given pages, replacing them with crossed boxes ifboxes
istrue
.int
encryptionKind
(Jcpdf.Pdf pdf) Returns the encryption method currently in use on a document, such asaes256bitisofalse
.void
Ends enumeration of currently allocated PDFs.void
Lists information about attachments.void
Ends the bookmark retrieval process, cleaning up.void
Retrieves font information.void
Gets image data, including resolution at all points of use.void
Ends retrieval of optional content group names.void
Gets page label data.void
Ends the bookmark setting process, writing the bookmarks to the given PDF.enumeratePDFsInfo
(int n) Returns the info for a given PDF number.int
enumeratePDFsKey
(int n) Returns the key for a given PDF number.even
(Jcpdf.Range r) The page range containing all even-numbered pages from an existing range.void
Sets the fit window flag.Loads a PDF document from a file.fromFileLazy
(String filename, String userpw) Loads a PDF document from a file, doing only minimal parsing.Loads a PDF from a JSON file given its filename.fromJSONMemory
(byte[] data) Loads a PDF from a JSON file in memory.fromMemory
(byte[] data, String userpw) Loads a PDF document from memory.fromMemoryLazy
(byte[] data, String userpw) Loads a file from memory and the user password, but lazily likefromFileLazy
.void
fromMemoryLazyRelease
(byte[] data) Releases memory returned fromfromMemoryLazy
void
These functions get a box given the document.byte[]
getAttachmentData
(int serial) Gets the attachment data itself, given a serial number.getAttachmentName
(int serial) Gets the name of an attachment, given a serial number.int
getAttachmentPage
(int serial) Gets the page number, given a serial number.Returns the author of a document.getAuthorXMP
(Jcpdf.Pdf pdf) Returns the XMP author of a document.void
getBleedBox
(Jcpdf.Pdf pdf, int pagenumber, double[] r) These functions get a box given the document.int
getBookmarkLevel
(int serial) Gets the bookmark level for the given bookmark0...(n - 1)
.boolean
getBookmarkOpenStatus
(int serial) Returnstrue
if the bookmark is open.int
getBookmarkPage
(Jcpdf.Pdf pdf, int serial) Gets the bookmark target page for the given PDF (which must be the same as the PDF passed tostartGetBookmarkInfo
) and bookmark0...(n - 1)
.byte[]
Returns the bookmark data in JSON format.getBookmarkText
(int serial) Returns the text of bookmark0...(n - 1))
getCreationDate
(Jcpdf.Pdf pdf) Returns the creation date of a document.Returns the XMP creation date of a document.getCreator
(Jcpdf.Pdf pdf) Returns the creator of a document.getCreatorXMP
(Jcpdf.Pdf pdf) Returns the XMP creator of a document.void
getCropBox
(Jcpdf.Pdf pdf, int pagenumber, double[] r) These functions get a box given the document.void
getDateComponents
(String datestring, int[] r) Returns the components from a PDF date string in an array of length 8.byte[]
getDictEntries
(Jcpdf.Pdf pdf, String key) Returns a JSON array containing any and all values associated with the given key, and fills in its length.getFontEncoding
(int serial) Retrieves font information.getFontName
(int serial) Retrieves font information.int
getFontPage
(int serial) Retrieves font information.getFontType
(int setial) Retrieves font information.getImageResolutionImageName
(int serial) Gets image data, including resolution at all points of use.int
getImageResolutionPageNumber
(int serial) Gets image data, including resolution at all points of use.int
getImageResolutionXPixels
(int serial) Gets image data, including resolution at all points of use.double
getImageResolutionXRes
(int serial) Gets image data, including resolution at all points of use.int
getImageResolutionYPixels
(int serial) Gets image data, including resolution at all points of use.double
getImageResolutionYRes
(int serial) Gets image data, including resolution at all points of use.getKeywords
(Jcpdf.Pdf pdf) Returns the keywords of a document.getKeywordsXMP
(Jcpdf.Pdf pdf) Returns the XMP keywords of a document.int
getMajorVersion
(Jcpdf.Pdf pdf) Returns the major version number of a document.void
getMediaBox
(Jcpdf.Pdf pdf, int pagenumber, double[] r) These functions get a box given the document.byte[]
getMetadata
(Jcpdf.Pdf pdf) Returns the XMP metadata from a document.Returns the modification date of a document.Returns the XMP modification date of a document.int
getPageLabelOffset
(int n) Gets page label data.getPageLabelPrefix
(int n) Gets page label data.int
getPageLabelRange
(int n) Gets page label data.getPageLabelStringForPage
(Jcpdf.Pdf pdf, int pagenumber) Calculates the full label string for a given page, and returns it.int
getPageLabelStyle
(int n) Gets page label data.int
getPageRotation
(Jcpdf.Pdf pdf, int pagenumber) Gets the viewing rotation for a given page.getProducer
(Jcpdf.Pdf pdf) Returns the producer of a document.getProducerXMP
(Jcpdf.Pdf pdf) Returns the XMP producer of a document.getSubject
(Jcpdf.Pdf pdf) Returns the subject of a document.getSubjectXMP
(Jcpdf.Pdf pdf) Returns the XMP subject of a document.Returns the title of a document.getTitleXMP
(Jcpdf.Pdf pdf) Returns the XMP title of a document.void
getTrimBox
(Jcpdf.Pdf pdf, int pagenumber, double[] r) These functions get a box given the document.int
getVersion
(Jcpdf.Pdf pdf) Returns the minor version number of a document.void
hardBox
(Jcpdf.Pdf pdf, Jcpdf.Range range, String box) Makes a given box a 'hard box' i.e clips it explicitly.boolean
Returnstrue
if the given page has the given box.boolean
hasPermission
(Jcpdf.Pdf pdf, int permission) Returnstrue
if the given permission (restriction) such asnoEdit
is present.void
hFlip
(Jcpdf.Pdf pdf, Jcpdf.Range range) Flips horizontally the pages in the range.void
hideMenubar
(Jcpdf.Pdf pdf, boolean flag) Sets the hide menubar flag.void
hideToolbar
(Jcpdf.Pdf pdf, boolean flag) Sets the hide toolbar flag.void
hideWindowUi
(Jcpdf.Pdf pdf, boolean flag) Sets the hide window UI flag.void
impose
(Jcpdf.Pdf pdf, double x, double y, boolean fit, boolean columns, boolean rtl, boolean btt, boolean center, double margin, double spacing, double linewidth) Imposes a PDF.double
inOfPt
(double f) Converts a figure in points to millimetres.boolean
isEncrypted
(Jcpdf.Pdf pdf) Returnstrue
if a document is encrypted,false
otherwise.boolean
isInRange
(Jcpdf.Range r, int n) Tests to see if a given number is in a page range.boolean
isLinearized
(String filename) Finds out if a document is linearized as quickly as possible without loading it.void
markTrapped
(Jcpdf.Pdf pdf) Marks a document as trapped.void
markTrappedXMP
(Jcpdf.Pdf pdf) Marks a document as trapped in XMP metadata.void
markUntrapped
(Jcpdf.Pdf pdf) Marks a document as untrapped.void
Marks a document as untrapped in XMP metadata.Merges the PDFs.mergeSame
(Jcpdf.Pdf[] pdfs, boolean retain_numbering, boolean remove_duplicate_fonts, Jcpdf.Range[] ranges) Merges PDFs when one or more are drawn from the same document.mergeSimple
(Jcpdf.Pdf[] pdfs) Given an array of PDFs, merges the documents into a new one, which is returned.double
mmOfPt
(double f) Converts a figure in points to millimetres.int
Gets the number of bookmarks for the PDF given tostartGetBookmarkInfo
.int
Retrieves font information.int
Lists information about attachments.void
OCGCoalesce
(Jcpdf.Pdf pdf) Coalesces optional content groups.OCGListEntry
(int serial) Retrieves an entry in the optional content group list, given the serial number0..n - 1
.void
OCGOrderAll
(Jcpdf.Pdf pdf) Ensures that every optional content group appears in the OCG order list.void
Renames an optional content group.odd
(Jcpdf.Range r) The page range containing all odd-numbered pages from an existing range.void
onExit()
Prints some information about resource usage.void
openAtPage
(Jcpdf.Pdf pdf, boolean fit, int pagenumber) Sets the PDF to open, possibly with zoom-to-fit, at the given page number.void
outputJSON
(String filename, boolean parse_content, boolean no_stream_data, boolean decompress_streams, Jcpdf.Pdf pdf) Outputs a PDF in JSON format to the given filename.byte[]
outputJSONMemory
(Jcpdf.Pdf pdf, boolean parse_content, boolean no_stream_data, boolean decompress_streams) Like outputJSON, but it writes to a byte array in memory.void
padAfter
(Jcpdf.Pdf pdf, Jcpdf.Range range) Adds a blank page after each page in the given range.void
padBefore
(Jcpdf.Pdf pdf, Jcpdf.Range range) Adds a blank page before each page in the given range.void
Adds a blank page after every n pages.void
padMultiple
(Jcpdf.Pdf pdf, int n) Adds pages at the end to pad the file to a multiple of n pages in length.void
padMultipleBefore
(Jcpdf.Pdf pdf, int n) Adds pages at the beginning to pad the file to a multiple of n pages in length.int
Returns the number of pages in a PDF.int
Returns the number of pages in a given PDF, with given user password.parsePagespec
(Jcpdf.Pdf pdf, String pagespec) Parses a page specification such as1,2,6-end
with reference to a given PDF.double
ptOfCm
(double f) Converts a figure in centimetres to points.double
ptOfIn
(double f) Converts a figure in inches to points (72.double
ptOfMm
(double f) Converts a figure in millimetres to points.range
(int from, int to) The page range containing all page numbers from one page number to another.rangeAdd
(Jcpdf.Range r, int n) Adds a page number to a range, returning a new one.int
rangeGet
(Jcpdf.Range r, int n) Gets a page number from a range at the given offset.int
The length of a range.rangeUnion
(Jcpdf.Range r, Jcpdf.Range s) The union of two ranges - all those pages in either.void
removeAllText
(Jcpdf.Pdf pdf, Jcpdf.Range range) Removes all text from the given pages in a given document.void
removeArt
(Jcpdf.Pdf pdf, Jcpdf.Range range) Removes any art box from pages in the range.void
Removes all page- and document-level attachments from a document.void
removeBleed
(Jcpdf.Pdf pdf, Jcpdf.Range range) Removes any bleed box from pages in the range.void
removeClipping
(Jcpdf.Pdf pdf, Jcpdf.Range range) Removes all clipping from pages in the given range.void
removeCrop
(Jcpdf.Pdf pdf, Jcpdf.Range range) Removes any crop box from pages in the range.void
removeDictEntry
(Jcpdf.Pdf pdf, String key) Removes any dictionary entry with the given key anywhere in the document.void
removeDictEntrySearch
(Jcpdf.Pdf pdf, String key, String searchterm) Removes any dictionary entry with the given key whose value matches the given search term.Remove duplicates from a range, returning a new one.void
removeFonts
(Jcpdf.Pdf pdf) Removes all font data from a file.void
Removes a document's/ID
.void
removeMetadata
(Jcpdf.Pdf pdf) Removes the XMP metadata from a document.void
Removes the page labels from the document.void
removeText
(Jcpdf.Pdf pdf, Jcpdf.Range range) Removes any text added by Jcpdf from the given pages.void
removeTrim
(Jcpdf.Pdf pdf, Jcpdf.Range range) Removes any trim box from pages in the range.void
replaceDictEntry
(Jcpdf.Pdf pdf, String key, String newvalue) Replaces the value associated with the given key.void
replaceDictEntrySearch
(Jcpdf.Pdf pdf, String key, String newvalue, String searchterm) Replaces the value associated with the given key if the existing value matches the search term.void
rotate
(Jcpdf.Pdf pdf, Jcpdf.Range range, int angle) Changes the viewing rotation to an absolute value.void
rotateBy
(Jcpdf.Pdf pdf, Jcpdf.Range range, int angle) Changes the viewing rotation by a relative value.void
rotateContents
(Jcpdf.Pdf pdf, Jcpdf.Range range, double angle) Rotates the content about the centre of the page by the given number of degrees, in a clockwise direction.void
scaleContents
(Jcpdf.Pdf pdf, Jcpdf.Range range, int anchor, double p1, double p2, double scale) Scales the contents of the pages in the range about the point given by theanchor
,p1
andp2
by the scale given.void
scalePages
(Jcpdf.Pdf pdf, Jcpdf.Range range, double sx, double sy) Scales the page dimensions and content by the given scale, about (0, 0).void
scaleToFit
(Jcpdf.Pdf pdf, Jcpdf.Range range, double w, double h, double scale) Scales the content to fit new page dimensions (width x height) multiplied by scale (typically 1.0).void
scaleToFitPaper
(Jcpdf.Pdf pdf, Jcpdf.Range range, int papersize, double scale) Scales the page content to fit the given page size, possibly multiplied by scale (typically 1.0).selectPages
(Jcpdf.Pdf pdf, Jcpdf.Range range) Returns a new document with just those pages in the page range.void
setArtBox
(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) These functions set a box given the document, page range, min x, max x, min y, max y in points.void
Sets the author of a document.void
setAuthorXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP author of a document.void
setBleedBox
(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) These functions set a box given the document, page range, min x, max x, min y, max y in points.void
setBookmarkLevel
(int serial, int level) Set bookmark level for the given bookmark0...(n - 1)
.void
setBookmarkOpenStatus
(int serial, boolean open) Sets the open status of bookmark0...(n - 1)
.void
setBookmarkPage
(Jcpdf.Pdf pdf, int serial, int pagenum) Sets the bookmark target page for the given PDF (which must be the same as the PDF to be passed toendSetBookmarkInfo
) and bookmark0...(n - 1)
.void
setBookmarksJSON
(Jcpdf.Pdf pdf, byte[] data) Sets the bookmarks from JSON bookmark data.void
setBookmarkText
(int serial, String text) Sets the text of bookmark0...(n - 1)
.void
setCreationDate
(Jcpdf.Pdf pdf, String str) Sets the creation date of a document.void
setCreationDateXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP creation date of a document.void
setCreator
(Jcpdf.Pdf pdf, String str) Sets the creator of a document.void
setCreatorXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP creator of a document.void
setCropBox
(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) These functions set a box given the document, page range, min x, max x, min y, max y in points.void
setFast()
Sets fast mode.void
setFullVersion
(Jcpdf.Pdf pdf, int major, int minor) Sets the full version number of a document.void
setKeywords
(Jcpdf.Pdf pdf, String str) Sets the keywords of a document.void
setKeywordsXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP keywords of a document.void
setMediabox
(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) These functions set a box given the document page range, min x, max x, min y, max y in points.void
setMetadataDate
(Jcpdf.Pdf pdf, String date) Sets the metadata date for a PDF.void
setMetadataFromByteArray
(Jcpdf.Pdf pdf, byte[] data) Sets the XMP metadata from an array of bytes.void
setMetadataFromFile
(Jcpdf.Pdf pdf, String filename) Sets the XMP metadata of a document, given a file name.void
setModificationDate
(Jcpdf.Pdf pdf, String str) Sets the modification date of a document.void
setModificationDateXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP modification date of a document.void
setPageLayout
(Jcpdf.Pdf pdf, int layout) Sets the page layout for a document, such assinglePage
void
setPageMode
(Jcpdf.Pdf pdf, int mode) Sets the page mode for a document, such asuseNone
void
setProducer
(Jcpdf.Pdf pdf, String str) Sets the producer of a document.void
setProducerXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP producer of a document.void
setSlow()
Sets slow mode.void
setSubject
(Jcpdf.Pdf pdf, String str) Sets the subject of a document.void
setSubjectXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP subject of a document.void
Sets the title of a document.void
setTitleXMP
(Jcpdf.Pdf pdf, String str) Sets the XMP title of a document.void
setTrimBox
(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) These functions set a box given the document, page range, min x, max x, min y, max y in points.void
setVersion
(Jcpdf.Pdf pdf, int version) Sets the minor version number of a document.void
shiftContents
(Jcpdf.Pdf pdf, Jcpdf.Range range, double dx, double dy) Shifts the content of the pages in the range.void
showBoxes
(Jcpdf.Pdf pdf, Jcpdf.Range range) Shows the boxes on the given pages, for debug.void
squeezeInMemory
(Jcpdf.Pdf pdf) Squeezes a pdf in memory.stampAsXObject
(Jcpdf.Pdf pdf, Jcpdf.Range range, Jcpdf.Pdf stamp_pdf) Stamps a PDF onto the pages in the given range in pdf as a shared Form XObject.void
stampExtended
(Jcpdf.Pdf pdf, Jcpdf.Pdf pdf2, Jcpdf.Range range, boolean isover, boolean scale_stamp_to_fit, int anchor, double p1, double p2, boolean relative_to_cropbox) A stamping function with extra features.void
stampOn
(Jcpdf.Pdf stamp_pdf, Jcpdf.Pdf pdf, Jcpdf.Range range) Stamps another PDF on top of all the pages in the document which are in the range.void
stampUnder
(Jcpdf.Pdf stamp_pdf, Jcpdf.Pdf pdf, Jcpdf.Range range) Stamps another PDF under all the pages in the document which are in the range.int
Begins enumerating currently allocated PDFs.void
Lists information about attachments.void
Starts the bookmark retrieval process for a given PDF.void
Retrieves font information.int
startGetImageResolution
(Jcpdf.Pdf pdf, double res) Gets image data, including resolution at all points of use.int
startGetOCGList
(Jcpdf.Pdf pdf) Begins retrieving optional content group names.int
Gets page label data.void
startSetBookmarkInfo
(int n) Starts the bookmark setting process for n bookmarks.void
startup()
Initialises the library.stringOfPagespec
(Jcpdf.Pdf pdf, Jcpdf.Range r) Builds a page specification from a page range.void
tableOfContents
(Jcpdf.Pdf pdf, int font, double fontsize, String title, boolean bookmark) Typesets a table of contents from existing bookmarks and prepends it to the document.Typesets a UTF8 text file ragged right on a page of size w * h in points in the given font and font size.textToPDFPaper
(int papersize, int font, double fontsize, String filename) Typesets a UTF8 text file ragged right on a page of the given size in the given font and font size.int
Returns the width of a given string in the given font in thousandths of a point.void
thinLines
(Jcpdf.Pdf pdf, Jcpdf.Range range, double min_thickness) Thickens every line less thanmin_thickness
tomin_thickness
.void
Writes the PDF document to a given filename.void
toFileEncrypted
(Jcpdf.Pdf pdf, int encryption_method, int[] permissions, String owner_password, String user_password, boolean linearize, boolean makeid, String filename) Writes a PDF document as encrypted.void
toFileEncryptedExt
(Jcpdf.Pdf pdf, int encryption_method, int[] permissions, String owner_password, String user_password, boolean linearize, boolean makeid, boolean preserve_objstm, boolean generate_objstm, boolean compress_objstm, String filename) Writes a file as encrypted with extra parameters.void
toFileExt
(Jcpdf.Pdf pdf, String filename, boolean linearize, boolean make_id, boolean preserve_objstm, boolean create_objstm, boolean compress_objstm) Writes the PDF document to a given filename, with extra parameters.byte[]
Writes a PDF document and returns it as an array of bytes.void
trimMarks
(Jcpdf.Pdf pdf, Jcpdf.Range range) Adds trim marks to the given pages, if the trimbox exists.void
Imposes a document two up.void
twoUpStack
(Jcpdf.Pdf pdf) Imposes a document two up.void
upright
(Jcpdf.Pdf pdf, Jcpdf.Range range) Changes the viewing rotation of the pages in the range, counter-rotating the dimensions and content such that there is no visual change.boolean
validatePagespec
(String pagespec) Validates a page specification so far as is possible in the absence of the actual document.version()
Returns a string giving the version number of the Jcpdf library.void
vFlip
(Jcpdf.Pdf pdf, Jcpdf.Range range) Flips vertically the pages in the range.
-
Field Details
-
noEdit
public static int noEditPermission: cannot edit the document -
noPrint
public static int noPrintPermission: cannot print the document -
noCopy
public static int noCopyPermission: cannot copy the document -
noAnnot
public static int noAnnotPermission: cannot annotate the document -
noForms
public static int noFormsPermission: cannot edit forms in the document -
noExtract
public static int noExtractPermission: cannot extract information -
noAssemble
public static int noAssemblePermission: cannot assemble into a bigger document -
noHqPrint
public static int noHqPrintPermission: cannot print high quality -
pdf40bit
public static int pdf40bitEncryption method: 40 bit RC4 encryption -
pdf128bit
public static int pdf128bitEncryption method: 128 bit RC4 encryption -
aes128bitfalse
public static int aes128bitfalseEncryption method: 128 bit AES encryption, do not encrypt metadata -
aes128bittrue
public static int aes128bittrueEncryption method: 128 bit AES encryption, encrypt metadata -
aes256bitfalse
public static int aes256bitfalseEncryption method: Deprecated. Do not use for new files -
aes256bittrue
public static int aes256bittrueEncryption method: Deprecated. Do not use for new files -
aes256bitisofalse
public static int aes256bitisofalseEncryption method: 256 bit AES encryption, do not encrypt metadata -
aes256bitisotrue
public static int aes256bitisotrueEncryption method: 256 bit AES encryption, encrypt metadata -
decimalArabic
public static int decimalArabicPage label style: 1, 2, 3... -
uppercaseRoman
public static int uppercaseRomanPage label style: I, II, III... -
lowercaseRoman
public static int lowercaseRomanPage label style: i, ii, iii... -
uppercaseLetters
public static int uppercaseLettersPage label style: A, B, C... -
lowercaseLetters
public static int lowercaseLettersPage label style: a, b, c... -
singlePage
public static int singlePageLayout: single page -
oneColumn
public static int oneColumnLayout: one column -
twoColumnLeft
public static int twoColumnLeftLayout: two column left -
twoColumnRight
public static int twoColumnRightLayout: two column right -
twoPageLeft
public static int twoPageLeftLayout: two page left -
twoPageRight
public static int twoPageRightLayout: two page right -
useNone
public static int useNonePage mode: use none -
useOutlines
public static int useOutlinesPage mode: use outlines -
useThumbs
public static int useThumbsPage mode: use thumbs -
useOC
public static int useOCPage mode: use OC -
useAttachments
public static int useAttachmentsPage mode: use Attachments -
a0portrait
public static int a0portraitPaper size: A0 Portrait -
a1portrait
public static int a1portraitPaper size: A1 Portrait -
a2portrait
public static int a2portraitPaper size: A2 Portrait -
a3portrait
public static int a3portraitPaper size: A3 Portrait -
a4portrait
public static int a4portraitPaper size: A4 Portrait -
a5portrait
public static int a5portraitPaper size: A5 Portrait -
a0landscape
public static int a0landscapePaper size: A0 Landscape -
a1landscape
public static int a1landscapePaper size: A1 Landscape -
a2landscape
public static int a2landscapePaper size: A2 Landscape -
a3landscape
public static int a3landscapePaper size: A3 Landscape -
a4landscape
public static int a4landscapePaper size: A4 Landscape -
a5landscape
public static int a5landscapePaper size: A5 Landscape -
usletterportrait
public static int usletterportraitPaper size: US Letter Portrait -
usletterlandscape
public static int usletterlandscapePaper size: US Letter Landscape -
uslegalportrait
public static int uslegalportraitPaper size: US Legal Portrait -
uslegallandscape
public static int uslegallandscapePaper size: US Legal Landscape -
timesRoman
public static int timesRomanStandard font: Times Roman -
timesBold
public static int timesBoldStandard font: Times Bold -
timesItalic
public static int timesItalicStandard font: Times Italic -
timesBoldItalic
public static int timesBoldItalicStandard font: Times Bold Italic -
helvetica
public static int helveticaStandard font: Helvetica -
helveticaBold
public static int helveticaBoldStandard font: Helvetica Bold -
helveticaOblique
public static int helveticaObliqueStandard font: Helvetica Oblique -
helveticaBoldOblique
public static int helveticaBoldObliqueStandard font: Helvetica Bold Oblique -
courier
public static int courierStandard font: Courier -
courierBold
public static int courierBoldStandard font: Courier Bold -
courierOblique
public static int courierObliqueStandard font: Courier Oblique -
courierBoldOblique
public static int courierBoldObliqueStandard font: Courier Bold Oblique -
posCentre
public static int posCentrePosition anchor: absolute centre. Takes two numbers, x and y. -
posLeft
public static int posLeftPosition anchor: absolute left. Takes two numbers, x and y. -
posRight
public static int posRightPosition anchor: absolute right. Takes two numbers, x and y. -
top
public static int topPosition anchor: the top centre of the page. Takes one number - distance from top. Second number ignored. -
topLeft
public static int topLeftPosition anchor: the top left of the page. Takes one numbers - distance from top left. Second number ignored. -
topRight
public static int topRightPosition anchor: the top right of the page. Takes one number - distance from top right. Second number ignored. -
left
public static int leftPosition anchor: the left hand side of the page, halfway down. Takes one number - distance from left middle. Second number ignored. -
bottomLeft
public static int bottomLeftPosition anchor: the bottom left of the page. Takes one number - distance from bottom left. Second number ignored. -
bottom
public static int bottomPosition anchor: the bottom middle of the page. Takes one number - distance from bottom middle. Second number ignored. -
bottomRight
public static int bottomRightPosition anchor: the bottomm right of the page. Takes one number - distance from bottom right. Second number ignored. -
right
public static int rightPosition anchor: the right hand side of the page, halfway down. Takes one number - distance from right middle. Second number ignored. -
diagonal
public static int diagonalPosition anchor: diagonal, bottom left to top right. Takes no numbers. Both numbers ignored. -
reverseDiagonal
public static int reverseDiagonalPosition anchor: diagonal, top left to bottom right. Takes no numbers. Both numbers ignored. -
leftJustify
public static int leftJustifyJustification: left -
centreJustify
public static int centreJustifyJustification: centre -
rightJusitfy
public static int rightJusitfyJustification: right
-
-
Constructor Details
-
Jcpdf
public Jcpdf()Create a new instance of the Jcpdf library. You must use
too, before calling any other function.startup()
-
-
Method Details
-
startup
Initialises the library. Must be called before any other function.- Throws:
Jcpdf.CpdfError
-
version
Returns a string giving the version number of the Jcpdf library.- Throws:
Jcpdf.CpdfError
-
setFast
Sets fast mode. Some operations have a fast mode. The default is 'slow' mode, which works even on old-fashioned files. For more details, see section 1.13 of the CPDF manual. This functions sets the mode to fast globally.- Throws:
Jcpdf.CpdfError
-
setSlow
Sets slow mode. Some operations have a fast mode. The default is 'slow' mode, which works even on old-fashioned files. For more details, see section 1.13 of the CPDF manual. This functions sets the mode to slow globally.- Throws:
Jcpdf.CpdfError
-
onExit
public void onExit()Prints some information about resource usage. This can be used to detect if PDFs or ranges are being deallocated properly. Contrary to its name, it may be run at any time. -
fromFile
Loads a PDF document from a 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:
filename
- file nameuserpw
- user password- Throws:
Jcpdf.CpdfError
-
fromFileLazy
Loads a PDF document 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:
filename
- file nameuserpw
- user password- Throws:
Jcpdf.CpdfError
-
fromMemory
Loads a PDF document from memory. 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:
data
- byte array containing the PDF fileuserpw
- user password- Throws:
Jcpdf.CpdfError
-
fromMemoryLazy
Loads a file from memory and the user password, but lazily likefromFileLazy
. The caller must usefromMemoryLazyRelease
to free the memory. It must not free the memory until the PDF is also gone.- Throws:
Jcpdf.CpdfError
-
fromMemoryLazyRelease
Releases memory returned fromfromMemoryLazy
- Parameters:
data
- byte array previously passed tofromMemoryLazy
- Throws:
Jcpdf.CpdfError
-
startEnumeratePDFs
Begins enumerating currently allocated PDFs.To enumerate the list of currently allocated PDFs, call
startEnumeratePDFs
which gives the number,n
, of PDFs allocated, thenenumeratePDFsInfo
andenumeratePDFsKey
with index numbers from0...(n - 1)
. CallendEnumeratePDFs
to clean up.- Throws:
Jcpdf.CpdfError
-
enumeratePDFsKey
Returns the key for a given PDF number.To enumerate the list of currently allocated PDFs, call
startEnumeratePDFs
which gives the number,n
, of PDFs allocated, thenenumeratePDFsInfo
andenumeratePDFsKey
with index numbers from0...(n - 1)
. CallendEnumeratePDFs
to clean up.- Throws:
Jcpdf.CpdfError
-
enumeratePDFsInfo
Returns the info for a given PDF number.To enumerate the list of currently allocated PDFs, call
startEnumeratePDFs
which gives the number,n
, of PDFs allocated, thenenumeratePDFsInfo
andenumeratePDFsKey
with index numbers from0...(n - 1)
. CallendEnumeratePDFs
to clean up.- Throws:
Jcpdf.CpdfError
-
endEnumeratePDFs
Ends enumeration of currently allocated PDFs.To enumerate the list of currently allocated PDFs, call
startEnumeratePDFs
which gives the number,n
, of PDFs allocated, thenenumeratePDFsInfo
andenumeratePDFsKey
with index numbers from0...(n - 1)
. CallendEnumeratePDFs
to clean up.- Throws:
Jcpdf.CpdfError
-
ptOfCm
Converts a figure in centimetres to points. (72 points to 1 inch)- Throws:
Jcpdf.CpdfError
-
ptOfMm
Converts a figure in millimetres to points. (72 points to 1 inch)- Throws:
Jcpdf.CpdfError
-
ptOfIn
Converts a figure in inches to points (72. points to 1 inch)- Throws:
Jcpdf.CpdfError
-
cmOfPt
Converts a figure in points to centimetres. (72 points to 1 inch)- Throws:
Jcpdf.CpdfError
-
mmOfPt
Converts a figure in points to millimetres. (72 points to 1 inch)- Throws:
Jcpdf.CpdfError
-
inOfPt
Converts a figure in points to millimetres. (72 points to 1 inch)- Throws:
Jcpdf.CpdfError
-
parsePagespec
Parses a page specification such as1,2,6-end
with reference to a given PDF. (The PDF is supplied so that page ranges which reference pages which do not exist are rejected).- Parameters:
pdf
- PDF documentpagespec
- page specification- Throws:
Jcpdf.CpdfError
-
validatePagespec
Validates a page specification so far as is possible in the absence of the actual document. Result istrue
if valid.- Throws:
Jcpdf.CpdfError
-
stringOfPagespec
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:
pdf
- PDF documentr
- page range- Throws:
Jcpdf.CpdfError
-
blankRange
The range containing no pages.- Throws:
Jcpdf.CpdfError
-
range
The page range containing all page numbers from one page number to another.- Parameters:
from
- page number to begin at (inclusive)to
- page number to end at (inclusive)- Throws:
Jcpdf.CpdfError
-
all
The page range contaning all pages in a given document.- Throws:
Jcpdf.CpdfError
-
odd
The page range containing all odd-numbered pages from an existing range.- Throws:
Jcpdf.CpdfError
-
even
The page range containing all even-numbered pages from an existing range.- Throws:
Jcpdf.CpdfError
-
rangeUnion
The union of two ranges - all those pages in either.- Throws:
Jcpdf.CpdfError
-
difference
The range containing all pages in the first given range which are not in the second.- Throws:
Jcpdf.CpdfError
-
removeDuplicates
Remove duplicates from a range, returning a new one.- Throws:
Jcpdf.CpdfError
-
rangeLength
The length of a range.- Throws:
Jcpdf.CpdfError
-
rangeGet
Gets a page number from a range at the given offset.- Throws:
Jcpdf.CpdfError
-
rangeAdd
Adds a page number to a range, returning a new one.- Throws:
Jcpdf.CpdfError
-
isInRange
Tests to see if a given number is in a page range.- Throws:
Jcpdf.CpdfError
-
pages
Returns the number of pages in a PDF.- Throws:
Jcpdf.CpdfError
-
pagesFast
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:
userpw
- user passwordfilename
- file name- Throws:
Jcpdf.CpdfError
-
toFile
public void toFile(Jcpdf.Pdf pdf, String filename, boolean linearize, boolean make_id) throws Jcpdf.CpdfError Writes the PDF document to a given filename. Iflinearize
istrue
, it will be linearized if a linearizer is available. Ifmake_id
istrue
, it will be given a new ID.- Parameters:
pdf
- PDF documentfilename
- file namelinearize
- linearizemake_id
- make new ID- Throws:
Jcpdf.CpdfError
-
toFileExt
public void toFileExt(Jcpdf.Pdf pdf, String filename, boolean linearize, boolean make_id, boolean preserve_objstm, boolean create_objstm, boolean compress_objstm) throws Jcpdf.CpdfError Writes the PDF document to a given filename, with extra parameters. Ifmake_id
is true, it will be given a new ID. Ifpreserve_objstm
is true, existing object streams will be preserved. Ifgenerate_objstm
is true, object streams will be generated even if not originally present. Ifcompress_objstm
is true, object streams will be compressed (what we usually want). WARNING: the pdf argument will be invalid after this call, and should not be used again.- Parameters:
pdf
- PDF documentfilename
- file namelinearize
- linearizemake_id
- make new IDpreserve_objstm
- preserve object streamscreate_objstm
- create new object streamscompress_objstm
- compress object streams- Throws:
Jcpdf.CpdfError
-
toMemory
Writes a PDF document and returns it as an array of bytes.- Parameters:
pdf
- PDF documentlinearize
- linearizemake_id
- make new ID- Throws:
Jcpdf.CpdfError
-
isEncrypted
Returnstrue
if a document is encrypted,false
otherwise.- Throws:
Jcpdf.CpdfError
-
decryptPdf
Attempts to decrypt a PDF using the given user password. An exception is raised if the decryption fails.- Parameters:
pdf
- PDF documentuserpw
- user password- Throws:
Jcpdf.CpdfError
-
decryptPdfOwner
Attempts to decrypt a PDF using the given owner password. Raises an exception if the decryption fails.- Parameters:
pdf
- PDF documentownerpw
- owner password- Throws:
Jcpdf.CpdfError
-
toFileEncrypted
public void toFileEncrypted(Jcpdf.Pdf pdf, int encryption_method, int[] permissions, String owner_password, String user_password, boolean linearize, boolean makeid, String filename) throws Jcpdf.CpdfError Writes a PDF document as encrypted. The encryption method and permissions are drawn from Jcpdf's fields, documented above.- Parameters:
pdf
- PDF documentencryption_method
- encryption method, e.gaes256bitisofalse
permissions
- array of permissions e.gnoEdit
owner_password
- owner passworduser_password
- user passwordlinearize
- linearizemakeid
- make new IDfilename
- file name- Throws:
Jcpdf.CpdfError
-
toFileEncryptedExt
public void toFileEncryptedExt(Jcpdf.Pdf pdf, int encryption_method, int[] permissions, String owner_password, String user_password, boolean linearize, boolean makeid, boolean preserve_objstm, boolean generate_objstm, boolean compress_objstm, String filename) throws Jcpdf.CpdfError 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:
pdf
- PDF documentencryption_method
- encryption method, e.gaes256bitisofalse
permissions
- array of permissions e.gnoEdit
owner_password
- owner passworduser_password
- user passwordlinearize
- linearizemakeid
- make new IDpreserve_objstm
- preserve existing object streamsgenerate_objstm
- generate new object streamscompress_objstm
- compress object streamsfilename
- file name- Throws:
Jcpdf.CpdfError
-
hasPermission
Returnstrue
if the given permission (restriction) such asnoEdit
is present.- Throws:
Jcpdf.CpdfError
-
encryptionKind
Returns the encryption method currently in use on a document, such asaes256bitisofalse
.- Throws:
Jcpdf.CpdfError
-
mergeSimple
Given an array of PDFs, merges the documents into a new one, which is returned.- Throws:
Jcpdf.CpdfError
-
merge
public Jcpdf.Pdf merge(Jcpdf.Pdf[] pdfs, boolean retain_numbering, boolean remove_duplicate_fonts) throws Jcpdf.CpdfError Merges the PDFs. Ifretain_numbering
is true page labels are not rewritten. Ifremove_duplicate_fonts
is true, duplicate fonts are merged. This is useful when the source documents for merging originate from the same source.- Parameters:
pdfs
- array of PDF documentsretain_numbering
- retain page numbering in outputremove_duplicate_fonts
- remove duplicate font data by merging- Throws:
Jcpdf.CpdfError
-
mergeSame
public Jcpdf.Pdf mergeSame(Jcpdf.Pdf[] pdfs, boolean retain_numbering, boolean remove_duplicate_fonts, Jcpdf.Range[] ranges) throws Jcpdf.CpdfError Merges PDFs when one or more are drawn from the same document. 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:
pdfs
- array of PDF documentsretain_numbering
- retain page numbering in outputremove_duplicate_fonts
- remove duplicate font data by mergingranges
- array of ranges, one for each PDF- Throws:
Jcpdf.CpdfError
-
selectPages
Returns a new document with just those pages in the page range.- Parameters:
pdf
- PDF documentrange
- range- Throws:
Jcpdf.CpdfError
-
scalePages
public void scalePages(Jcpdf.Pdf pdf, Jcpdf.Range range, double sx, double sy) throws Jcpdf.CpdfError Scales the page dimensions and content by the given scale, about (0, 0). Other boxes (crop etc. are altered as appropriate).- Parameters:
pdf
- PDF documentrange
- page rangesx
- X scalesy
- Y scale- Throws:
Jcpdf.CpdfError
-
scaleToFit
public void scaleToFit(Jcpdf.Pdf pdf, Jcpdf.Range range, double w, double h, double scale) throws Jcpdf.CpdfError 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:
pdf
- PDF documentrange
- page rangew
- width in pointsh
- height in pointsscale
- scale (typically 1.0)- Throws:
Jcpdf.CpdfError
-
scaleToFitPaper
public void scaleToFitPaper(Jcpdf.Pdf pdf, Jcpdf.Range range, int papersize, double scale) throws Jcpdf.CpdfError Scales the page content to fit the given page size, possibly multiplied by scale (typically 1.0).- Parameters:
pdf
- PDF documentrange
- page rangepapersize
- paper size, such asa0portrait
scale
- scale (typically 1.0)- Throws:
Jcpdf.CpdfError
-
scaleContents
public void scaleContents(Jcpdf.Pdf pdf, Jcpdf.Range range, int anchor, double p1, double p2, double scale) throws Jcpdf.CpdfError Scales the contents of the pages in the range about the point given by theanchor
,p1
andp2
by the scale given. See the documentation for the chosen anchor.- Parameters:
pdf
- PDF documentrange
- page rangeanchor
- position anchor, such asposCentre
p1
- position parameter 1p2
- position parameter 2scale
- scale- Throws:
Jcpdf.CpdfError
-
shiftContents
public void shiftContents(Jcpdf.Pdf pdf, Jcpdf.Range range, double dx, double dy) throws Jcpdf.CpdfError Shifts the content of the pages in the range.- Parameters:
pdf
- PDF documentrange
- page rangedx
- X shiftdy
- Y shift- Throws:
Jcpdf.CpdfError
-
rotate
Changes the viewing rotation to an absolute value. Appropriate rotations are 0, 90, 180, 270.- Parameters:
pdf
- PDF documentrange
- page rangeangle
- viewing rotation- Throws:
Jcpdf.CpdfError
-
rotateBy
Changes the viewing rotation by a relative value. Appropriate rotations are 0, 90, 180, 270.- Parameters:
pdf
- PDF documentrange
- page rangeangle
- viewing rotation- Throws:
Jcpdf.CpdfError
-
rotateContents
Rotates the content about the centre of the page by the given number of degrees, in a clockwise direction.- Parameters:
pdf
- PDF documentrange
- page rangeangle
- angle in degrees- Throws:
Jcpdf.CpdfError
-
upright
Changes the viewing rotation of the pages in the range, counter-rotating the dimensions and content such that there is no visual change.- Throws:
Jcpdf.CpdfError
-
hFlip
Flips horizontally the pages in the range.- Throws:
Jcpdf.CpdfError
-
vFlip
Flips vertically the pages in the range.- Throws:
Jcpdf.CpdfError
-
crop
public void crop(Jcpdf.Pdf pdf, Jcpdf.Range range, double x, double y, double w, double h) throws Jcpdf.CpdfError Crops a page, replacing any existing crop box. The dimensions are in points.- Parameters:
pdf
- PDF documentrange
- page rangex
- minimum Xy
- minimum Yw
- widthh
- height- Throws:
Jcpdf.CpdfError
-
removeCrop
Removes any crop box from pages in the range.- Throws:
Jcpdf.CpdfError
-
removeTrim
Removes any trim box from pages in the range.- Throws:
Jcpdf.CpdfError
-
removeArt
Removes any art box from pages in the range.- Throws:
Jcpdf.CpdfError
-
removeBleed
Removes any bleed box from pages in the range.- Throws:
Jcpdf.CpdfError
-
trimMarks
Adds trim marks to the given pages, if the trimbox exists.- Throws:
Jcpdf.CpdfError
-
showBoxes
Shows the boxes on the given pages, for debug.- Throws:
Jcpdf.CpdfError
-
hardBox
Makes a given box a 'hard box' i.e clips it explicitly.- Parameters:
pdf
- PDF documentrange
- page rangebox
- box name e.g "/CropBox"- Throws:
Jcpdf.CpdfError
-
compress
Compresses any uncompressed streams in the given PDF using the Flate algorithm.- Throws:
Jcpdf.CpdfError
-
decompress
Decompresses any streams in the given PDF, so long as the compression method is supported.- Throws:
Jcpdf.CpdfError
-
squeezeInMemory
Squeezes a pdf in memory.- Throws:
Jcpdf.CpdfError
-
startGetBookmarkInfo
Starts the bookmark retrieval process for a given PDF.- Throws:
Jcpdf.CpdfError
-
numberBookmarks
Gets the number of bookmarks for the PDF given tostartGetBookmarkInfo
.- Throws:
Jcpdf.CpdfError
-
getBookmarkLevel
Gets the bookmark level for the given bookmark0...(n - 1)
.- Throws:
Jcpdf.CpdfError
-
getBookmarkPage
Gets the bookmark target page for the given PDF (which must be the same as the PDF passed tostartGetBookmarkInfo
) and bookmark0...(n - 1)
.- Throws:
Jcpdf.CpdfError
-
getBookmarkText
Returns the text of bookmark0...(n - 1))
- Throws:
Jcpdf.CpdfError
-
getBookmarkOpenStatus
Returnstrue
if the bookmark is open.- Throws:
Jcpdf.CpdfError
-
endGetBookmarkInfo
Ends the bookmark retrieval process, cleaning up.- Throws:
Jcpdf.CpdfError
-
startSetBookmarkInfo
Starts the bookmark setting process for n bookmarks.- Throws:
Jcpdf.CpdfError
-
setBookmarkLevel
Set bookmark level for the given bookmark0...(n - 1)
.- Throws:
Jcpdf.CpdfError
-
setBookmarkPage
Sets the bookmark target page for the given PDF (which must be the same as the PDF to be passed toendSetBookmarkInfo
) and bookmark0...(n - 1)
.- Throws:
Jcpdf.CpdfError
-
setBookmarkOpenStatus
Sets the open status of bookmark0...(n - 1)
.- Throws:
Jcpdf.CpdfError
-
setBookmarkText
Sets the text of bookmark0...(n - 1)
.- Throws:
Jcpdf.CpdfError
-
endSetBookmarkInfo
Ends the bookmark setting process, writing the bookmarks to the given PDF.- Throws:
Jcpdf.CpdfError
-
getBookmarksJSON
Returns the bookmark data in JSON format.- Throws:
Jcpdf.CpdfError
-
setBookmarksJSON
Sets the bookmarks from JSON bookmark data.- Throws:
Jcpdf.CpdfError
-
tableOfContents
public void tableOfContents(Jcpdf.Pdf pdf, int font, double fontsize, String title, boolean bookmark) throws Jcpdf.CpdfError Typesets a table of contents from existing bookmarks and prepends it to the document.- Parameters:
pdf
- PDF documentfont
- font, such astimesRoman
fontsize
- font sizetitle
- table of contents titlebookmark
- iftrue
, the table of contents gets its own bookmark.- Throws:
Jcpdf.CpdfError
-
stampOn
Stamps another PDF on top of all the pages in the document which are in the range. The stamp is placed with its origin at the origin of the target document.- Parameters:
stamp_pdf
- stamp PDF documentpdf
- PDF documentrange
- page range- Throws:
Jcpdf.CpdfError
-
stampUnder
public void stampUnder(Jcpdf.Pdf stamp_pdf, Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError Stamps another 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:
stamp_pdf
- stamp PDF documentpdf
- PDF documentrange
- page range- Throws:
Jcpdf.CpdfError
-
stampExtended
public void stampExtended(Jcpdf.Pdf pdf, Jcpdf.Pdf pdf2, Jcpdf.Range range, boolean isover, boolean scale_stamp_to_fit, int anchor, double p1, double p2, boolean relative_to_cropbox) throws Jcpdf.CpdfError A stamping function with extra features.- Parameters:
pdf
- first PDF documentpdf2
- second PDF documentrange
- page rangeisover
- iftrue
,pdf
goes overpdf2
otherwise underscale_stamp_to_fit
- iftrue
scales the stamp to fit the page.anchor
- position anchor, such asposCentre
p1
- position parameter onep2
- position parameter tworelative_to_cropbox
- iftrue
, the position is relative to the crop box rather than the media box.- Throws:
Jcpdf.CpdfError
-
combinePages
Combines the two PDFs page-by-page, putting each page of 'over' over each page of 'under'.- Throws:
Jcpdf.CpdfError
-
addText
public void addText(boolean metrics, Jcpdf.Pdf pdf, Jcpdf.Range range, String text, int anchor, double p1, double p2, double linespacing, int bates, int font, double fontsize, double r, double g, double b, boolean underneath, boolean cropbox, boolean outline, double opacity, int justification, boolean midline, boolean topline, String filename, double linewidth, boolean embed_fonts) throws Jcpdf.CpdfError Adds text to the pages in the given range.- Parameters:
metrics
- iftrue
, only collect metricspdf
- PDF documentrange
- page rangetext
- the text to stamp, including any special codesanchor
- position anchor, such asposCentre
p1
- position parameter onep2
- position parameter twolinespacing
- line spacingbates
- starting bates numberfont
- font, such astimesRoman
fontsize
- font sizer
- red component of colourg
- green component of colourb
- blue component of colourunderneath
- iftrue
, text goes under pagecropbox
- iftrue
, relative to cropbox rather than media boxoutline
- text is outlineopacity
- opacityjustification
- justification, such asleftJustify
midline
- position is relative to midline not baselinetopline
- position is relative to topline not baselinefilename
- file name, if requied by special code in textlinewidth
- line widthembed_fonts
- if true, embed fonts- Throws:
Jcpdf.CpdfError
-
addTextSimple
public void addTextSimple(Jcpdf.Pdf pdf, Jcpdf.Range range, String text, int anchor, double p1, double p2, int font, double fontsize) throws Jcpdf.CpdfError Adds text with most parameters default.- Parameters:
pdf
- PDF documentrange
- page rangetext
- the text to stamp, including any special codesanchor
- position anchor, such asposCentre
p1
- position parameter onep2
- position parameter twofont
- font, such astimesRoman
fontsize
- font size- Throws:
Jcpdf.CpdfError
-
removeText
Removes any text added by Jcpdf from the given pages.- Throws:
Jcpdf.CpdfError
-
textWidth
Returns the width of a given string in the given font in thousandths of a point.- Parameters:
font
- font, such astimesRoman
text
- text- Throws:
Jcpdf.CpdfError
-
addContent
public void addContent(String s, boolean before, Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError Adds page content before or after the existing content to pages in the given range in the given PDF.- Parameters:
s
- page content to addbefore
- iftrue
new content goes before, else afterpdf
- PDF documentrange
- page range- Throws:
Jcpdf.CpdfError
-
stampAsXObject
public String stampAsXObject(Jcpdf.Pdf pdf, Jcpdf.Range range, Jcpdf.Pdf stamp_pdf) throws Jcpdf.CpdfError Stamps a 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:
pdf
- PDF documentrange
- page rangestamp_pdf
- PDF document to stamp- Throws:
Jcpdf.CpdfError
-
impose
public void impose(Jcpdf.Pdf pdf, double x, double y, boolean fit, boolean columns, boolean rtl, boolean btt, boolean center, double margin, double spacing, double linewidth) throws Jcpdf.CpdfError Imposes a PDF.- Parameters:
pdf
- PDF documentx
- x parametery
- y parameterfit
-true
: impose to fit a page of size x by y;false
: impose x by ycolumns
- imposes by columns rather than rowsrtl
- impose right-to-leftbtt
- impose bottom-to-topcenter
- unused for nowmargin
- margin around the outputspacing
- spacing between imposed inputs- Throws:
Jcpdf.CpdfError
-
twoUp
Imposes a document two up. twoUp does so by shrinking the page size, to fit two pages on one.- Throws:
Jcpdf.CpdfError
-
twoUpStack
Imposes a document two up. twoUpStack does so by doubling the page size, to fit two pages on one.- Throws:
Jcpdf.CpdfError
-
padBefore
Adds a blank page before each page in the given range.- Throws:
Jcpdf.CpdfError
-
padAfter
Adds a blank page after each page in the given range.- Throws:
Jcpdf.CpdfError
-
padEvery
Adds a blank page after every n pages.- Throws:
Jcpdf.CpdfError
-
padMultiple
Adds pages at the end to pad the file to a multiple of n pages in length.- Throws:
Jcpdf.CpdfError
-
padMultipleBefore
Adds pages at the beginning to pad the file to a multiple of n pages in length.- Throws:
Jcpdf.CpdfError
-
annotationsJSON
Returns the annotations from a PDF in JSON format.- Throws:
Jcpdf.CpdfError
-
isLinearized
Finds out if a document is linearized as quickly as possible without loading it.- Throws:
Jcpdf.CpdfError
-
getVersion
Returns the minor version number of a document.- Throws:
Jcpdf.CpdfError
-
getMajorVersion
Returns the major version number of a document.- Throws:
Jcpdf.CpdfError
-
getTitle
Returns the title of a document.- Throws:
Jcpdf.CpdfError
-
getAuthor
Returns the author of a document.- Throws:
Jcpdf.CpdfError
-
getSubject
Returns the subject of a document.- Throws:
Jcpdf.CpdfError
-
getKeywords
Returns the keywords of a document.- Throws:
Jcpdf.CpdfError
-
getCreator
Returns the creator of a document.- Throws:
Jcpdf.CpdfError
-
getProducer
Returns the producer of a document.- Throws:
Jcpdf.CpdfError
-
getCreationDate
Returns the creation date of a document.- Throws:
Jcpdf.CpdfError
-
getModificationDate
Returns the modification date of a document.- Throws:
Jcpdf.CpdfError
-
getTitleXMP
Returns the XMP title of a document.- Throws:
Jcpdf.CpdfError
-
getAuthorXMP
Returns the XMP author of a document.- Throws:
Jcpdf.CpdfError
-
getSubjectXMP
Returns the XMP subject of a document.- Throws:
Jcpdf.CpdfError
-
getKeywordsXMP
Returns the XMP keywords of a document.- Throws:
Jcpdf.CpdfError
-
getCreatorXMP
Returns the XMP creator of a document.- Throws:
Jcpdf.CpdfError
-
getProducerXMP
Returns the XMP producer of a document.- Throws:
Jcpdf.CpdfError
-
getCreationDateXMP
Returns the XMP creation date of a document.- Throws:
Jcpdf.CpdfError
-
getModificationDateXMP
Returns the XMP modification date of a document.- Throws:
Jcpdf.CpdfError
-
setTitle
Sets the title of a document.- Throws:
Jcpdf.CpdfError
-
setAuthor
Sets the author of a document.- Throws:
Jcpdf.CpdfError
-
setSubject
Sets the subject of a document.- Throws:
Jcpdf.CpdfError
-
setKeywords
Sets the keywords of a document.- Throws:
Jcpdf.CpdfError
-
setCreator
Sets the creator of a document.- Throws:
Jcpdf.CpdfError
-
setProducer
Sets the producer of a document.- Throws:
Jcpdf.CpdfError
-
setCreationDate
Sets the creation date of a document.- Throws:
Jcpdf.CpdfError
-
setModificationDate
Sets the modification date of a document.- Throws:
Jcpdf.CpdfError
-
setTitleXMP
Sets the XMP title of a document.- Throws:
Jcpdf.CpdfError
-
setAuthorXMP
Sets the XMP author of a document.- Throws:
Jcpdf.CpdfError
-
setSubjectXMP
Sets the XMP subject of a document.- Throws:
Jcpdf.CpdfError
-
setKeywordsXMP
Sets the XMP keywords of a document.- Throws:
Jcpdf.CpdfError
-
setCreatorXMP
Sets the XMP creator of a document.- Throws:
Jcpdf.CpdfError
-
setProducerXMP
Sets the XMP producer of a document.- Throws:
Jcpdf.CpdfError
-
setCreationDateXMP
Sets the XMP creation date of a document.- Throws:
Jcpdf.CpdfError
-
setModificationDateXMP
Sets the XMP modification date of a document.- Throws:
Jcpdf.CpdfError
-
getDateComponents
Returns the components from a PDF date string in an array of length 8.- Parameters:
datestring
- date stringr
- return array- Throws:
Jcpdf.CpdfError
-
dateStringOfComponents
public String dateStringOfComponents(int year, int month, int day, int hour, int minute, int second, int hour_offset, int minute_offset) throws Jcpdf.CpdfError Builds a PDF date string from individual components.- Throws:
Jcpdf.CpdfError
-
getPageRotation
Gets the viewing rotation for a given page.- Throws:
Jcpdf.CpdfError
-
hasBox
Returnstrue
if the given page has the given box. E.g "/CropBox".- Parameters:
pdf
- PDF documentpagenumber
- page numberboxname
- box name, e.g "/CropBox"- Throws:
Jcpdf.CpdfError
-
getMediaBox
These functions get a box given the document. The values are returned in a given array of length 4: min x, max x, min y, max y in points. Only succeeds if such a box exists, as checked byhasBox
.- Throws:
Jcpdf.CpdfError
-
getCropBox
These functions get a box given the document. The values are returned in a given array of length 4: min x, max x, min y, max y in points. Only succeeds if such a box exists, as checked byhasBox
.- Throws:
Jcpdf.CpdfError
-
getBleedBox
These functions get a box given the document. The values are returned in a given array of length 4: min x, max x, min y, max y in points. Only succeeds if such a box exists, as checked byhasBox
.- Throws:
Jcpdf.CpdfError
-
getArtBox
These functions get a box given the document. The values are returned in a given array of length 4: min x, max x, min y, max y in points. Only succeeds if such a box exists, as checked byhasBox
.- Throws:
Jcpdf.CpdfError
-
getTrimBox
These functions get a box given the document. The values are returned in a given array of length 4: min x, max x, min y, max y in points. Only succeeds if such a box exists, as checked byhasBox
.- Throws:
Jcpdf.CpdfError
-
setMediabox
public void setMediabox(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) throws Jcpdf.CpdfError These functions set a box given the document page range, min x, max x, min y, max y in points.- Throws:
Jcpdf.CpdfError
-
setCropBox
public void setCropBox(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) throws Jcpdf.CpdfError These functions set a box given the document, page range, min x, max x, min y, max y in points.- Throws:
Jcpdf.CpdfError
-
setTrimBox
public void setTrimBox(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) throws Jcpdf.CpdfError These functions set a box given the document, page range, min x, max x, min y, max y in points.- Throws:
Jcpdf.CpdfError
-
setArtBox
public void setArtBox(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) throws Jcpdf.CpdfError These functions set a box given the document, page range, min x, max x, min y, max y in points.- Throws:
Jcpdf.CpdfError
-
setBleedBox
public void setBleedBox(Jcpdf.Pdf pdf, Jcpdf.Range range, double minx, double maxx, double miny, double maxy) throws Jcpdf.CpdfError These functions set a box given the document, page range, min x, max x, min y, max y in points.- Throws:
Jcpdf.CpdfError
-
markTrapped
Marks a document as trapped.- Throws:
Jcpdf.CpdfError
-
markUntrapped
Marks a document as untrapped.- Throws:
Jcpdf.CpdfError
-
markTrappedXMP
Marks a document as trapped in XMP metadata.- Throws:
Jcpdf.CpdfError
-
markUntrappedXMP
Marks a document as untrapped in XMP metadata.- Throws:
Jcpdf.CpdfError
-
setPageLayout
Sets the page layout for a document, such assinglePage
- Throws:
Jcpdf.CpdfError
-
setPageMode
Sets the page mode for a document, such asuseNone
- Throws:
Jcpdf.CpdfError
-
hideToolbar
Sets the hide toolbar flag.- Throws:
Jcpdf.CpdfError
-
hideMenubar
Sets the hide menubar flag.- Throws:
Jcpdf.CpdfError
-
hideWindowUi
Sets the hide window UI flag.- Throws:
Jcpdf.CpdfError
-
fitWindow
Sets the fit window flag.- Throws:
Jcpdf.CpdfError
-
centerWindow
Sets the center window flag.- Throws:
Jcpdf.CpdfError
-
displayDocTitle
Sets the display document title flag.- Throws:
Jcpdf.CpdfError
-
openAtPage
Sets the PDF to open, possibly with zoom-to-fit, at the given page number.- Parameters:
pdf
- PDF documentfit
- iftrue
zoom to fitpagenumber
- page number- Throws:
Jcpdf.CpdfError
-
setMetadataFromFile
Sets the XMP metadata of a document, given a file name.- Throws:
Jcpdf.CpdfError
-
setMetadataFromByteArray
Sets the XMP metadata from an array of bytes.- Throws:
Jcpdf.CpdfError
-
removeMetadata
Removes the XMP metadata from a document.- Throws:
Jcpdf.CpdfError
-
getMetadata
Returns the XMP metadata from a document.- Throws:
Jcpdf.CpdfError
-
createMetadata
Builds fresh XMP metadata as best it can from existing metadata in the document.- Throws:
Jcpdf.CpdfError
-
setMetadataDate
Sets the metadata date for a PDF. The date is given in PDF date format. Jcpdf will convert it to XMP format. The date "now" means now.- Throws:
Jcpdf.CpdfError
-
addPageLabels
public void addPageLabels(Jcpdf.Pdf pdf, int style, String prefix, int offset, Jcpdf.Range range, boolean progress) throws Jcpdf.CpdfError Adds page labels to a document.- Parameters:
pdf
- PDF documentstyle
- label style, such asdecimalArabic
prefix
- text for each labeloffset
- can be used to shift the numbering up or downrange
- page rangeprogress
- iftrue
, labels progress- Throws:
Jcpdf.CpdfError
-
removePageLabels
Removes the page labels from the document.- Throws:
Jcpdf.CpdfError
-
getPageLabelStringForPage
Calculates the full label string for a given page, and returns it.- Throws:
Jcpdf.CpdfError
-
startGetPageLabels
Gets page label data. CallstartGetPageLabels
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). CallendGetPageLabels
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- Throws:
Jcpdf.CpdfError
-
endGetPageLabels
Gets page label data. CallstartGetPageLabels
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). CallendGetPageLabels
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- Throws:
Jcpdf.CpdfError
-
getPageLabelOffset
Gets page label data. CallstartGetPageLabels
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). CallendGetPageLabels
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- Throws:
Jcpdf.CpdfError
-
getPageLabelStyle
Gets page label data. CallstartGetPageLabels
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). CallendGetPageLabels
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- Throws:
Jcpdf.CpdfError
-
getPageLabelRange
Gets page label data. CallstartGetPageLabels
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). CallendGetPageLabels
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- Throws:
Jcpdf.CpdfError
-
getPageLabelPrefix
Gets page label data. CallstartGetPageLabels
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). CallendGetPageLabels
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- Throws:
Jcpdf.CpdfError
-
attachFile
Attaches a file to the PDF. It is attached at document level.- Parameters:
filename
- file namepdf
- PDF document- Throws:
Jcpdf.CpdfError
-
attachFileToPage
Attaches a file to a page of the PDF. Given its file name, pdf, and the page number to which it should be attached.- Parameters:
filename
- file namepdf
- PDF documentpagenumber
- page number to attach to- Throws:
Jcpdf.CpdfError
-
attachFileFromMemory
public void attachFileFromMemory(byte[] data, String filename, Jcpdf.Pdf pdf) throws Jcpdf.CpdfError Attaches data from memory to a document.- Parameters:
data
- attachment itselffilename
- file name to use to describe attachmentpdf
- PDF document- Throws:
Jcpdf.CpdfError
-
attachFileToPageFromMemory
public void attachFileToPageFromMemory(byte[] data, String filename, Jcpdf.Pdf pdf, int pagenumber) throws Jcpdf.CpdfError Attaches data to a page from memory.- Parameters:
data
- attachment itselffilename
- file name to use to describe attachmentpdf
- PDF document- Throws:
Jcpdf.CpdfError
-
removeAttachedFiles
Removes all page- and document-level attachments from a document.- Throws:
Jcpdf.CpdfError
-
startGetAttachments
Lists information about attachments. CallstartGetAttachments
first, thennumberGetAttachments
to find out how many there are. ThengetAttachmentName
,getAttachmentPage
, orgetAttachmentData
. to return each one0...(n - 1)
. Finally, call#endGetAttachments
to clean up.- Throws:
Jcpdf.CpdfError
-
numberGetAttachments
Lists information about attachments. CallstartGetAttachments
first, thennumberGetAttachments
to find out how many there are. ThengetAttachmentName
,getAttachmentPage
, orgetAttachmentData
. to return each one0...(n - 1)
. Finally, call#endGetAttachments
to clean up.- Throws:
Jcpdf.CpdfError
-
getAttachmentName
Gets the name of an attachment, given a serial number.- Throws:
Jcpdf.CpdfError
-
getAttachmentPage
Gets the page number, given a serial number. 0 = document level.- Throws:
Jcpdf.CpdfError
-
getAttachmentData
Gets the attachment data itself, given a serial number.- Throws:
Jcpdf.CpdfError
-
endGetAttachments
Lists information about attachments. CallstartGetAttachments
first, thennumberGetAttachments
to find out how many there are. ThengetAttachmentName
,getAttachmentPage
, orgetAttachmentData
. to return each one0...(n - 1)
. Finally, call#endGetAttachments
to clean up.- Throws:
Jcpdf.CpdfError
-
startGetImageResolution
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
getImageResolutionPageNumber
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
getImageResolutionImageName
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
getImageResolutionXPixels
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
getImageResolutionYPixels
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
getImageResolutionXRes
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
getImageResolutionYRes
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
endGetImageResolution
Gets image data, including resolution at all points of use. CallstartGetImageResolution(pdf, min_required_resolution)
to begin the process of obtaining data on all image uses belowmin_required_resolution
, returning the total number. So, to return all image uses, specify a very highmin_required_resolution
. Then, call the other functions giving a serial number0...n - 1
, to retrieve the data. Finally, callendGetImageResolution
to clean up.- Throws:
Jcpdf.CpdfError
-
startGetFontInfo
Retrieves font information. First, callstartGetFontInfo
. Now callnumberFonts
to return the number of fonts. For each font, call one or more ofgetFontPage
,getFontName
,getFontType
, andgetFontEncoding
giving a serial number0...n - 1
to return information. Finally, callendGetFontInfo
to clean up.- Throws:
Jcpdf.CpdfError
-
numberFonts
Retrieves font information. First, callstartGetFontInfo
. Now callnumberFonts
to return the number of fonts. For each font, call one or more ofgetFontPage
,getFontName
,getFontType
, andgetFontEncoding
giving a serial number0...n - 1
to return information. Finally, callendGetFontInfo
to clean up.- Throws:
Jcpdf.CpdfError
-
getFontName
Retrieves font information. First, callstartGetFontInfo
. Now callnumberFonts
to return the number of fonts. For each font, call one or more ofgetFontPage
,getFontName
,getFontType
, andgetFontEncoding
giving a serial number0...n - 1
to return information. Finally, callendGetFontInfo
to clean up.- Throws:
Jcpdf.CpdfError
-
getFontPage
Retrieves font information. First, callstartGetFontInfo
. Now callnumberFonts
to return the number of fonts. For each font, call one or more ofgetFontPage
,getFontName
,getFontType
, andgetFontEncoding
giving a serial number0...n - 1
to return information. Finally, callendGetFontInfo
to clean up.- Throws:
Jcpdf.CpdfError
-
getFontType
Retrieves font information. First, callstartGetFontInfo
. Now callnumberFonts
to return the number of fonts. For each font, call one or more ofgetFontPage
,getFontName
,getFontType
, andgetFontEncoding
giving a serial number0...n - 1
to return information. Finally, callendGetFontInfo
to clean up.- Throws:
Jcpdf.CpdfError
-
getFontEncoding
Retrieves font information. First, callstartGetFontInfo
. Now callnumberFonts
to return the number of fonts. For each font, call one or more ofgetFontPage
,getFontName
,getFontType
, andgetFontEncoding
giving a serial number0...n - 1
to return information. Finally, callendGetFontInfo
to clean up.- Throws:
Jcpdf.CpdfError
-
endGetFontInfo
Retrieves font information. First, callstartGetFontInfo
. Now callnumberFonts
to return the number of fonts. For each font, call one or more ofgetFontPage
,getFontName
,getFontType
, andgetFontEncoding
giving a serial number0...n - 1
to return information. Finally, callendGetFontInfo
to clean up.- Throws:
Jcpdf.CpdfError
-
removeFonts
Removes all font data from a file.- Throws:
Jcpdf.CpdfError
-
copyFont
public void copyFont(Jcpdf.Pdf from_pdf, Jcpdf.Pdf to_pdf, Jcpdf.Range range, int pagenumber, String fontname) throws Jcpdf.CpdfError Copies the given font from the given page in the 'from' PDF to every page in the 'to' PDF. The new font is stored under its font name.- Parameters:
from_pdf
- PDF document to copy fromto_pdf
- PDF document to copy torange
- page rangepagenumber
- page number of the page to copy fromfontname
- font name- Throws:
Jcpdf.CpdfError
-
outputJSON
public void outputJSON(String filename, boolean parse_content, boolean no_stream_data, boolean decompress_streams, Jcpdf.Pdf pdf) throws Jcpdf.CpdfError Outputs a PDF in JSON format to the given filename.- Parameters:
filename
- file nameparse_content
- parse page contentno_stream_data
- all stream data is suppressed entirelydecompress_streams
- streams are decompressedpdf
- PDF document- Throws:
Jcpdf.CpdfError
-
outputJSONMemory
public byte[] outputJSONMemory(Jcpdf.Pdf pdf, boolean parse_content, boolean no_stream_data, boolean decompress_streams) throws Jcpdf.CpdfError Like outputJSON, but it writes to a byte array in memory.- Parameters:
pdf
- PDF documentparse_content
- parse page contentno_stream_data
- all stream data is suppressed entirelydecompress_streams
- streams are decompressed- Throws:
Jcpdf.CpdfError
-
fromJSON
Loads a PDF from a JSON file given its filename.- Throws:
Jcpdf.CpdfError
-
fromJSONMemory
Loads a PDF from a JSON file in memory.- Throws:
Jcpdf.CpdfError
-
startGetOCGList
Begins retrieving optional content group names. The serial number0..n - 1
is returned.- Throws:
Jcpdf.CpdfError
-
OCGListEntry
Retrieves an entry in the optional content group list, given the serial number0..n - 1
.- Throws:
Jcpdf.CpdfError
-
endGetOCGList
Ends retrieval of optional content group names.- Throws:
Jcpdf.CpdfError
-
OCGRename
Renames an optional content group.- Parameters:
pdf
- PDF documentf
- name to rename fromt
- name to rename to- Throws:
Jcpdf.CpdfError
-
OCGOrderAll
Ensures that every optional content group appears in the OCG order list.- Throws:
Jcpdf.CpdfError
-
OCGCoalesce
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.- Throws:
Jcpdf.CpdfError
-
blankDocument
Creates a blank document with pages of the given width (in points), height (in points), and number of pages.- Parameters:
w
- width of pageh
- height of pagepages
- number of pages- Throws:
Jcpdf.CpdfError
-
blankDocumentPaper
Makes a blank document given a page size and number of pages.- Parameters:
papersize
- paper size, such asa0portrait
pages
- number of pages- Throws:
Jcpdf.CpdfError
-
textToPDF
public Jcpdf.Pdf textToPDF(double w, double h, int font, double fontsize, String filename) throws Jcpdf.CpdfError Typesets a UTF8 text file ragged right on a page of size w * h in points in the given font and font size.- Parameters:
w
- width of pageh
- height of pagefont
- font, such astimesRoman
fontsize
- font sizefilename
- file name- Throws:
Jcpdf.CpdfError
-
textToPDFPaper
public Jcpdf.Pdf textToPDFPaper(int papersize, int font, double fontsize, String filename) throws Jcpdf.CpdfError Typesets a UTF8 text file ragged right on a page of the given size in the given font and font size.- Parameters:
papersize
- paper size, such asa0portrait
font
- font, such astimesRoman
fontsize
- font sizefilename
- file name- Throws:
Jcpdf.CpdfError
-
draft
Removes images on the given pages, replacing them with crossed boxes ifboxes
istrue
.- Parameters:
pdf
- PDF documentrange
- page rangeboxes
- add crossed boxes- Throws:
Jcpdf.CpdfError
-
removeAllText
Removes all text from the given pages in a given document.- Throws:
Jcpdf.CpdfError
-
blackText
Blackens all text on the given pages.- Throws:
Jcpdf.CpdfError
-
blackLines
Blackens all lines on the given pages.- Throws:
Jcpdf.CpdfError
-
blackFills
Blackens all fills on the given pages.- Throws:
Jcpdf.CpdfError
-
thinLines
public void thinLines(Jcpdf.Pdf pdf, Jcpdf.Range range, double min_thickness) throws Jcpdf.CpdfError Thickens every line less thanmin_thickness
tomin_thickness
. Thickness given in points.- Parameters:
pdf
- PDF documentrange
- page rangemin_thickness
- minimum thickness- Throws:
Jcpdf.CpdfError
-
copyId
Copies the/ID
from one document to another.- Parameters:
pdf
- PDF document to copy frompdf2
- PDF document to copy to- Throws:
Jcpdf.CpdfError
-
removeId
Removes a document's/ID
.- Throws:
Jcpdf.CpdfError
-
setVersion
Sets the minor version number of a document.- Parameters:
pdf
- PDF documentversion
- minor version number- Throws:
Jcpdf.CpdfError
-
setFullVersion
Sets the full version number of a document.- Parameters:
pdf
- PDF documentmajor
- major version numberminor
- minor version nuber- Throws:
Jcpdf.CpdfError
-
removeDictEntry
Removes any dictionary entry with the given key anywhere in the document.- Parameters:
pdf
- PDF documentkey
- key to remove- Throws:
Jcpdf.CpdfError
-
removeDictEntrySearch
public void removeDictEntrySearch(Jcpdf.Pdf pdf, String key, String searchterm) throws Jcpdf.CpdfError Removes any dictionary entry with the given key whose value matches the given search term.- Parameters:
pdf
- PDF documentkey
- key to removesearchterm
- search term- Throws:
Jcpdf.CpdfError
-
replaceDictEntry
Replaces the value associated with the given key.- Parameters:
pdf
- PDF documentkey
- key whose value to replacenewvalue
- value to replace with- Throws:
Jcpdf.CpdfError
-
replaceDictEntrySearch
public void replaceDictEntrySearch(Jcpdf.Pdf pdf, String key, String newvalue, String searchterm) throws Jcpdf.CpdfError Replaces the value associated with the given key if the existing value matches the search term.- Parameters:
pdf
- PDF documentkey
- key whose value to replacenewvalue
- value to replace withsearchterm
- search term- Throws:
Jcpdf.CpdfError
-
removeClipping
Removes all clipping from pages in the given range.- Throws:
Jcpdf.CpdfError
-
getDictEntries
Returns a JSON array containing any and all values associated with the given key, and fills in its length.- Parameters:
pdf
- PDF documentkey
- key to search for- Throws:
Jcpdf.CpdfError
-