Class Jcpdf

java.lang.Object
com.coherentpdf.Jcpdf

public class Jcpdf extends Object
The Coherent PDF Library for Java
  • Field Details

    • noEdit

      public static int noEdit
      Permission: cannot edit the document
    • noPrint

      public static int noPrint
      Permission: cannot print the document
    • noCopy

      public static int noCopy
      Permission: cannot copy the document
    • noAnnot

      public static int noAnnot
      Permission: cannot annotate the document
    • noForms

      public static int noForms
      Permission: cannot edit forms in the document
    • noExtract

      public static int noExtract
      Permission: cannot extract information
    • noAssemble

      public static int noAssemble
      Permission: cannot assemble into a bigger document
    • noHqPrint

      public static int noHqPrint
      Permission: cannot print high quality
    • pdf40bit

      public static int pdf40bit
      Encryption method: 40 bit RC4 encryption
    • pdf128bit

      public static int pdf128bit
      Encryption method: 128 bit RC4 encryption
    • aes128bitfalse

      public static int aes128bitfalse
      Encryption method: 128 bit AES encryption, do not encrypt metadata
    • aes128bittrue

      public static int aes128bittrue
      Encryption method: 128 bit AES encryption, encrypt metadata
    • aes256bitfalse

      public static int aes256bitfalse
      Encryption method: Deprecated. Do not use for new files
    • aes256bittrue

      public static int aes256bittrue
      Encryption method: Deprecated. Do not use for new files
    • aes256bitisofalse

      public static int aes256bitisofalse
      Encryption method: 256 bit AES encryption, do not encrypt metadata
    • aes256bitisotrue

      public static int aes256bitisotrue
      Encryption method: 256 bit AES encryption, encrypt metadata
    • decimalArabic

      public static int decimalArabic
      Page label style: 1, 2, 3...
    • uppercaseRoman

      public static int uppercaseRoman
      Page label style: I, II, III...
    • lowercaseRoman

      public static int lowercaseRoman
      Page label style: i, ii, iii...
    • uppercaseLetters

      public static int uppercaseLetters
      Page label style: A, B, C...
    • lowercaseLetters

      public static int lowercaseLetters
      Page label style: a, b, c...
    • singlePage

      public static int singlePage
      Layout: single page
    • oneColumn

      public static int oneColumn
      Layout: one column
    • twoColumnLeft

      public static int twoColumnLeft
      Layout: two column left
    • twoColumnRight

      public static int twoColumnRight
      Layout: two column right
    • twoPageLeft

      public static int twoPageLeft
      Layout: two page left
    • twoPageRight

      public static int twoPageRight
      Layout: two page right
    • useNone

      public static int useNone
      Page mode: use none
    • useOutlines

      public static int useOutlines
      Page mode: use outlines
    • useThumbs

      public static int useThumbs
      Page mode: use thumbs
    • useOC

      public static int useOC
      Page mode: use OC
    • useAttachments

      public static int useAttachments
      Page mode: use Attachments
    • a0portrait

      public static int a0portrait
      Paper size: A0 Portrait
    • a1portrait

      public static int a1portrait
      Paper size: A1 Portrait
    • a2portrait

      public static int a2portrait
      Paper size: A2 Portrait
    • a3portrait

      public static int a3portrait
      Paper size: A3 Portrait
    • a4portrait

      public static int a4portrait
      Paper size: A4 Portrait
    • a5portrait

      public static int a5portrait
      Paper size: A5 Portrait
    • a0landscape

      public static int a0landscape
      Paper size: A0 Landscape
    • a1landscape

      public static int a1landscape
      Paper size: A1 Landscape
    • a2landscape

      public static int a2landscape
      Paper size: A2 Landscape
    • a3landscape

      public static int a3landscape
      Paper size: A3 Landscape
    • a4landscape

      public static int a4landscape
      Paper size: A4 Landscape
    • a5landscape

      public static int a5landscape
      Paper size: A5 Landscape
    • usletterportrait

      public static int usletterportrait
      Paper size: US Letter Portrait
    • usletterlandscape

      public static int usletterlandscape
      Paper size: US Letter Landscape
    • uslegalportrait

      public static int uslegalportrait
      Paper size: US Legal Portrait
    • uslegallandscape

      public static int uslegallandscape
      Paper size: US Legal Landscape
    • timesRoman

      public static int timesRoman
      Standard font: Times Roman
    • timesBold

      public static int timesBold
      Standard font: Times Bold
    • timesItalic

      public static int timesItalic
      Standard font: Times Italic
    • timesBoldItalic

      public static int timesBoldItalic
      Standard font: Times Bold Italic
    • helvetica

      public static int helvetica
      Standard font: Helvetica
    • helveticaBold

      public static int helveticaBold
      Standard font: Helvetica Bold
    • helveticaOblique

      public static int helveticaOblique
      Standard font: Helvetica Oblique
    • helveticaBoldOblique

      public static int helveticaBoldOblique
      Standard font: Helvetica Bold Oblique
    • courier

      public static int courier
      Standard font: Courier
    • courierBold

      public static int courierBold
      Standard font: Courier Bold
    • courierOblique

      public static int courierOblique
      Standard font: Courier Oblique
    • courierBoldOblique

      public static int courierBoldOblique
      Standard font: Courier Bold Oblique
    • posCentre

      public static int posCentre
      Position anchor: absolute centre. Takes two numbers, x and y.
    • posLeft

      public static int posLeft
      Position anchor: absolute left. Takes two numbers, x and y.
    • posRight

      public static int posRight
      Position anchor: absolute right. Takes two numbers, x and y.
    • top

      public static int top
      Position anchor: the top centre of the page. Takes one number - distance from top. Second number ignored.
    • topLeft

      public static int topLeft
      Position anchor: the top left of the page. Takes one numbers - distance from top left. Second number ignored.
    • topRight

      public static int topRight
      Position anchor: the top right of the page. Takes one number - distance from top right. Second number ignored.
    • left

      public static int left
      Position anchor: the left hand side of the page, halfway down. Takes one number - distance from left middle. Second number ignored.
    • bottomLeft

      public static int bottomLeft
      Position anchor: the bottom left of the page. Takes one number - distance from bottom left. Second number ignored.
    • bottom

      public static int bottom
      Position anchor: the bottom middle of the page. Takes one number - distance from bottom middle. Second number ignored.
    • bottomRight

      public static int bottomRight
      Position anchor: the bottomm right of the page. Takes one number - distance from bottom right. Second number ignored.
    • diagonal

      public static int diagonal
      Position anchor: diagonal, bottom left to top right. Takes no numbers. Both numbers ignored.
    • reverseDiagonal

      public static int reverseDiagonal
      Position anchor: diagonal, top left to bottom right. Takes no numbers. Both numbers ignored.
    • leftJustify

      public static int leftJustify
      Justification: left
    • centreJustify

      public static int centreJustify
      Justification: centre
    • rightJusitfy

      public static int rightJusitfy
      Justification: right
  • Constructor Details

    • Jcpdf

      public Jcpdf()
      Create a new instance of the Jcpdf library. You must use startup() too, before calling any other function.
  • Method Details

    • startup

      public void startup() throws Jcpdf.CpdfError
      Initialises the library. Must be called before any other function.
      Throws:
      Jcpdf.CpdfError
    • version

      public String version() throws Jcpdf.CpdfError
      Returns a string giving the version number of the Jcpdf library.
      Throws:
      Jcpdf.CpdfError
    • setFast

      public void setFast() throws Jcpdf.CpdfError
      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

      public void setSlow() throws Jcpdf.CpdfError
      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

      public Jcpdf.Pdf fromFile(String filename, String userpw) throws Jcpdf.CpdfError
      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 name
      userpw - user password
      Throws:
      Jcpdf.CpdfError
    • fromFileLazy

      public Jcpdf.Pdf fromFileLazy(String filename, String userpw) throws Jcpdf.CpdfError
      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 name
      userpw - user password
      Throws:
      Jcpdf.CpdfError
    • fromMemory

      public Jcpdf.Pdf fromMemory(byte[] data, String userpw) throws Jcpdf.CpdfError
      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 file
      userpw - user password
      Throws:
      Jcpdf.CpdfError
    • fromMemoryLazy

      public Jcpdf.Pdf fromMemoryLazy(byte[] data, String userpw) throws Jcpdf.CpdfError
      Loads a file from memory and the user password, but lazily like fromFileLazy. The caller must use fromMemoryLazyRelease to free the memory. It must not free the memory until the PDF is also gone.
      Throws:
      Jcpdf.CpdfError
    • fromMemoryLazyRelease

      public void fromMemoryLazyRelease(byte[] data) throws Jcpdf.CpdfError
      Releases memory returned from fromMemoryLazy
      Parameters:
      data - byte array previously passed to fromMemoryLazy
      Throws:
      Jcpdf.CpdfError
    • startEnumeratePDFs

      public int startEnumeratePDFs() throws Jcpdf.CpdfError
      Begins enumerating currently allocated PDFs.

      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.

      Throws:
      Jcpdf.CpdfError
    • enumeratePDFsKey

      public int enumeratePDFsKey(int n) throws Jcpdf.CpdfError
      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, then enumeratePDFsInfo and enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to clean up.

      Throws:
      Jcpdf.CpdfError
    • enumeratePDFsInfo

      public String enumeratePDFsInfo(int n) throws Jcpdf.CpdfError
      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, then enumeratePDFsInfo and enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to clean up.

      Throws:
      Jcpdf.CpdfError
    • endEnumeratePDFs

      public void endEnumeratePDFs() throws Jcpdf.CpdfError
      Ends enumeration of currently allocated PDFs.

      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.

      Throws:
      Jcpdf.CpdfError
    • ptOfCm

      public double ptOfCm(double f) throws Jcpdf.CpdfError
      Converts a figure in centimetres to points. (72 points to 1 inch)
      Throws:
      Jcpdf.CpdfError
    • ptOfMm

      public double ptOfMm(double f) throws Jcpdf.CpdfError
      Converts a figure in millimetres to points. (72 points to 1 inch)
      Throws:
      Jcpdf.CpdfError
    • ptOfIn

      public double ptOfIn(double f) throws Jcpdf.CpdfError
      Converts a figure in inches to points (72. points to 1 inch)
      Throws:
      Jcpdf.CpdfError
    • cmOfPt

      public double cmOfPt(double f) throws Jcpdf.CpdfError
      Converts a figure in points to centimetres. (72 points to 1 inch)
      Throws:
      Jcpdf.CpdfError
    • mmOfPt

      public double mmOfPt(double f) throws Jcpdf.CpdfError
      Converts a figure in points to millimetres. (72 points to 1 inch)
      Throws:
      Jcpdf.CpdfError
    • inOfPt

      public double inOfPt(double f) throws Jcpdf.CpdfError
      Converts a figure in points to millimetres. (72 points to 1 inch)
      Throws:
      Jcpdf.CpdfError
    • parsePagespec

      public Jcpdf.Range parsePagespec(Jcpdf.Pdf pdf, String pagespec) throws Jcpdf.CpdfError
      Parses a page specification such as 1,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 document
      pagespec - page specification
      Throws:
      Jcpdf.CpdfError
    • validatePagespec

      public boolean validatePagespec(String pagespec) throws Jcpdf.CpdfError
      Validates a page specification so far as is possible in the absence of the actual document. Result is true if valid.
      Throws:
      Jcpdf.CpdfError
    • stringOfPagespec

      public String stringOfPagespec(Jcpdf.Pdf pdf, Jcpdf.Range r) throws Jcpdf.CpdfError
      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 document
      r - page range
      Throws:
      Jcpdf.CpdfError
    • blankRange

      public Jcpdf.Range blankRange() throws Jcpdf.CpdfError
      The range containing no pages.
      Throws:
      Jcpdf.CpdfError
    • range

      public Jcpdf.Range range(int from, int to) throws Jcpdf.CpdfError
      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

      public Jcpdf.Range all(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      The page range contaning all pages in a given document.
      Throws:
      Jcpdf.CpdfError
    • odd

      public Jcpdf.Range odd(Jcpdf.Range r) throws Jcpdf.CpdfError
      The page range containing all odd-numbered pages from an existing range.
      Throws:
      Jcpdf.CpdfError
    • even

      public Jcpdf.Range even(Jcpdf.Range r) throws Jcpdf.CpdfError
      The page range containing all even-numbered pages from an existing range.
      Throws:
      Jcpdf.CpdfError
    • rangeUnion

      public Jcpdf.Range rangeUnion(Jcpdf.Range r, Jcpdf.Range s) throws Jcpdf.CpdfError
      The union of two ranges - all those pages in either.
      Throws:
      Jcpdf.CpdfError
    • difference

      public Jcpdf.Range difference(Jcpdf.Range r, Jcpdf.Range s) throws Jcpdf.CpdfError
      The range containing all pages in the first given range which are not in the second.
      Throws:
      Jcpdf.CpdfError
    • removeDuplicates

      public Jcpdf.Range removeDuplicates(Jcpdf.Range r) throws Jcpdf.CpdfError
      Remove duplicates from a range, returning a new one.
      Throws:
      Jcpdf.CpdfError
    • rangeLength

      public int rangeLength(Jcpdf.Range r) throws Jcpdf.CpdfError
      The length of a range.
      Throws:
      Jcpdf.CpdfError
    • rangeGet

      public int rangeGet(Jcpdf.Range r, int n) throws Jcpdf.CpdfError
      Gets a page number from a range at the given offset.
      Throws:
      Jcpdf.CpdfError
    • rangeAdd

      public Jcpdf.Range rangeAdd(Jcpdf.Range r, int n) throws Jcpdf.CpdfError
      Adds a page number to a range, returning a new one.
      Throws:
      Jcpdf.CpdfError
    • isInRange

      public boolean isInRange(Jcpdf.Range r, int n) throws Jcpdf.CpdfError
      Tests to see if a given number is in a page range.
      Throws:
      Jcpdf.CpdfError
    • pages

      public int pages(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the number of pages in a PDF.
      Throws:
      Jcpdf.CpdfError
    • pagesFast

      public int pagesFast(String userpw, String filename) throws Jcpdf.CpdfError
      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 password
      filename - 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. 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:
      pdf - PDF document
      filename - file name
      linearize - linearize
      make_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. If make_id is true, it will be given a new ID. If preserve_objstm is true, existing object streams will be preserved. If generate_objstm is true, object streams will be generated even if not originally present. If compress_objstm is true, object streams will be compressed (what we usually want). WARNING: the pdf argument will be invalid after this call, and should not be used again.
      Parameters:
      pdf - PDF document
      filename - file name
      linearize - linearize
      make_id - make new ID
      preserve_objstm - preserve object streams
      create_objstm - create new object streams
      compress_objstm - compress object streams
      Throws:
      Jcpdf.CpdfError
    • toMemory

      public byte[] toMemory(Jcpdf.Pdf pdf, boolean linearize, boolean make_id) throws Jcpdf.CpdfError
      Writes a PDF document and returns it as an array of bytes.
      Parameters:
      pdf - PDF document
      linearize - linearize
      make_id - make new ID
      Throws:
      Jcpdf.CpdfError
    • isEncrypted

      public boolean isEncrypted(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns true if a document is encrypted, false otherwise.
      Throws:
      Jcpdf.CpdfError
    • decryptPdf

      public void decryptPdf(Jcpdf.Pdf pdf, String userpw) throws Jcpdf.CpdfError
      Attempts to decrypt a PDF using the given user password. An exception is raised if the decryption fails.
      Parameters:
      pdf - PDF document
      userpw - user password
      Throws:
      Jcpdf.CpdfError
    • decryptPdfOwner

      public void decryptPdfOwner(Jcpdf.Pdf pdf, String ownerpw) throws Jcpdf.CpdfError
      Attempts to decrypt a PDF using the given owner password. Raises an exception if the decryption fails.
      Parameters:
      pdf - PDF document
      ownerpw - 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 document
      encryption_method - encryption method, e.g aes256bitisofalse
      permissions - array of permissions e.g noEdit
      owner_password - owner password
      user_password - user password
      linearize - linearize
      makeid - make new ID
      filename - 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 document
      encryption_method - encryption method, e.g aes256bitisofalse
      permissions - array of permissions e.g noEdit
      owner_password - owner password
      user_password - user password
      linearize - linearize
      makeid - make new ID
      preserve_objstm - preserve existing object streams
      generate_objstm - generate new object streams
      compress_objstm - compress object streams
      filename - file name
      Throws:
      Jcpdf.CpdfError
    • hasPermission

      public boolean hasPermission(Jcpdf.Pdf pdf, int permission) throws Jcpdf.CpdfError
      Returns true if the given permission (restriction) such as noEdit is present.
      Throws:
      Jcpdf.CpdfError
    • encryptionKind

      public int encryptionKind(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the encryption method currently in use on a document, such as aes256bitisofalse.
      Throws:
      Jcpdf.CpdfError
    • mergeSimple

      public Jcpdf.Pdf mergeSimple(Jcpdf.Pdf[] pdfs) throws Jcpdf.CpdfError
      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. 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:
      pdfs - array of PDF documents
      retain_numbering - retain page numbering in output
      remove_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 documents
      retain_numbering - retain page numbering in output
      remove_duplicate_fonts - remove duplicate font data by merging
      ranges - array of ranges, one for each PDF
      Throws:
      Jcpdf.CpdfError
    • selectPages

      public Jcpdf.Pdf selectPages(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Returns a new document with just those pages in the page range.
      Parameters:
      pdf - PDF document
      range - 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 document
      range - page range
      sx - X scale
      sy - 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 document
      range - page range
      w - width in points
      h - height in points
      scale - 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 document
      range - page range
      papersize - paper size, such as a0portrait
      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 the anchor, p1 and p2 by the scale given. See the documentation for the chosen anchor.
      Parameters:
      pdf - PDF document
      range - page range
      anchor - position anchor, such as posCentre
      p1 - position parameter 1
      p2 - position parameter 2
      scale - 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 document
      range - page range
      dx - X shift
      dy - Y shift
      Throws:
      Jcpdf.CpdfError
    • rotate

      public void rotate(Jcpdf.Pdf pdf, Jcpdf.Range range, int angle) throws Jcpdf.CpdfError
      Changes the viewing rotation to an absolute value. Appropriate rotations are 0, 90, 180, 270.
      Parameters:
      pdf - PDF document
      range - page range
      angle - viewing rotation
      Throws:
      Jcpdf.CpdfError
    • rotateBy

      public void rotateBy(Jcpdf.Pdf pdf, Jcpdf.Range range, int angle) throws Jcpdf.CpdfError
      Changes the viewing rotation by a relative value. Appropriate rotations are 0, 90, 180, 270.
      Parameters:
      pdf - PDF document
      range - page range
      angle - viewing rotation
      Throws:
      Jcpdf.CpdfError
    • rotateContents

      public void rotateContents(Jcpdf.Pdf pdf, Jcpdf.Range range, double angle) throws Jcpdf.CpdfError
      Rotates the content about the centre of the page by the given number of degrees, in a clockwise direction.
      Parameters:
      pdf - PDF document
      range - page range
      angle - angle in degrees
      Throws:
      Jcpdf.CpdfError
    • upright

      public void upright(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      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

      public void hFlip(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Flips horizontally the pages in the range.
      Throws:
      Jcpdf.CpdfError
    • vFlip

      public void vFlip(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      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 document
      range - page range
      x - minimum X
      y - minimum Y
      w - width
      h - height
      Throws:
      Jcpdf.CpdfError
    • removeCrop

      public void removeCrop(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Removes any crop box from pages in the range.
      Throws:
      Jcpdf.CpdfError
    • removeTrim

      public void removeTrim(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Removes any trim box from pages in the range.
      Throws:
      Jcpdf.CpdfError
    • removeArt

      public void removeArt(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Removes any art box from pages in the range.
      Throws:
      Jcpdf.CpdfError
    • removeBleed

      public void removeBleed(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Removes any bleed box from pages in the range.
      Throws:
      Jcpdf.CpdfError
    • trimMarks

      public void trimMarks(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Adds trim marks to the given pages, if the trimbox exists.
      Throws:
      Jcpdf.CpdfError
    • showBoxes

      public void showBoxes(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Shows the boxes on the given pages, for debug.
      Throws:
      Jcpdf.CpdfError
    • hardBox

      public void hardBox(Jcpdf.Pdf pdf, Jcpdf.Range range, String box) throws Jcpdf.CpdfError
      Makes a given box a 'hard box' i.e clips it explicitly.
      Parameters:
      pdf - PDF document
      range - page range
      box - box name e.g "/CropBox"
      Throws:
      Jcpdf.CpdfError
    • compress

      public void compress(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Compresses any uncompressed streams in the given PDF using the Flate algorithm.
      Throws:
      Jcpdf.CpdfError
    • decompress

      public void decompress(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Decompresses any streams in the given PDF, so long as the compression method is supported.
      Throws:
      Jcpdf.CpdfError
    • squeezeInMemory

      public void squeezeInMemory(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Squeezes a pdf in memory.
      Throws:
      Jcpdf.CpdfError
    • startGetBookmarkInfo

      public void startGetBookmarkInfo(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Starts the bookmark retrieval process for a given PDF.
      Throws:
      Jcpdf.CpdfError
    • numberBookmarks

      public int numberBookmarks() throws Jcpdf.CpdfError
      Gets the number of bookmarks for the PDF given to startGetBookmarkInfo.
      Throws:
      Jcpdf.CpdfError
    • getBookmarkLevel

      public int getBookmarkLevel(int serial) throws Jcpdf.CpdfError
      Gets the bookmark level for the given bookmark 0...(n - 1).
      Throws:
      Jcpdf.CpdfError
    • getBookmarkPage

      public int getBookmarkPage(Jcpdf.Pdf pdf, int serial) throws Jcpdf.CpdfError
      Gets the bookmark target page for the given PDF (which must be the same as the PDF passed to startGetBookmarkInfo) and bookmark 0...(n - 1).
      Throws:
      Jcpdf.CpdfError
    • getBookmarkText

      public String getBookmarkText(int serial) throws Jcpdf.CpdfError
      Returns the text of bookmark 0...(n - 1))
      Throws:
      Jcpdf.CpdfError
    • getBookmarkOpenStatus

      public boolean getBookmarkOpenStatus(int serial) throws Jcpdf.CpdfError
      Returns true if the bookmark is open.
      Throws:
      Jcpdf.CpdfError
    • endGetBookmarkInfo

      public void endGetBookmarkInfo() throws Jcpdf.CpdfError
      Ends the bookmark retrieval process, cleaning up.
      Throws:
      Jcpdf.CpdfError
    • startSetBookmarkInfo

      public void startSetBookmarkInfo(int n) throws Jcpdf.CpdfError
      Starts the bookmark setting process for n bookmarks.
      Throws:
      Jcpdf.CpdfError
    • setBookmarkLevel

      public void setBookmarkLevel(int serial, int level) throws Jcpdf.CpdfError
      Set bookmark level for the given bookmark 0...(n - 1).
      Throws:
      Jcpdf.CpdfError
    • setBookmarkPage

      public void setBookmarkPage(Jcpdf.Pdf pdf, int serial, int pagenum) throws Jcpdf.CpdfError
      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).
      Throws:
      Jcpdf.CpdfError
    • setBookmarkOpenStatus

      public void setBookmarkOpenStatus(int serial, boolean open) throws Jcpdf.CpdfError
      Sets the open status of bookmark 0...(n - 1).
      Throws:
      Jcpdf.CpdfError
    • setBookmarkText

      public void setBookmarkText(int serial, String text) throws Jcpdf.CpdfError
      Sets the text of bookmark 0...(n - 1).
      Throws:
      Jcpdf.CpdfError
    • endSetBookmarkInfo

      public void endSetBookmarkInfo(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Ends the bookmark setting process, writing the bookmarks to the given PDF.
      Throws:
      Jcpdf.CpdfError
    • getBookmarksJSON

      public byte[] getBookmarksJSON(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the bookmark data in JSON format.
      Throws:
      Jcpdf.CpdfError
    • setBookmarksJSON

      public void setBookmarksJSON(Jcpdf.Pdf pdf, byte[] data) throws Jcpdf.CpdfError
      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 document
      font - font, such as timesRoman
      fontsize - font size
      title - table of contents title
      bookmark - if true, the table of contents gets its own bookmark.
      Throws:
      Jcpdf.CpdfError
    • stampOn

      public void stampOn(Jcpdf.Pdf stamp_pdf, Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      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 document
      pdf - PDF document
      range - 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 document
      pdf - PDF document
      range - 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 document
      pdf2 - second PDF document
      range - page range
      isover - if true, pdf goes over pdf2 otherwise under
      scale_stamp_to_fit - if true scales the stamp to fit the page.
      anchor - position anchor, such as posCentre
      p1 - position parameter one
      p2 - position parameter two
      relative_to_cropbox - if true, the position is relative to the crop box rather than the media box.
      Throws:
      Jcpdf.CpdfError
    • combinePages

      public Jcpdf.Pdf combinePages(Jcpdf.Pdf under, Jcpdf.Pdf over) throws Jcpdf.CpdfError
      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 - if true, only collect metrics
      pdf - PDF document
      range - page range
      text - the text to stamp, including any special codes
      anchor - position anchor, such as posCentre
      p1 - position parameter one
      p2 - position parameter two
      linespacing - line spacing
      bates - starting bates number
      font - font, such as timesRoman
      fontsize - font size
      r - red component of colour
      g - green component of colour
      b - blue component of colour
      underneath - if true, text goes under page
      cropbox - if true, relative to cropbox rather than media box
      outline - text is outline
      opacity - opacity
      justification - justification, such as leftJustify
      midline - position is relative to midline not baseline
      topline - position is relative to topline not baseline
      filename - file name, if requied by special code in text
      linewidth - line width
      embed_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 document
      range - page range
      text - the text to stamp, including any special codes
      anchor - position anchor, such as posCentre
      p1 - position parameter one
      p2 - position parameter two
      font - font, such as timesRoman
      fontsize - font size
      Throws:
      Jcpdf.CpdfError
    • removeText

      public void removeText(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Removes any text added by Jcpdf from the given pages.
      Throws:
      Jcpdf.CpdfError
    • textWidth

      public int textWidth(int font, String text) throws Jcpdf.CpdfError
      Returns the width of a given string in the given font in thousandths of a point.
      Parameters:
      font - font, such as timesRoman
      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 add
      before - if true new content goes before, else after
      pdf - PDF document
      range - 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 document
      range - page range
      stamp_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 document
      x - x parameter
      y - y parameter
      fit - true: impose to fit a page of size x by y; false: impose x by y
      columns - imposes by columns rather than rows
      rtl - impose right-to-left
      btt - impose bottom-to-top
      center - unused for now
      margin - margin around the output
      spacing - spacing between imposed inputs
      Throws:
      Jcpdf.CpdfError
    • twoUp

      public void twoUp(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Imposes a document two up. twoUp does so by shrinking the page size, to fit two pages on one.
      Throws:
      Jcpdf.CpdfError
    • twoUpStack

      public void twoUpStack(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Imposes a document two up. twoUpStack does so by doubling the page size, to fit two pages on one.
      Throws:
      Jcpdf.CpdfError
    • padBefore

      public void padBefore(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Adds a blank page before each page in the given range.
      Throws:
      Jcpdf.CpdfError
    • padAfter

      public void padAfter(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Adds a blank page after each page in the given range.
      Throws:
      Jcpdf.CpdfError
    • padEvery

      public void padEvery(Jcpdf.Pdf pdf, int n) throws Jcpdf.CpdfError
      Adds a blank page after every n pages.
      Throws:
      Jcpdf.CpdfError
    • padMultiple

      public void padMultiple(Jcpdf.Pdf pdf, int n) throws Jcpdf.CpdfError
      Adds pages at the end to pad the file to a multiple of n pages in length.
      Throws:
      Jcpdf.CpdfError
    • padMultipleBefore

      public void padMultipleBefore(Jcpdf.Pdf pdf, int n) throws Jcpdf.CpdfError
      Adds pages at the beginning to pad the file to a multiple of n pages in length.
      Throws:
      Jcpdf.CpdfError
    • annotationsJSON

      public byte[] annotationsJSON(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the annotations from a PDF in JSON format.
      Throws:
      Jcpdf.CpdfError
    • isLinearized

      public boolean isLinearized(String filename) throws Jcpdf.CpdfError
      Finds out if a document is linearized as quickly as possible without loading it.
      Throws:
      Jcpdf.CpdfError
    • getVersion

      public int getVersion(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the minor version number of a document.
      Throws:
      Jcpdf.CpdfError
    • getMajorVersion

      public int getMajorVersion(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the major version number of a document.
      Throws:
      Jcpdf.CpdfError
    • getTitle

      public String getTitle(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the title of a document.
      Throws:
      Jcpdf.CpdfError
    • getAuthor

      public String getAuthor(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the author of a document.
      Throws:
      Jcpdf.CpdfError
    • getSubject

      public String getSubject(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the subject of a document.
      Throws:
      Jcpdf.CpdfError
    • getKeywords

      public String getKeywords(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the keywords of a document.
      Throws:
      Jcpdf.CpdfError
    • getCreator

      public String getCreator(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the creator of a document.
      Throws:
      Jcpdf.CpdfError
    • getProducer

      public String getProducer(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the producer of a document.
      Throws:
      Jcpdf.CpdfError
    • getCreationDate

      public String getCreationDate(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the creation date of a document.
      Throws:
      Jcpdf.CpdfError
    • getModificationDate

      public String getModificationDate(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the modification date of a document.
      Throws:
      Jcpdf.CpdfError
    • getTitleXMP

      public String getTitleXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP title of a document.
      Throws:
      Jcpdf.CpdfError
    • getAuthorXMP

      public String getAuthorXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP author of a document.
      Throws:
      Jcpdf.CpdfError
    • getSubjectXMP

      public String getSubjectXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP subject of a document.
      Throws:
      Jcpdf.CpdfError
    • getKeywordsXMP

      public String getKeywordsXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP keywords of a document.
      Throws:
      Jcpdf.CpdfError
    • getCreatorXMP

      public String getCreatorXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP creator of a document.
      Throws:
      Jcpdf.CpdfError
    • getProducerXMP

      public String getProducerXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP producer of a document.
      Throws:
      Jcpdf.CpdfError
    • getCreationDateXMP

      public String getCreationDateXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP creation date of a document.
      Throws:
      Jcpdf.CpdfError
    • getModificationDateXMP

      public String getModificationDateXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP modification date of a document.
      Throws:
      Jcpdf.CpdfError
    • setTitle

      public void setTitle(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the title of a document.
      Throws:
      Jcpdf.CpdfError
    • setAuthor

      public void setAuthor(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the author of a document.
      Throws:
      Jcpdf.CpdfError
    • setSubject

      public void setSubject(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the subject of a document.
      Throws:
      Jcpdf.CpdfError
    • setKeywords

      public void setKeywords(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the keywords of a document.
      Throws:
      Jcpdf.CpdfError
    • setCreator

      public void setCreator(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the creator of a document.
      Throws:
      Jcpdf.CpdfError
    • setProducer

      public void setProducer(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the producer of a document.
      Throws:
      Jcpdf.CpdfError
    • setCreationDate

      public void setCreationDate(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the creation date of a document.
      Throws:
      Jcpdf.CpdfError
    • setModificationDate

      public void setModificationDate(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the modification date of a document.
      Throws:
      Jcpdf.CpdfError
    • setTitleXMP

      public void setTitleXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP title of a document.
      Throws:
      Jcpdf.CpdfError
    • setAuthorXMP

      public void setAuthorXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP author of a document.
      Throws:
      Jcpdf.CpdfError
    • setSubjectXMP

      public void setSubjectXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP subject of a document.
      Throws:
      Jcpdf.CpdfError
    • setKeywordsXMP

      public void setKeywordsXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP keywords of a document.
      Throws:
      Jcpdf.CpdfError
    • setCreatorXMP

      public void setCreatorXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP creator of a document.
      Throws:
      Jcpdf.CpdfError
    • setProducerXMP

      public void setProducerXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP producer of a document.
      Throws:
      Jcpdf.CpdfError
    • setCreationDateXMP

      public void setCreationDateXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP creation date of a document.
      Throws:
      Jcpdf.CpdfError
    • setModificationDateXMP

      public void setModificationDateXMP(Jcpdf.Pdf pdf, String str) throws Jcpdf.CpdfError
      Sets the XMP modification date of a document.
      Throws:
      Jcpdf.CpdfError
    • getDateComponents

      public void getDateComponents(String datestring, int[] r) throws Jcpdf.CpdfError
      Returns the components from a PDF date string in an array of length 8.
      Parameters:
      datestring - date string
      r - 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

      public int getPageRotation(Jcpdf.Pdf pdf, int pagenumber) throws Jcpdf.CpdfError
      Gets the viewing rotation for a given page.
      Throws:
      Jcpdf.CpdfError
    • hasBox

      public boolean hasBox(Jcpdf.Pdf pdf, int pagenumber, String boxname) throws Jcpdf.CpdfError
      Returns true if the given page has the given box. E.g "/CropBox".
      Parameters:
      pdf - PDF document
      pagenumber - page number
      boxname - box name, e.g "/CropBox"
      Throws:
      Jcpdf.CpdfError
    • getMediaBox

      public void getMediaBox(Jcpdf.Pdf pdf, int pagenumber, double[] r) throws Jcpdf.CpdfError
      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 by hasBox.
      Throws:
      Jcpdf.CpdfError
    • getCropBox

      public void getCropBox(Jcpdf.Pdf pdf, int pagenumber, double[] r) throws Jcpdf.CpdfError
      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 by hasBox.
      Throws:
      Jcpdf.CpdfError
    • getBleedBox

      public void getBleedBox(Jcpdf.Pdf pdf, int pagenumber, double[] r) throws Jcpdf.CpdfError
      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 by hasBox.
      Throws:
      Jcpdf.CpdfError
    • getArtBox

      public void getArtBox(Jcpdf.Pdf pdf, int pagenumber, double[] r) throws Jcpdf.CpdfError
      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 by hasBox.
      Throws:
      Jcpdf.CpdfError
    • getTrimBox

      public void getTrimBox(Jcpdf.Pdf pdf, int pagenumber, double[] r) throws Jcpdf.CpdfError
      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 by hasBox.
      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

      public void markTrapped(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Marks a document as trapped.
      Throws:
      Jcpdf.CpdfError
    • markUntrapped

      public void markUntrapped(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Marks a document as untrapped.
      Throws:
      Jcpdf.CpdfError
    • markTrappedXMP

      public void markTrappedXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Marks a document as trapped in XMP metadata.
      Throws:
      Jcpdf.CpdfError
    • markUntrappedXMP

      public void markUntrappedXMP(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Marks a document as untrapped in XMP metadata.
      Throws:
      Jcpdf.CpdfError
    • setPageLayout

      public void setPageLayout(Jcpdf.Pdf pdf, int layout) throws Jcpdf.CpdfError
      Sets the page layout for a document, such as singlePage
      Throws:
      Jcpdf.CpdfError
    • setPageMode

      public void setPageMode(Jcpdf.Pdf pdf, int mode) throws Jcpdf.CpdfError
      Sets the page mode for a document, such as useNone
      Throws:
      Jcpdf.CpdfError
    • hideToolbar

      public void hideToolbar(Jcpdf.Pdf pdf, boolean flag) throws Jcpdf.CpdfError
      Sets the hide toolbar flag.
      Throws:
      Jcpdf.CpdfError
    • hideMenubar

      public void hideMenubar(Jcpdf.Pdf pdf, boolean flag) throws Jcpdf.CpdfError
      Sets the hide menubar flag.
      Throws:
      Jcpdf.CpdfError
    • hideWindowUi

      public void hideWindowUi(Jcpdf.Pdf pdf, boolean flag) throws Jcpdf.CpdfError
      Sets the hide window UI flag.
      Throws:
      Jcpdf.CpdfError
    • fitWindow

      public void fitWindow(Jcpdf.Pdf pdf, boolean flag) throws Jcpdf.CpdfError
      Sets the fit window flag.
      Throws:
      Jcpdf.CpdfError
    • centerWindow

      public void centerWindow(Jcpdf.Pdf pdf, boolean flag) throws Jcpdf.CpdfError
      Sets the center window flag.
      Throws:
      Jcpdf.CpdfError
    • displayDocTitle

      public void displayDocTitle(Jcpdf.Pdf pdf, boolean flag) throws Jcpdf.CpdfError
      Sets the display document title flag.
      Throws:
      Jcpdf.CpdfError
    • openAtPage

      public void openAtPage(Jcpdf.Pdf pdf, boolean fit, int pagenumber) throws Jcpdf.CpdfError
      Sets the PDF to open, possibly with zoom-to-fit, at the given page number.
      Parameters:
      pdf - PDF document
      fit - if true zoom to fit
      pagenumber - page number
      Throws:
      Jcpdf.CpdfError
    • setMetadataFromFile

      public void setMetadataFromFile(Jcpdf.Pdf pdf, String filename) throws Jcpdf.CpdfError
      Sets the XMP metadata of a document, given a file name.
      Throws:
      Jcpdf.CpdfError
    • setMetadataFromByteArray

      public void setMetadataFromByteArray(Jcpdf.Pdf pdf, byte[] data) throws Jcpdf.CpdfError
      Sets the XMP metadata from an array of bytes.
      Throws:
      Jcpdf.CpdfError
    • removeMetadata

      public void removeMetadata(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Removes the XMP metadata from a document.
      Throws:
      Jcpdf.CpdfError
    • getMetadata

      public byte[] getMetadata(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Returns the XMP metadata from a document.
      Throws:
      Jcpdf.CpdfError
    • createMetadata

      public void createMetadata(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Builds fresh XMP metadata as best it can from existing metadata in the document.
      Throws:
      Jcpdf.CpdfError
    • setMetadataDate

      public void setMetadataDate(Jcpdf.Pdf pdf, String date) throws Jcpdf.CpdfError
      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 document
      style - label style, such as decimalArabic
      prefix - text for each label
      offset - can be used to shift the numbering up or down
      range - page range
      progress - if true, labels progress
      Throws:
      Jcpdf.CpdfError
    • removePageLabels

      public void removePageLabels(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Removes the page labels from the document.
      Throws:
      Jcpdf.CpdfError
    • getPageLabelStringForPage

      public String getPageLabelStringForPage(Jcpdf.Pdf pdf, int pagenumber) throws Jcpdf.CpdfError
      Calculates the full label string for a given page, and returns it.
      Throws:
      Jcpdf.CpdfError
    • startGetPageLabels

      public int startGetPageLabels(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      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

      Throws:
      Jcpdf.CpdfError
    • endGetPageLabels

      public void endGetPageLabels() throws Jcpdf.CpdfError
      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

      Throws:
      Jcpdf.CpdfError
    • getPageLabelOffset

      public int getPageLabelOffset(int n) throws Jcpdf.CpdfError
      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

      Throws:
      Jcpdf.CpdfError
    • getPageLabelStyle

      public int getPageLabelStyle(int n) throws Jcpdf.CpdfError
      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

      Throws:
      Jcpdf.CpdfError
    • getPageLabelRange

      public int getPageLabelRange(int n) throws Jcpdf.CpdfError
      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

      Throws:
      Jcpdf.CpdfError
    • getPageLabelPrefix

      public String getPageLabelPrefix(int n) throws Jcpdf.CpdfError
      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

      Throws:
      Jcpdf.CpdfError
    • attachFile

      public void attachFile(String filename, Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Attaches a file to the PDF. It is attached at document level.
      Parameters:
      filename - file name
      pdf - PDF document
      Throws:
      Jcpdf.CpdfError
    • attachFileToPage

      public void attachFileToPage(String filename, Jcpdf.Pdf pdf, int pagenumber) throws Jcpdf.CpdfError
      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 name
      pdf - PDF document
      pagenumber - 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 itself
      filename - file name to use to describe attachment
      pdf - 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 itself
      filename - file name to use to describe attachment
      pdf - PDF document
      Throws:
      Jcpdf.CpdfError
    • removeAttachedFiles

      public void removeAttachedFiles(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Removes all page- and document-level attachments from a document.
      Throws:
      Jcpdf.CpdfError
    • startGetAttachments

      public void startGetAttachments(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Lists information about attachments. Call startGetAttachments first, then numberGetAttachments to find out how many there are. Then getAttachmentName, getAttachmentPage, or getAttachmentData. to return each one 0...(n - 1). Finally, call #endGetAttachments to clean up.
      Throws:
      Jcpdf.CpdfError
    • numberGetAttachments

      public int numberGetAttachments() throws Jcpdf.CpdfError
      Lists information about attachments. Call startGetAttachments first, then numberGetAttachments to find out how many there are. Then getAttachmentName, getAttachmentPage, or getAttachmentData. to return each one 0...(n - 1). Finally, call #endGetAttachments to clean up.
      Throws:
      Jcpdf.CpdfError
    • getAttachmentName

      public String getAttachmentName(int serial) throws Jcpdf.CpdfError
      Gets the name of an attachment, given a serial number.
      Throws:
      Jcpdf.CpdfError
    • getAttachmentPage

      public int getAttachmentPage(int serial) throws Jcpdf.CpdfError
      Gets the page number, given a serial number. 0 = document level.
      Throws:
      Jcpdf.CpdfError
    • getAttachmentData

      public byte[] getAttachmentData(int serial) throws Jcpdf.CpdfError
      Gets the attachment data itself, given a serial number.
      Throws:
      Jcpdf.CpdfError
    • endGetAttachments

      public void endGetAttachments() throws Jcpdf.CpdfError
      Lists information about attachments. Call startGetAttachments first, then numberGetAttachments to find out how many there are. Then getAttachmentName, getAttachmentPage, or getAttachmentData. to return each one 0...(n - 1). Finally, call #endGetAttachments to clean up.
      Throws:
      Jcpdf.CpdfError
    • startGetImageResolution

      public int startGetImageResolution(Jcpdf.Pdf pdf, double res) throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • getImageResolutionPageNumber

      public int getImageResolutionPageNumber(int serial) throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • getImageResolutionImageName

      public String getImageResolutionImageName(int serial) throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • getImageResolutionXPixels

      public int getImageResolutionXPixels(int serial) throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • getImageResolutionYPixels

      public int getImageResolutionYPixels(int serial) throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • getImageResolutionXRes

      public double getImageResolutionXRes(int serial) throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • getImageResolutionYRes

      public double getImageResolutionYRes(int serial) throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • endGetImageResolution

      public void endGetImageResolution() throws Jcpdf.CpdfError
      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.
      Throws:
      Jcpdf.CpdfError
    • startGetFontInfo

      public void startGetFontInfo(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Retrieves font information. First, call startGetFontInfo. 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.
      Throws:
      Jcpdf.CpdfError
    • numberFonts

      public int numberFonts() throws Jcpdf.CpdfError
      Retrieves font information. First, call startGetFontInfo. 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.
      Throws:
      Jcpdf.CpdfError
    • getFontName

      public String getFontName(int serial) throws Jcpdf.CpdfError
      Retrieves font information. First, call startGetFontInfo. 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.
      Throws:
      Jcpdf.CpdfError
    • getFontPage

      public int getFontPage(int serial) throws Jcpdf.CpdfError
      Retrieves font information. First, call startGetFontInfo. 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.
      Throws:
      Jcpdf.CpdfError
    • getFontType

      public String getFontType(int setial) throws Jcpdf.CpdfError
      Retrieves font information. First, call startGetFontInfo. 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.
      Throws:
      Jcpdf.CpdfError
    • getFontEncoding

      public String getFontEncoding(int serial) throws Jcpdf.CpdfError
      Retrieves font information. First, call startGetFontInfo. 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.
      Throws:
      Jcpdf.CpdfError
    • endGetFontInfo

      public void endGetFontInfo() throws Jcpdf.CpdfError
      Retrieves font information. First, call startGetFontInfo. 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.
      Throws:
      Jcpdf.CpdfError
    • removeFonts

      public void removeFonts(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      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 from
      to_pdf - PDF document to copy to
      range - page range
      pagenumber - page number of the page to copy from
      fontname - 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 name
      parse_content - parse page content
      no_stream_data - all stream data is suppressed entirely
      decompress_streams - streams are decompressed
      pdf - 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 document
      parse_content - parse page content
      no_stream_data - all stream data is suppressed entirely
      decompress_streams - streams are decompressed
      Throws:
      Jcpdf.CpdfError
    • fromJSON

      public Jcpdf.Pdf fromJSON(String filename) throws Jcpdf.CpdfError
      Loads a PDF from a JSON file given its filename.
      Throws:
      Jcpdf.CpdfError
    • fromJSONMemory

      public Jcpdf.Pdf fromJSONMemory(byte[] data) throws Jcpdf.CpdfError
      Loads a PDF from a JSON file in memory.
      Throws:
      Jcpdf.CpdfError
    • startGetOCGList

      public int startGetOCGList(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Begins retrieving optional content group names. The serial number 0..n - 1 is returned.
      Throws:
      Jcpdf.CpdfError
    • OCGListEntry

      public String OCGListEntry(int serial) throws Jcpdf.CpdfError
      Retrieves an entry in the optional content group list, given the serial number 0..n - 1.
      Throws:
      Jcpdf.CpdfError
    • endGetOCGList

      public void endGetOCGList() throws Jcpdf.CpdfError
      Ends retrieval of optional content group names.
      Throws:
      Jcpdf.CpdfError
    • OCGRename

      public void OCGRename(Jcpdf.Pdf pdf, String f, String t) throws Jcpdf.CpdfError
      Renames an optional content group.
      Parameters:
      pdf - PDF document
      f - name to rename from
      t - name to rename to
      Throws:
      Jcpdf.CpdfError
    • OCGOrderAll

      public void OCGOrderAll(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Ensures that every optional content group appears in the OCG order list.
      Throws:
      Jcpdf.CpdfError
    • OCGCoalesce

      public void OCGCoalesce(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      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

      public Jcpdf.Pdf blankDocument(double w, double h, int pages) throws Jcpdf.CpdfError
      Creates a blank document with pages of the given width (in points), height (in points), and number of pages.
      Parameters:
      w - width of page
      h - height of page
      pages - number of pages
      Throws:
      Jcpdf.CpdfError
    • blankDocumentPaper

      public Jcpdf.Pdf blankDocumentPaper(int papersize, int pages) throws Jcpdf.CpdfError
      Makes a blank document given a page size and number of pages.
      Parameters:
      papersize - paper size, such as a0portrait
      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 page
      h - height of page
      font - font, such as timesRoman
      fontsize - font size
      filename - 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 as a0portrait
      font - font, such as timesRoman
      fontsize - font size
      filename - file name
      Throws:
      Jcpdf.CpdfError
    • draft

      public void draft(Jcpdf.Pdf pdf, Jcpdf.Range range, boolean boxes) throws Jcpdf.CpdfError
      Removes images on the given pages, replacing them with crossed boxes if boxes is true.
      Parameters:
      pdf - PDF document
      range - page range
      boxes - add crossed boxes
      Throws:
      Jcpdf.CpdfError
    • removeAllText

      public void removeAllText(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Removes all text from the given pages in a given document.
      Throws:
      Jcpdf.CpdfError
    • blackText

      public void blackText(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Blackens all text on the given pages.
      Throws:
      Jcpdf.CpdfError
    • blackLines

      public void blackLines(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Blackens all lines on the given pages.
      Throws:
      Jcpdf.CpdfError
    • blackFills

      public void blackFills(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      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 than min_thickness to min_thickness. Thickness given in points.
      Parameters:
      pdf - PDF document
      range - page range
      min_thickness - minimum thickness
      Throws:
      Jcpdf.CpdfError
    • copyId

      public void copyId(Jcpdf.Pdf pdf, Jcpdf.Pdf pdf2) throws Jcpdf.CpdfError
      Copies the /ID from one document to another.
      Parameters:
      pdf - PDF document to copy from
      pdf2 - PDF document to copy to
      Throws:
      Jcpdf.CpdfError
    • removeId

      public void removeId(Jcpdf.Pdf pdf) throws Jcpdf.CpdfError
      Removes a document's /ID.
      Throws:
      Jcpdf.CpdfError
    • setVersion

      public void setVersion(Jcpdf.Pdf pdf, int version) throws Jcpdf.CpdfError
      Sets the minor version number of a document.
      Parameters:
      pdf - PDF document
      version - minor version number
      Throws:
      Jcpdf.CpdfError
    • setFullVersion

      public void setFullVersion(Jcpdf.Pdf pdf, int major, int minor) throws Jcpdf.CpdfError
      Sets the full version number of a document.
      Parameters:
      pdf - PDF document
      major - major version number
      minor - minor version nuber
      Throws:
      Jcpdf.CpdfError
    • removeDictEntry

      public void removeDictEntry(Jcpdf.Pdf pdf, String key) throws Jcpdf.CpdfError
      Removes any dictionary entry with the given key anywhere in the document.
      Parameters:
      pdf - PDF document
      key - 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 document
      key - key to remove
      searchterm - search term
      Throws:
      Jcpdf.CpdfError
    • replaceDictEntry

      public void replaceDictEntry(Jcpdf.Pdf pdf, String key, String newvalue) throws Jcpdf.CpdfError
      Replaces the value associated with the given key.
      Parameters:
      pdf - PDF document
      key - key whose value to replace
      newvalue - 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 document
      key - key whose value to replace
      newvalue - value to replace with
      searchterm - search term
      Throws:
      Jcpdf.CpdfError
    • removeClipping

      public void removeClipping(Jcpdf.Pdf pdf, Jcpdf.Range range) throws Jcpdf.CpdfError
      Removes all clipping from pages in the given range.
      Throws:
      Jcpdf.CpdfError
    • getDictEntries

      public byte[] getDictEntries(Jcpdf.Pdf pdf, String key) throws Jcpdf.CpdfError
      Returns a JSON array containing any and all values associated with the given key, and fills in its length.
      Parameters:
      pdf - PDF document
      key - key to search for
      Throws:
      Jcpdf.CpdfError