This commit is contained in:
John Whitington 2022-05-18 17:47:31 +01:00
parent 15bee681ae
commit 0ea7d45506
20 changed files with 813 additions and 1153 deletions

Binary file not shown.

View File

@ -1,171 +1,275 @@
// Enumerations // Enumerations and data structures
/** Permission: cannot edit the document */
public static int noEdit = 0;
/** Permission: cannot print the document */
public static int noPrint = 1;
/** Permission: cannot copy the document */
public static int noCopy = 2;
/** Permission: cannot annotate the document */
public static int noAnnot = 3;
/** Permission: cannot edit forms in the document */
public static int noForms = 4;
/** Permission: cannot extract information */
public static int noExtract = 5;
/** Permission: cannot assemble into a bigger document */
public static int noAssemble = 6;
/** Permission: cannot print high quality */
public static int noHqPrint = 7;
/** Encryption method: 40 bit RC4 encryption */ // Permissions
public static int pdf40bit = 0;
/** Encryption method: 128 bit RC4 encryption */
public static int pdf128bit = 1;
/** Encryption method: 128 bit AES encryption, do not encrypt metadata */
public static int aes128bitfalse = 2;
/** Encryption method: 128 bit AES encryption, encrypt metadata */
public static int aes128bittrue = 3;
/** Encryption method: Deprecated. Do not use for new files */
public static int aes256bitfalse = 4;
/** Encryption method: Deprecated. Do not use for new files */
public static int aes256bittrue = 5;
/** Encryption method: 256 bit AES encryption, do not encrypt metadata */
public static int aes256bitisofalse = 6;
/** Encryption method: 256 bit AES encryption, encrypt metadata */
public static int aes256bitisotrue = 7;
/** Page label style: 1, 2, 3... */ /** Cannot edit the document */
public static int decimalArabic = 0; var noEdit = 0;
/** Page label style: I, II, III... */
public static int uppercaseRoman = 1;
/** Page label style: i, ii, iii... */
public static int lowercaseRoman = 2;
/** Page label style: A, B, C... */
public static int uppercaseLetters = 3;
/** Page label style: a, b, c...*/
public static int lowercaseLetters = 4;
/** Layout: single page */ /** Cannot print the document */
public static int singlePage = 0; var noPrint = 1;
/** Layout: one column */
public static int oneColumn = 1;
/** Layout: two column left */
public static int twoColumnLeft = 2;
/** Layout: two column right */
public static int twoColumnRight = 3;
/** Layout: two page left */
public static int twoPageLeft = 4;
/** Layout: two page right */
public static int twoPageRight = 5;
/** Page mode: use none */ /** Cannot copy the document */
public static int useNone = 0; var noCopy = 2;
/** Page mode: use outlines */
public static int useOutlines = 1;
/** Page mode: use thumbs */
public static int useThumbs = 2;
/** Page mode: use OC */
public static int useOC = 3;
/** Page mode: use Attachments */
public static int useAttachments = 4;
/** Paper size: A0 Portrait */ /** Cannot annotate the document */
public static int a0portrait = 0; var noAnnot = 3;
/** Paper size: A1 Portrait */
public static int a1portrait = 1;
/** Paper size: A2 Portrait */
public static int a2portrait = 2;
/** Paper size: A3 Portrait */
public static int a3portrait = 3;
/** Paper size: A4 Portrait */
public static int a4portrait = 4;
/** Paper size: A5 Portrait */
public static int a5portrait = 5;
/** Paper size: A0 Landscape */
public static int a0landscape = 6;
/** Paper size: A1 Landscape */
public static int a1landscape = 7;
/** Paper size: A2 Landscape */
public static int a2landscape = 8;
/** Paper size: A3 Landscape */
public static int a3landscape = 9;
/** Paper size: A4 Landscape */
public static int a4landscape = 10;
/** Paper size: A5 Landscape */
public static int a5landscape = 11;
/** Paper size: US Letter Portrait */
public static int usletterportrait = 12;
/** Paper size: US Letter Landscape */
public static int usletterlandscape = 13;
/** Paper size: US Legal Portrait */
public static int uslegalportrait = 14;
/** Paper size: US Legal Landscape */
public static int uslegallandscape = 15;
/** Standard font: Times Roman */ /** Cannot edit forms in the document */
public static int timesRoman = 0; var noForms = 4;
/** Standard font: Times Bold */
public static int timesBold = 1;
/** Standard font: Times Italic */
public static int timesItalic = 2;
/** Standard font: Times Bold Italic */
public static int timesBoldItalic = 3;
/** Standard font: Helvetica */
public static int helvetica = 4;
/** Standard font: Helvetica Bold */
public static int helveticaBold = 5;
/** Standard font: Helvetica Oblique */
public static int helveticaOblique = 6;
/** Standard font: Helvetica Bold Oblique */
public static int helveticaBoldOblique = 7;
/** Standard font: Courier */
public static int courier = 8;
/** Standard font: Courier Bold */
public static int courierBold = 9;
/** Standard font: Courier Oblique */
public static int courierOblique = 10;
/** Standard font: Courier Bold Oblique */
public static int courierBoldOblique = 11;
/** Position anchor: absolute centre. Takes two numbers, x and y. */ /** Cannot extract information */
public static int posCentre = 0; var noExtract = 5;
/** Position anchor: absolute left. Takes two numbers, x and y. */
public static int posLeft = 1; /** Cannot assemble into a bigger document */
/** Position anchor: absolute right. Takes two numbers, x and y. */ var noAssemble = 6;
public static int posRight = 2;
/** Position anchor: the top centre of the page. /** Cannot print high quality */
Takes one number - distance from top. Second number ignored. */ var noHqPrint = 7;
public static int top = 3;
/** Position anchor: the top left of the page.
Takes one numbers - distance from top left. Second number ignored. */ // Encryption types
public static int topLeft = 4;
/** Position anchor: the top right of the page. /** 40 bit RC4 encryption */
Takes one number - distance from top right. Second number ignored. */ var pdf40bit = 0;
public static int topRight = 5;
/** Position anchor: the left hand side of the page, halfway down. /** 128 bit RC4 encryption */
Takes one number - distance from left middle. Second number ignored. */ var pdf128bit = 1;
public static int left = 6;
/** Position anchor: the bottom left of the page. /** 128 bit AES encryption, do not encrypt metadata */
Takes one number - distance from bottom left. Second number ignored. */ var aes128bitfalse = 2;
public static int bottomLeft = 7;
/** Position anchor: the bottom middle of the page. /** 128 bit AES encryption, encrypt metadata */
Takes one number - distance from bottom middle. Second number ignored. */ var aes128bittrue = 3;
public static int bottom = 8;
/** Position anchor: the bottomm right of the page. /** Deprecated. Do not use for new files */
Takes one number - distance from bottom right. Second number ignored. */ var aes256bitfalse = 4;
public static int bottomRight = 9;
/** Position anchor: the right hand side of the page, halfway down. /** Deprecated. Do not use for new files */
Takes one number - distance from right middle. Second number ignored. */ var aes256bittrue = 5;
public static int right = 10;
/** Position anchor: diagonal, bottom left to top right. /** 256 bit AES encryption, do not encrypt metadata */
Takes no numbers. Both numbers ignored. */ var aes256bitisofalse = 6;
public static int diagonal = 11;
/** Position anchor: diagonal, top left to bottom right. /** 256 bit AES encryption, encrypt metadata */
Takes no numbers. Both numbers ignored. */ var aes256bitisotrue = 7;
public static int reverseDiagonal = 12;
/** Justification: left */
public static int leftJustify = 0; // Paper sizes
/** Justification: centre */
public static int centreJustify = 1; /** A0 Portrait paper */
/** Justification: right */ var a0portrait = 0;
public static int rightJusitfy = 2;
/** A1 Portrait paper */
var a1portrait = 1;
/** A2 Portrait paper */
var a2portrait = 2;
/** A3 Portrait paper */
var a3portrait = 3;
/** A4 Portrait paper */
var a4portrait = 4;
/** A5 Portrait paper */
var a5portrait = 5;
/** A0 Landscape paper */
var a0landscape = 6;
/** A1 Landscape paper */
var a1landscape = 7;
/** A2 Landscape paper */
var a2landscape = 8;
/** A3 Landscape paper */
var a3landscape = 9;
/** A4 Landscape paper */
var a4landscape = 10;
/** A5 Landscape paper */
var a5landscape = 11;
/** US Letter Portrait paper */
var usletterportrait = 12;
/** US Letter Landscape paper */
var usletterlandscape = 13;
/** US Legal Portrait paper */
var uslegalportrait = 14;
/** US Legal Landscape paper */
var uslegallandscape = 15;
// Positions
/** Absolute centre */
var posCentre = 0;
/** Absolute left */
var posLeft = 1;
/** Absolute right */
var posRight = 2;
/** The top centre of the page */
var top = 3;
/** The top left of the page */
var topLeft = 4;
/** The top right of the page */
var topRight = 5;
/** The left hand side of the page, halfway down */
var left = 6;
/** The bottom left of the page */
var bottomLeft = 7;
/** The bottom middle of the page */
var bottom = 8;
/** The bottom right of the page */
var bottomRight = 9;
/** The right hand side of the page, halfway down */
var right = 10;
/** Diagonal, bottom left to top right */
var diagonal = 11;
/** Diagonal, top left to bottom right */
var reversediagonal = 12;
/** Positions on the page. Used for scaling about a point, and adding text.
A position is an anchor and zero or one or two parameters. Constructors are provided.
posCentre: Two parameters, x and y
posLeft: Two parameters, x and y
posRight: Two parameters, x and y
top: One parameter - distance from top
topLeft: One parameter - distance from top left
topRight: One parameter - distance from top right
left: One parameter - distance from left middle
bottomLeft: One parameter - distance from bottom left
bottom: One parameter - distance from bottom
bottomRight: One parameter - distance from bottom right
right: One parameter - distance from right
diagonal: Zero parameters
reverseDiagonal: Zero parameters */
function Position(anchor, p1, p2)
// Fonts
/** Times Roman */
var timesRoman = 0;
/** Times Bold */
var timesBold = 1;
/** Times Italic */
var timesItalic = 2;
/** Times Bold Italic */
var timesBoldItalic = 3;
/** Helvetica */
var helvetica = 4;
/** Helvetica Bold */
var helveticaBold = 5;
/** Helvetica Oblique */
var helveticaOblique = 6;
/** Helvetica Bold Oblique */
var helveticaBoldOblique = 7;
/** Courier */
var courier = 8;
/** Courier Bold */
var courierBold = 9;
/** Courier Oblique */
var courierOblique = 10;
/** Courier Bold Oblique */
var courierBoldOblique = 11;
// Justification types
/** Left justify */
var leftJustify = 0;
/** Centre justify */
var centreJustify = 1;
/** Right justify */
var rightJustify = 2;
/// Page layouts
/** Single page */
var singlePage = 0;
/** One column */
var oneColumn = 1;
/** Two column left */
var twoColumnLeft = 2;
/** Two column right */
var twoColumnRight = 3;
/** Two page left */
var twoPageLeft = 4;
/** Two page right */
var twoPageRight = 5;
// Page modes
/** Use none */
var useNone = 0;
/** Use outlines */
var useOutlines = 1;
/** Use thumbs */
var useThumbs = 2;
/** Use OC */
var useOC = 3;
/** Use attachments */
var useAttachments = 4;
// Page label styles
/** 1, 2, 3... */
var decimalArabic = 0;
/** I, II, III... */
var uppercaseRoman = 1;
/** i, ii, iii... */
var lowercaseRoman = 2;
/** A, B, C... */
var uppercaseLetters = 3;
/** a, b, c... */
var lowercaseLetters = 4;

View File

@ -1,24 +1,22 @@
/* CHAPTER 0. Preliminaries */ // CHAPTER 0. Preliminaries
/** Initialises the library. Must be called before any other function. */ /** Returns a string giving the version number of the CPDF library. */
public native void startup() throws CpdfError; function version()
/** Returns a string giving the version number of the Jcpdf library. */ /** Some operations have a fast mode. The default is 'slow' mode, which works
public native String version() throws CpdfError; even on old-fashioned files. For more details, see section 1.13 of the CPDF
manual. This function sets the mode to fast globally. */
function setFast()
/** Sets fast mode. Some operations have a fast mode. The default is 'slow' /** Some operations have a fast mode. The default is 'slow' mode, which works
mode, which works even on old-fashioned files. For more details, see even on old-fashioned files. For more details, see section 1.13 of the CPDF
section 1.13 of the CPDF manual. This functions sets the mode to fast manual. This function sets the mode to slow globally. */
globally. */ function setSlow()
public native void setFast() throws CpdfError;
/** Sets slow mode. Some operations have a fast mode. The default is 'slow' /** Delete a PDF so the memory representing it may be recovered. */
mode, which works even on old-fashioned files. For more details, see function deletePdf(pdf)
section 1.13 of the CPDF manual. This functions sets the mode to slow
globally. */
public native void setSlow() throws CpdfError;
/** Prints some information about /* A debug function which prints some information about resource usage. This
resource usage. This can be used to detect if PDFs or ranges are being can be used to detect if PDFs or ranges are being deallocated properly.
deallocated properly. Contrary to its name, it may be run at any time. */ Contrary to its name, it may be run at any time. */
public native void onExit(); function onexit()

View File

@ -1,256 +1,166 @@
/* CHAPTER 1. Basics */ //CHAPTER 1. Basics
/** Loads a PDF document from a file. Supply /** Loads a PDF file from a given file. Supply a user password (possibly blank)
a user password (possibly blank) in case the file is encrypted. It won't be in case the file is encrypted. It won't be decrypted, but sometimes the
decrypted, but sometimes the password is needed just to load the file. password is needed just to load the file. */
@param filename file name function fromFile(filename, userpw)
@param userpw user password */
public Pdf fromFile(String filename, String userpw) throws CpdfError;
/** Loads a PDF document from a file, doing only minimal /** Loads a PDF from a file, doing only minimal parsing. The objects will be
parsing. The objects will be read and parsed when they are actually read and parsed when they are actually needed. Use this when the whole file
needed. Use this when the whole file won't be required. Also supply a user won't be required. Also supply a user password (possibly blank) in case the
password (possibly blank) in case the file is encrypted. It won't be file is encrypted. It won't be decrypted, but sometimes the password is needed
decrypted, but sometimes the password is needed just to load the file. just to load the file. */
function fromFileLazy(filename, userpw)
@param filename file name /** Loads a file from memory given any user password. */
@param userpw user password */ function fromMemory(data, userpw)
public Pdf fromFileLazy(String filename, String userpw) throws CpdfError;
/** Loads a PDF document from memory. Supply /** Loads a file from memory, given a pointer and a length, and the user
a user password (possibly blank) in case the file is encrypted. It won't be password, but lazily like fromFileLazy. */
decrypted, but sometimes the password is needed just to load the file. function fromMemoryLazy(data, userpw)
@param data byte array containing the PDF file /** To enumerate the list of currently allocated PDFs, call startEnumeratePDFs
@param userpw user password */ which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and
public Pdf fromMemory(byte[] data, String userpw) throws CpdfError; enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to
clean up. */
function startEnumeratePDFs()
/** Loads a file from memory and the user /** To enumerate the list of currently allocated PDFs, call startEnumeratePDFs
password, but lazily like {@link #fromFileLazy(String, String) which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and
fromFileLazy}. The caller must use {@link #fromMemoryLazyRelease(byte[]) enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to
fromMemoryLazyRelease} to free the memory. It must not free the memory clean up. */
until the PDF is also gone. */ function enumeratePDFsKey(n)
public Pdf fromMemoryLazy(byte[] data, String userpw) throws CpdfError;
/** Releases memory returned from /** To enumerate the list of currently allocated PDFs, call startEnumeratePDFs
<code>{@link #fromMemoryLazy(byte[], String) fromMemoryLazy}</code> which gives the number, n, of PDFs allocated, then enumeratePDFsInfo and
@param data byte array previously passed to {@link #fromMemoryLazy(byte[], enumeratePDFsKey with index numbers from 0...(n - 1). Call endEnumeratePDFs to
String) fromMemoryLazy} */ clean up. */
public native void fromMemoryLazyRelease(byte[] data) throws CpdfError; function enumeratePDFsInfo(n)
/** 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. */
function endEnumeratePDFs()
<p>To enumerate the list of currently allocated PDFs, call /** Converts a figure in centimetres to points (72 points to 1 inch) */
{@link #startEnumeratePDFs() startEnumeratePDFs} which gives the number, function ptOfCm(i)
<code>n</code>, of PDFs allocated, then {@link #enumeratePDFsInfo(int)
enumeratePDFsInfo} and {@link #enumeratePDFsKey(int) enumeratePDFsKey} with
index numbers from <code>0...(n - 1)</code>. Call
{@link #endEnumeratePDFs() endEnumeratePDFs} to clean up. */
public native int startEnumeratePDFs() throws CpdfError;
/** Returns the key for a given PDF number. */ /** Converts a figure in millimetres to points (72 points to 1 inch) */
public native int enumeratePDFsKey(int n) throws CpdfError; function ptOfMm(i)
/** Returns the info for a given PDF number. */ /** Converts a figure in inches to points (72 points to 1 inch) */
public native String enumeratePDFsInfo(int n) throws CpdfError; function ptOfIn(i)
/** Ends enumeration of currently allocated PDFs. */ /** Converts a figure in points to centimetres (72 points to 1 inch) */
public native void endEnumeratePDFs() throws CpdfError; function cmOfPt(i)
/** Converts a figure in centimetres to points. (72 points to 1 inch) */ /** Converts a figure in points to millimetres (72 points to 1 inch) */
public native double ptOfCm(double f) throws CpdfError; function mmOfPt(i)
/** Converts a figure in millimetres to points. (72 points to 1 inch) */ /** Converts a figure in points to inches (72 points to 1 inch) */
public native double ptOfMm(double f) throws CpdfError; function inOfPt(i)
/** Converts a figure in inches to points (72. points to 1 inch) */ /** Parses a page specification with reference to a given PDF (the PDF is
public native double ptOfIn(double f) throws CpdfError; supplied so that page ranges which reference pages which do not exist are
rejected). */
/** Converts a figure in points to centimetres. (72 points to 1 inch) */ function parsePagespec(pdf, pagespec)
public native double cmOfPt(double f) throws CpdfError;
/** Converts a figure in points to millimetres. (72 points to 1 inch) */
public native double mmOfPt(double f) throws CpdfError;
/** Converts a figure in points to millimetres. (72 points to 1 inch) */
public native double inOfPt(double f) throws CpdfError;
/** Parses a page specification such as <code>1,2,6-end</code> with
reference to a given PDF. (The PDF is supplied so that page ranges which
reference pages which do not exist are rejected).
@param pdf PDF document
@param pagespec page specification */
public native Range parsePagespec(Pdf pdf, String pagespec)
throws CpdfError;
/** Validates a page specification so far as is possible in the absence of /** Validates a page specification so far as is possible in the absence of
the actual document. Result is <code>true</code> if valid. */ the actual document. Result is true if valid. */
public native boolean validatePagespec(String pagespec) throws CpdfError; function validatePagespec(pagespec)
/** Builds a page specification from a page range. For example, the range /** 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 containing 1,2,3,6,7,8 in a document of 8 pages might yield "1-3,6-end" */
<code>"1-3,6-end"</code> function stringOfPagespec(pdf, r)
@param pdf PDF document /** Creates a range with no pages in. */
@param r page range function blankRange()
*/
public String stringOfPagespec(Pdf pdf, Range r) throws CpdfError;
/** The range containing no pages. */ /** Builds a range from one page to another inclusive. For example, range(3,7)
public native Range blankRange() throws CpdfError; gives the range 3,4,5,6,7 */
function range(f, t)
/** The page range containing all page numbers from one page number to /** The range containing all the pages in a given document. */
another. function all(pdf)
@param from page number to begin at (inclusive)
@param to page number to end at (inclusive) */
public native Range range(int from, int to) throws CpdfError;
/** The page range contaning all pages in a given document. */ /** Makes a range which contains just the even pages of another range. */
public native Range all(Pdf pdf) throws CpdfError; function even(r_in)
/** The page range containing all odd-numbered pages from an existing /** Makes a range which contains just the odd pages of another range. */
range. */ function odd(r_in)
public native Range odd(Range r) throws CpdfError;
/** The page range containing all even-numbered pages from an existing /** Makes the union of two ranges giving a range containing the pages in range
range. */ a and range b. */
public native Range even(Range r) throws CpdfError; function rangeUnion(a, b)
/** The union of two ranges - all those pages in either. */ /** Makes the difference of two ranges, giving a range containing all the
public native Range rangeUnion(Range r, Range s) throws CpdfError; pages in a except for those which are also in b. */
function difference(a, b)
/** The range containing all pages in the first given range which are not /** Deduplicates a range, making a new one. */
in the second. */ function removeDuplicates(a)
public native Range difference(Range r, Range s) throws CpdfError;
/** Remove duplicates from a range, returning a new one. */ /** Gives the number of pages in a range. */
public native Range removeDuplicates(Range r) throws CpdfError; function rangeLength(r)
/** The length of a range. */ /** Gets the page number at position n in a range, where n runs from 0 to
public native int rangeLength(Range r) throws CpdfError; rangeLength - 1. */
function rangeGet(r, n)
/** Gets a page number from a range at the given offset. */ /** Adds the page to a range, if it is not already there. */
public native int rangeGet(Range r, int n) throws CpdfError; function rangeAdd(r, page)
/** Adds a page number to a range, returning a new one. */ /** Returns true if the page is in the range, false otherwise. */
public native Range rangeAdd(Range r, int n) throws CpdfError; function isInRange(r, page)
/** Tests to see if a given number is in a page range. */
public native boolean isInRange(Range r, int n) throws CpdfError;
/** Returns the number of pages in a PDF. */ /** Returns the number of pages in a PDF. */
public native int pages(Pdf pdf) throws CpdfError; function pages(pdf)
/** Returns the number of pages in a given /** Returns the number of pages in a given PDF, with given user password. It
PDF, with given user password. It tries to do this as fast as tries to do this as fast as possible, without loading the whole file. */
possible, without loading the whole file. function pagesFast(password, filename)
@param userpw user password
@param filename file name */
public int pagesFast(String userpw, String filename) throws CpdfError;
/** Writes the PDF document to a given filename. If <code>linearize</code> /** Writes the file to a given filename. If linearize is true, it will be
is <code>true</code>, it will be linearized if a linearizer is available. linearized if a linearizer is available. If make_id is true, it will be
If <code>make_id</code> is <code>true</code>, it will be given a new ID. given a new ID. */
@param pdf PDF document function toFile(pdf, filename, linearize, make_id)
@param filename file name
@param linearize linearize
@param make_id make new ID
*/
public void toFile(Pdf pdf, String filename, boolean linearize,
boolean make_id)
throws CpdfError;
/** Writes the PDF document to a given filename, with extra parameters. If /** Writes the file to a given filename. If make_id is true, it will be given
<code>make_id</code> is true, it will be given a new ID. If a new ID. If preserve_objstm is true, existing object streams will be
<code>preserve_objstm</code> is true, existing object streams will be preserved. If generate_objstm is true, object streams will be generated even if
preserved. If <code>generate_objstm</code> is true, object streams will be not originally present. If compress_objstm is true, object streams will be
generated even if not originally present. If <code>compress_objstm</code> compressed (what we usually want). WARNING: the pdf argument will be invalid
is true, object streams will be compressed (what we usually want). after this call, and should be not be used again. */
WARNING: the pdf argument will be invalid after this call, and should not function toFileExt(pdf, filename, linearize, make_id, preserve_objstm,
be used again. create_objstm, compress_objstm)
@param pdf PDF document
@param filename file name
@param linearize linearize
@param make_id make new ID
@param preserve_objstm preserve object streams
@param create_objstm create new object streams
@param compress_objstm compress object streams
*/
public void toFileExt(Pdf pdf, String filename, boolean linearize,
boolean make_id, boolean preserve_objstm,
boolean create_objstm, boolean compress_objstm)
throws CpdfError;
/** Writes a PDF document and returns it as an array of bytes. /** Writes a PDF file and returns as an array of bytes. */
@param pdf PDF document function toMemory(pdf, linearize, make_id)
@param linearize linearize
@param make_id make new ID
*/
public native byte[] toMemory(Pdf pdf, boolean linearize, boolean make_id)
throws CpdfError;
/** Returns <code>true</code> if a document is encrypted, /** Returns true if a document is encrypted, false otherwise. */
<code>false</code> otherwise. */ function isEncrypted(pdf)
public native boolean isEncrypted(Pdf pdf) throws CpdfError;
/** Attempts to decrypt a PDF using the given /** Attempts to decrypt a PDF using the given user password. An exception is
user password. An exception is raised if the decryption fails. raised if the decryption fails. */
@param pdf PDF document function decryptPdf(pdf, userpw)
@param userpw user password */
public void decryptPdf(Pdf pdf, String userpw) throws CpdfError;
/** Attempts to decrypt a PDF using the given owner password. Raises an /** Attempts to decrypt a PDF using the given owner password. Raises an
exception if the decryption fails. exception if the decryption fails. */
@param pdf PDF document function decryptPdfOwner(pdf, ownerpw)
@param ownerpw owner password */
public void decryptPdfOwner(Pdf pdf, String ownerpw) throws CpdfError;
/** Writes a PDF document as encrypted. The encryption method and /** Writes a file as encrypted. */
permissions are drawn from Jcpdf's fields, documented above. function toFileEncrypted(pdf, encryption_method, permissions, ownerpw, userpw,
@param pdf PDF document linearize, makeid, filename)
@param encryption_method encryption method, e.g
{@link #aes256bitisofalse aes256bitisofalse}
@param permissions array of permissions e.g {@link #noEdit noEdit}
@param owner_password owner password
@param user_password user password
@param linearize linearize
@param makeid make new ID
@param filename file name */
public void toFileEncrypted(Pdf pdf, int encryption_method,
int[] permissions, String owner_password,
String user_password, boolean linearize,
boolean makeid, String filename)
throws CpdfError;
/** Writes a file as encrypted with extra parameters. WARNING: the pdf /** Writes a file as encrypted with extra parameters. WARNING: the pdf argument
argument will be invalid after this call, and should not be used again. will be invalid after this call, and should not be used again. */
function toFileEncryptedExt(pdf, encryption_method, permissions, ownerpw, userpw,
linearize, makeid, preserve_objstm, generate_objstm,
compress_objstm, filename)
@param pdf PDF document /** Returns true if the given permission (restriction) is present. */
@param encryption_method encryption method, e.g function hasPermission(pdf, permission)
{@link #aes256bitisofalse aes256bitisofalse}
@param permissions array of permissions e.g {@link #noEdit noEdit}
@param owner_password owner password
@param user_password user password
@param linearize linearize
@param makeid make new ID
@param preserve_objstm preserve existing object streams
@param generate_objstm generate new object streams
@param compress_objstm compress object streams
@param filename file name */
public void toFileEncryptedExt(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 CpdfError;
/** Returns <code>true</code> if the given permission (restriction) such as /** Returns the encryption method currently in use on a document. */
{@link #noEdit noEdit} is present. */ function encryptionKind(pdf)
public native boolean hasPermission(Pdf pdf, int permission)
throws CpdfError;
/** Returns the encryption method currently in use on a document, such as
{@link #aes256bitisofalse aes256bitisofalse}. */
public native int encryptionKind(Pdf pdf) throws CpdfError;

View File

@ -1,33 +1,19 @@
/* CHAPTER 2. Merging and Splitting */ // CHAPTER 2. Merging and Splitting
/** Given an array of PDFs, merges the documents into a new one, which is /** Given a list of PDFs, merges the files into a new one, which is returned. */
returned. */ function mergeSimple(pdfs)
public native Pdf mergeSimple(Pdf[] pdfs) throws CpdfError;
/** Merges the PDFs. If <code>retain_numbering</code> is true page labels /** Merges the PDFs. If retain_numbering is true page labels are not
are not rewritten. If <code>remove_duplicate_fonts</code> is true, rewritten. If remove_duplicate_fonts is true, duplicate fonts are merged.
duplicate fonts are merged. This is useful when the source documents for This is useful when the source documents for merging originate from the same
merging originate from the same source. source. */
@param pdfs array of PDF documents function merge(pdfs, retain_numbering, remove_duplicate_fonts)
@param retain_numbering retain page numbering in output
@param remove_duplicate_fonts remove duplicate font data by merging */
public native Pdf merge(Pdf[] pdfs, boolean retain_numbering,
boolean remove_duplicate_fonts)
throws CpdfError;
/** Merges PDFs when one or more are drawn from the same document. It has /** The same as merge, except that it has an additional argument - a list of
an additional argument - a list of page ranges. This is used to select the page ranges. This is used to select the pages to pick from each PDF. This
pages to pick from each PDF. This avoids duplication of information when avoids duplication of information when multiple discrete parts of a source PDF
multiple discrete parts of a source PDF are included. are included. */
@param pdfs array of PDF documents function mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges)
@param retain_numbering retain page numbering in output
@param remove_duplicate_fonts remove duplicate font data by merging
@param ranges array of ranges, one for each PDF*/
public native Pdf mergeSame(Pdf[] pdfs, boolean retain_numbering,
boolean remove_duplicate_fonts, Range[] ranges)
throws CpdfError;
/** Returns a new document with just those pages in the page range. /** Returns a new document with just those pages in the page range. */
* @param pdf PDF document function selectPages(pdf, r)
* @param range range*/
public native Pdf selectPages(Pdf pdf, Range range) throws CpdfError;

View File

@ -1,134 +1,67 @@
/* CHAPTER 3. Pages */ // CHAPTER 3. Pages
/** Scales the page dimensions /** Scales the page dimensions and content by the given scale, about (0, 0).
and content by the given scale, about (0, 0). Other boxes (crop etc. are Other boxes (crop etc. are altered as appropriate) */
altered as appropriate). function scalePages(pdf, range, sx, sy)
@param pdf PDF document
@param range page range
@param sx X scale
@param sy Y scale*/
public native void scalePages(Pdf pdf, Range range, double sx, double sy)
throws CpdfError;
/** Scales the content to fit new page dimensions (width x height) /** Scales the content to fit new page dimensions (width x height) multiplied
multiplied by scale (typically 1.0). Other boxes (crop etc. are altered as by scale (typically 1.0). Other boxes (crop etc. are altered as appropriate). */
appropriate). function scaleToFit(pdf, range, sx, sy, scale)
@param pdf PDF document
@param range page range
@param w width in points
@param h height in points
@param scale scale (typically 1.0)
*/
public native void scaleToFit(Pdf pdf, Range range, double w, double h,
double scale)
throws CpdfError;
/** Scales the page content to fit the given page size, possibly multiplied /** Scales the page content to fit the given page size, possibly multiplied by
by scale (typically 1.0). scale (typically 1.0) */
@param pdf PDF document function scaleToFitPaper(pdf, range, papersize, s)
@param range page range
@param papersize paper size, such as {@link #a4portrait a0portrait}
@param scale scale (typically 1.0)
*/
public native void scaleToFitPaper(Pdf pdf, Range range, int papersize,
double scale)
throws CpdfError;
/** Scales the contents of the pages in the range about the point given by /** Scales the contents of the pages in the range about the point given by
the <code>anchor</code>, <code>p1</code> and <code>p2</code> by the scale the position, by the scale given. */
given. See the documentation for the chosen anchor. function scaleContents(pdf, range, position, scale)
@param pdf PDF document
@param range page range
@param anchor position anchor, such as {@link #posCentre posCentre}
@param p1 position parameter 1
@param p2 position parameter 2
@param scale scale
*/
public native void scaleContents(Pdf pdf, Range range, int anchor,
double p1, double p2, double scale)
throws CpdfError;
/** Shifts the content of the pages in the range. /** Shifts the content of the pages in the range. */
@param pdf PDF document function shiftContents(pdf, range, dx, dy)
@param range page range
@param dx X shift
@param dy Y shift
*/
public native void shiftContents(Pdf pdf, Range range, double dx,
double dy)
throws CpdfError;
/** Changes the viewing rotation to an absolute value. Appropriate /** Changes the viewing rotation to an absolute value. Appropriate rotations
rotations are 0, 90, 180, 270. are 0, 90, 180, 270. */
@param pdf PDF document function rotate(pdf, range, rotation)
@param range page range
@param angle viewing rotation
*/
public native void rotate(Pdf pdf, Range range, int angle)
throws CpdfError;
/** Changes the viewing rotation by a relative value. Appropriate
rotations are 0, 90, 180, 270.
@param pdf PDF document
@param range page range
@param angle viewing rotation
*/
public native void rotateBy(Pdf pdf, Range range, int angle)
throws CpdfError;
/** Rotates the content about the centre of the page by the given number of /** Rotates the content about the centre of the page by the given number of
degrees, in a clockwise direction. degrees, in a clockwise direction. */
@param pdf PDF document function rotateBy(pdf, range, rotation)
@param range page range
@param angle angle in degrees
*/
public native void rotateContents(Pdf pdf, Range range, double angle)
throws CpdfError;
/** Changes the viewing rotation of the pages in the range, /** Rotates the content about the centre of the page by the given number of
counter-rotating the dimensions and content such that there is no visual degrees, in a clockwise direction. */
change. */ function rotateContents(pdf, range, angle)
public native void upright(Pdf pdf, Range range) throws CpdfError;
/** Changes the viewing rotation of the pages in the range, counter-rotating
the dimensions and content such that there is no visual change. */
function upright(pdf, range)
/** Flips horizontally the pages in the range. */ /** Flips horizontally the pages in the range. */
public native void hFlip(Pdf pdf, Range range) throws CpdfError; function hFlip(pdf, range)
/** Flips vertically the pages in the range. */ /** Flips vertically the pages in the range. */
public native void vFlip(Pdf pdf, Range range) throws CpdfError; function vFlip(pdf, range)
/** Crops a page, replacing any existing crop box. The dimensions are in /** Crops a page, replacing any existing crop box. The dimensions are in
points. points. */
@param pdf PDF document function crop(pdf, range, x, y, w, h)
@param range page range
@param x minimum X
@param y minimum Y
@param w width
@param h height */
public native void crop(Pdf pdf, Range range, double x, double y, double w,
double h)
throws CpdfError;
/** Removes any crop box from pages in the range. */ /** Removes any crop box from pages in the range. */
public native void removeCrop(Pdf pdf, Range range) throws CpdfError; function removeCrop(pdf, range)
/** Removes any trim box from pages in the range. */ /** Removes any trim box from pages in the range. */
public native void removeTrim(Pdf pdf, Range range) throws CpdfError; function removeTrim(pdf, range)
/** Removes any art box from pages in the range. */ /** Removes any art box from pages in the range. */
public native void removeArt(Pdf pdf, Range range) throws CpdfError; function removeArt(pdf, range)
/** Removes any bleed box from pages in the range. */ /** Removes any bleed box from pages in the range. */
public native void removeBleed(Pdf pdf, Range range) throws CpdfError; function removeBleed(pdf, range)
/** Adds trim marks to the given pages, if the trimbox exists. */ /** Adds trim marks to the given pages, if the trimbox exists. */
public native void trimMarks(Pdf pdf, Range range) throws CpdfError; function trimMarks(pdf, range)
/** Shows the boxes on the given pages, for debug. */ /** Shows the boxes on the given pages, for debug. */
public native void showBoxes(Pdf pdf, Range range) throws CpdfError; function showBoxes(pdf, range)
/** Makes a given box a 'hard box' i.e clips it explicitly. /** Makes a given box a 'hard box' i.e clips it explicitly. */
@param pdf PDF document function hardBox(pdf, range, boxname)
@param range page range
@param box box name e.g "/CropBox" */
public native void hardBox(Pdf pdf, Range range, String box)
throws CpdfError;

View File

@ -1,12 +1,12 @@
/* CHAPTER 5. Compression */ // CHAPTER 5. Compression
/** Compresses any uncompressed streams in the given PDF using the Flate /** Compresses any uncompressed streams in the given PDF using the Flate
algorithm. */ algorithm. */
public native void compress(Pdf pdf) throws CpdfError; function compress(pdf)
/** Decompresses any streams in the given PDF, so long as the compression /** Decompresses any streams in the given PDF, so long as the compression
method is supported. */ method is supported. */
public native void decompress(Pdf pdf) throws CpdfError; function decompress(pdf)
/** Squeezes a pdf in memory. */ /** Squeezes a pdf in memory. */
public native void squeezeInMemory(Pdf pdf) throws CpdfError; function squeezeInMemory(pdf)

View File

@ -1,68 +1,54 @@
/* CHAPTER 6. Bookmarks */ // CHAPTER 6. Bookmarks
/** Starts the bookmark retrieval process for a given PDF. */ /** Starts the bookmark retrieval process for a given PDF. */
public native void startGetBookmarkInfo(Pdf pdf) throws CpdfError; function startGetBookmarkInfo(pdf)
/** Gets the number of bookmarks for the PDF given to {@link /** Gets the number of bookmarks for the PDF given to startGetBookmarkInfo. */
#startGetBookmarkInfo(Pdf) startGetBookmarkInfo}. */ function numberBookmarks()
public native int numberBookmarks() throws CpdfError;
/** Gets the bookmark level for the given bookmark /** Gets the bookmark level for the given bookmark (0...(n - 1)). */
<code>0...(n - 1)</code>. */ function getBookmarkLevel(n)
public native int getBookmarkLevel(int serial) throws CpdfError;
/** Gets the bookmark target page for the given PDF (which must be the /** Gets the bookmark target page for the given PDF (which must be the same
same as the PDF passed to {@link #startGetBookmarkInfo(Pdf) as the PDF passed to startSetBookmarkInfo) and bookmark (0...(n - 1)). */
startGetBookmarkInfo}) and bookmark <code>0...(n - 1)</code>. */ function getBookmarkPage(pdf, n)
public native int getBookmarkPage(Pdf pdf, int serial) throws CpdfError;
/** Returns the text of bookmark <code>0...(n - 1))</code> */ /** Returns the text of bookmark (0...(n - 1)). */
public String getBookmarkText(int serial) throws CpdfError; function getBookmarkText(n)
/** Returns <code>true</code> if the bookmark is open. */ /** True if the bookmark is open. */
public native boolean getBookmarkOpenStatus(int serial) throws CpdfError; function getBookmarkOpenStatus(n)
/** Ends the bookmark retrieval process, cleaning up. */ /** Ends the bookmark retrieval process, cleaning up. */
public native void endGetBookmarkInfo() throws CpdfError; function endGetBookmarkInfo()
/** Starts the bookmark setting process for n bookmarks. */ /** Starts the bookmark setting process for n bookmarks. */
public native void startSetBookmarkInfo(int n) throws CpdfError; function startSetBookmarkInfo(n)
/** Set bookmark level for the given bookmark <code>0...(n - 1)</code>. */ /** Set bookmark level for the given bookmark (0...(n - 1)). */
public native void setBookmarkLevel(int serial, int level) function setBookmarkLevel(a, b)
throws CpdfError;
/** Sets the bookmark target page for the given PDF (which must be the same /** Sets the bookmark target page for the given PDF (which must be the same as
as the PDF to be passed to {@link #endSetBookmarkInfo(Pdf) the PDF to be passed to endSetBookmarkInfo) and bookmark (0...(n - 1)). */
endSetBookmarkInfo}) and bookmark <code>0...(n - 1)</code>. */ function setBookmarkPage(pdf, a, b)
public native void setBookmarkPage(Pdf pdf, int serial, int pagenum)
throws CpdfError;
/** Sets the open status of bookmark <code>0...(n - 1)</code>. */ /** Sets the open status of bookmark (0...(n - 1)). */
public native void setBookmarkOpenStatus(int serial, boolean open) function setBookmarkOpenStatus(a, b)
throws CpdfError;
/** Sets the text of bookmark <code>0...(n - 1)</code>. */ /** Sets the text of bookmark (0...(n - 1)). */
public void setBookmarkText(int serial, String text) throws CpdfError; function setBookmarkText(n, t)
/** Ends the bookmark setting process, writing the bookmarks to the given /** Ends the bookmark setting process, writing the bookmarks to the given
PDF. */ PDF. */
public native void endSetBookmarkInfo(Pdf pdf) throws CpdfError; function endSetBookmarkInfo(pdf)
/** Returns the bookmark data in JSON format. */ /** Returns the bookmark data in JSON format. */
public native byte[] getBookmarksJSON(Pdf pdf) throws CpdfError; function getBookmarksJSON(pdf)
/** Sets the bookmarks from JSON bookmark data. */ /** Sets the bookmarks from JSON bookmark data. */
public native void setBookmarksJSON(Pdf pdf, byte[] data) throws CpdfError; function setBookmarksJSON(pdf, data)
/** Typesets a table of contents from existing bookmarks and prepends it to /** Typesets a table of contents from existing bookmarks and prepends it to
the document. the document. If bookmark is set, the table of contents gets its own
@param pdf PDF document
@param font font, such as {@link #timesRoman timesRoman}
@param fontsize font size
@param title table of contents title
@param bookmark if <code>true</code>, the table of contents gets its own
bookmark. */ bookmark. */
public void tableOfContents(Pdf pdf, int font, double fontsize, function tableOfContents(pdf, font, fontsize, title, bookmark)
String title, boolean bookmark)
throws CpdfError;

View File

@ -1,120 +1,47 @@
/* CHAPTER 8. Logos, Watermarks and Stamps */ // CHAPTER 8. Logos, Watermarks and Stamps
/** Stamps another PDF on top of all the pages in the document which are in /** A stamping function with extra features. - isover true, pdf goes over pdf2,
the range. The stamp is placed with its origin at the origin of the target isover false, pdf goes under pdf2 - scale_stamp_to_fit scales the stamp to fit
document. the page - pos gives the position to put the stamp - relative_to_cropbox: if
@param stamp_pdf stamp PDF document true, pos is relative to cropbox not mediabox. */
@param pdf PDF document function stampOn(stamp_pdf, pdf, range)
@param range page range */
public native void stampOn(Pdf stamp_pdf, Pdf pdf, Range range)
throws CpdfError;
/** Stamps another PDF under all the pages in the document which are in the /** Stamps stamp_pdf under all the pages in the document which are in the
range. The stamp is placed with its origin at the origin of the target range. The stamp is placed with its origin at the origin of the target
document. document. */
@param stamp_pdf stamp PDF document function stampUnder(stamp_pdf, pdf, range)
@param pdf PDF document
@param range page range */
public native void stampUnder(Pdf stamp_pdf, Pdf pdf, Range range)
throws CpdfError;
/** A stamping function with extra features. /** A stamping function with extra features. - isover true, pdf goes over
@param pdf first PDF document pdf2, isover false, pdf goes under pdf2 - scale_stamp_to_fit scales the
@param pdf2 second PDF document stamp to fit the page - pos gives the position to put the stamp -
@param range page range relative_to_cropbox: if true, pos is relative to cropbox not mediabox. */
@param isover if <code>true</code>, <code>pdf</code> goes over function stampExtended(pdf, pdf2, range, isover, scale_stamp_to_fit, position,
<code>pdf2</code> otherwise under relative_to_cropbox)
@param scale_stamp_to_fit if <code>true</code> scales the stamp to fit
the page.
@param anchor position anchor, such as {@link #posCentre posCentre}
@param p1 position parameter one
@param p2 position parameter two
@param relative_to_cropbox if <code>true</code>, the position is relative
to the crop box rather than the media box. */
public native void stampExtended(Pdf pdf, Pdf pdf2, Range range,
boolean isover,
boolean scale_stamp_to_fit, int anchor,
double p1, double p2,
boolean relative_to_cropbox)
throws CpdfError;
/** Combines the two PDFs page-by-page, putting each page of 'over' over /** Combines the PDFs page-by-page, putting each page of 'over' over each page
each page of 'under'. */ of 'under'. */
public native Pdf combinePages(Pdf under, Pdf over) throws CpdfError; function combinePages(under, over)
/** Adds text to the pages in the given range. /** Adds text to the pages in the given range. */
@param metrics if <code>true</code>, only collect metrics function addText(metrics, pdf, range, text, position, linespacing,
@param pdf PDF document bates, font, fontsize, r, g, b, underneath, relative_to_cropbox,
@param range page range outline, opacity, justification, midline, topline, filename,
@param text the text to stamp, including any special codes linewidth, embed_fonts)
@param anchor position anchor, such as {@link #posCentre posCentre}
@param p1 position parameter one
@param p2 position parameter two
@param linespacing line spacing
@param bates starting bates number
@param font font, such as {@link #timesRoman timesRoman}
@param fontsize font size
@param r red component of colour
@param g green component of colour
@param b blue component of colour
@param underneath if <code>true</code>, text goes under page
@param cropbox if <code>true</code>,
relative to cropbox rather than media box
@param outline text is outline
@param opacity opacity
@param justification justification,
such as {@link #leftJustify leftJustify}
@param midline position is relative to midline not baseline
@param topline position is relative to topline not baseline
@param filename file name, if requied by special code in text
@param linewidth line width
@param embed_fonts if true, embed fonts
*/
public void addText(boolean metrics, Pdf pdf, 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 CpdfError;
/** Adds text with most parameters default. /** Adds text with most parameters default. */
@param pdf PDF document function addTextSimple(pdf, range, text, position, font, fontsize)
@param range page range
@param text the text to stamp, including any special codes
@param anchor position anchor, such as {@link #posCentre posCentre}
@param p1 position parameter one
@param p2 position parameter two
@param font font, such as {@link #timesRoman timesRoman}
@param fontsize font size
*/
public void addTextSimple(Pdf pdf, Range range, String text, int anchor,
double p1, double p2, int font, double fontsize)
throws CpdfError;
/** Removes any text added by Jcpdf from the given pages. */ /** Removes any text added by cpdf from the given pages. */
public native void removeText(Pdf pdf, Range range) throws CpdfError; function removeText(pdf, range)
/** Returns the width of a given string in the given font in thousandths of /** Returns the width of a given string in the given font in thousandths of a
a point. point. */
@param font font, such as {@link #timesRoman timesRoman} function textWidth(font, text)
@param text text*/
public int textWidth(int font, String text) throws CpdfError;
/** Adds page content before or after the existing content to pages in the /** Adds page content before (if true) or after (if false) the existing
given range in the given PDF. content to pages in the given range in the given PDF. */
@param s page content to add function addContent(content, before, pdf, range)
@param before if <code>true</code> new content goes before, else after
@param pdf PDF document
@param range page range */
public void addContent(String s, boolean before, Pdf pdf, Range range)
throws CpdfError;
/** Stamps a PDF onto the pages in the given range in pdf as a shared Form /** Stamps stamp_pdf onto the pages in the given range in pdf as a shared Form
XObject. The name of the newly-created XObject is returned. XObject. The name of the newly-created XObject is returned. */
@param pdf PDF document function stampAsXObject(pdf, range, stamp_pdf)
@param range page range
@param stamp_pdf PDF document to stamp */
public native String stampAsXObject(Pdf pdf, Range range, Pdf stamp_pdf)
throws CpdfError;

View File

@ -1,44 +1,33 @@
/* CHAPTER 9. Multipage facilities */ // CHAPTER 9. Multipage facilities
/** Imposes a PDF. /** Imposes a PDF. There are two modes: imposing x * y, or imposing to fit a
@param pdf PDF document page of size x * y. This is controlled by fit. Columns imposes by columns
@param x x parameter rather than rows. rtl is right-to-left, btt bottom-to-top. Center is unused
@param y y parameter for now. Margin is the margin around the output, spacing the spacing between
@param fit <code>true</code>: impose to fit a page of size x by y; imposed inputs. */
<code>false</code>: impose x by y function impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, linewidth)
@param columns imposes by columns rather than rows
@param rtl impose right-to-left
@param btt impose bottom-to-top
@param center unused for now
@param margin margin around the output
@param spacing spacing between imposed inputs */
public native void impose(Pdf pdf, double x, double y, boolean fit,
boolean columns, boolean rtl, boolean btt,
boolean center, double margin, double spacing,
double linewidth)
throws CpdfError;
/** Imposes a document two up. twoUp does so by shrinking the page size, to /** Imposes a document two up. twoUp does so by shrinking the page size, to fit
fit two pages on one. */ two pages on one. */
public native void twoUp(Pdf pdf) throws CpdfError; function twoUp(pdf)
/** Imposes a document two up. twoUpStack does so by doubling the page /** Impose a document two up. twoUpStack does so by doubling the page size,
size, to fit two pages on one. */ to fit two pages on one. */
public native void twoUpStack(Pdf pdf) throws CpdfError; function twoUpStack(pdf)
/** Adds a blank page before each page in the given range. */ /** Adds a blank page before each page in the given range. */
public native void padBefore(Pdf pdf, Range range) throws CpdfError; function padBefore(pdf, range)
/** Adds a blank page after each page in the given range. */
public native void padAfter(Pdf pdf, Range range) throws CpdfError;
/** Adds a blank page after every n pages. */ /** Adds a blank page after every n pages. */
public native void padEvery(Pdf pdf, int n) throws CpdfError; function padAfter(pdf, range)
/** Adds a blank page after every n pages. */
function padEvery(pdf, n)
/** Adds pages at the end to pad the file to a multiple of n pages in /** Adds pages at the end to pad the file to a multiple of n pages in
length. */ length. */
public native void padMultiple(Pdf pdf, int n) throws CpdfError; function padMultiple(pdf, n)
/** Adds pages at the beginning to pad the file to a multiple of n pages in /** Adds pages at the beginning to pad the file to a multiple of n pages in
length. */ length. */
public native void padMultipleBefore(Pdf pdf, int n) throws CpdfError; function padMultipleBefore(pdf, n)

View File

@ -1,4 +1,4 @@
/* CHAPTER 10. Annotations */ // CHAPTER 10. Annotations
/** Returns the annotations from a PDF in JSON format. */ /** Returns the annotations from a PDF in JSON format. */
public native byte[] annotationsJSON(Pdf pdf) throws CpdfError; function annotationsJSON(pdf)

View File

@ -1,287 +1,260 @@
/* CHAPTER 11. Document Information and Metadata */ // CHAPTER 11. Document Information and Metadata
/** Finds out if a document is linearized as quickly as possible without /** Finds out if a document is linearized as quickly as possible without
loading it. */ loading it. */
public boolean isLinearized(String filename) throws CpdfError; function isLinearized(filename)
/** Returns the minor version number of a document. */ /** Returns the minor version number of a document. */
public native int getVersion(Pdf pdf) throws CpdfError; function getVersion(pdf)
/** Returns the major version number of a document. */ /** Returns the major version number of a document. */
public native int getMajorVersion(Pdf pdf) throws CpdfError; function getMajorVersion(pdf)
/** Returns the title of a document. */ /** Returns the title of a document. */
public String getTitle(Pdf pdf) throws CpdfError; function getTitle(pdf)
/** Returns the author of a document. */ /** Returns the author of a document. */
public String getAuthor(Pdf pdf) throws CpdfError; function getAuthor(pdf)
/** Returns the subject of a document. */ /** Returns the subject of a document. */
public String getSubject(Pdf pdf) throws CpdfError; function getSubject(pdf)
/** Returns the keywords of a document. */ /** Returns the keywords of a document. */
public String getKeywords(Pdf pdf) throws CpdfError; function getKeywords(pdf)
/** Returns the creator of a document. */ /** Returns the creator of a document. */
public String getCreator(Pdf pdf) throws CpdfError; function getCreator(pdf)
/** Returns the producer of a document. */ /** Returns the producer of a document. */
public String getProducer(Pdf pdf) throws CpdfError; function getProducer(pdf)
/** Returns the creation date of a document. */ /** Returns the creation date of a document. */
public String getCreationDate(Pdf pdf) throws CpdfError; function getCreationDate(pdf)
/** Returns the modification date of a document. */ /** Returns the modification date of a document. */
public String getModificationDate(Pdf pdf) throws CpdfError; function getModificationDate(pdf)
/** Returns the XMP title of a document. */ /** Returns the XMP title of a document. */
public String getTitleXMP(Pdf pdf) throws CpdfError; function getTitleXMP(pdf)
/** Returns the XMP author of a document. */ /** Returns the XMP author of a document. */
public String getAuthorXMP(Pdf pdf) throws CpdfError; function getAuthorXMP(pdf)
/** Returns the XMP subject of a document. */ /** Returns the XMP subject of a document. */
public String getSubjectXMP(Pdf pdf) throws CpdfError; function getSubjectXMP(pdf)
/** Returns the XMP keywords of a document. */ /** Returns the XMP keywords of a document. */
public String getKeywordsXMP(Pdf pdf) throws CpdfError; function getKeywordsXMP(pdf)
/** Returns the XMP creator of a document. */ /** Returns the XMP creator of a document. */
public String getCreatorXMP(Pdf pdf) throws CpdfError; function getCreatorXMP(pdf)
/** Returns the XMP producer of a document. */ /** Returns the XMP producer of a document. */
public String getProducerXMP(Pdf pdf) throws CpdfError; function getProducerXMP(pdf)
/** Returns the XMP creation date of a document. */ /** Returns the XMP creation date of a document. */
public String getCreationDateXMP(Pdf pdf) throws CpdfError; function getCreationDateXMP(pdf)
/** Returns the XMP modification date of a document. */ /** Returns the XMP modification date of a document. */
public String getModificationDateXMP(Pdf pdf) throws CpdfError; function getModificationDateXMP(pdf)
/** Sets the title of a document. */ /** Sets the title of a document. */
public void setTitle(Pdf pdf, String str) throws CpdfError; function setTitle(pdf, s)
/** Sets the author of a document. */ /** Sets the author of a document. */
public void setAuthor(Pdf pdf, String str) throws CpdfError; function setAuthor(pdf, s)
/** Sets the subject of a document. */ /** Sets the subject of a document. */
public void setSubject(Pdf pdf, String str) throws CpdfError; function setSubject(pdf, s)
/** Sets the keywords of a document. */ /** Sets the keywords of a document. */
public void setKeywords(Pdf pdf, String str) throws CpdfError; function setKeywords(pdf, s)
/** Sets the creator of a document. */ /** Sets the creator of a document. */
public void setCreator(Pdf pdf, String str) throws CpdfError; function setCreator(pdf, s)
/** Sets the producer of a document. */ /** Sets the producer of a document. */
public void setProducer(Pdf pdf, String str) throws CpdfError; function setProducer(pdf, s)
/** Sets the creation date of a document. */ /** Sets the creation date of a document. */
public void setCreationDate(Pdf pdf, String str) throws CpdfError; function setCreationDate(pdf, s)
/** Sets the modification date of a document. */ /** Sets the modification date of a document. */
public void setModificationDate(Pdf pdf, String str) throws CpdfError; function setModificationDate(pdf, s)
/** Sets the XMP title of a document. */ /** Sets the XMP title of a document. */
public void setTitleXMP(Pdf pdf, String str) throws CpdfError; function setTitleXMP(pdf, s)
/** Sets the XMP author of a document. */ /** Sets the XMP author of a document. */
public void setAuthorXMP(Pdf pdf, String str) throws CpdfError; function setAuthorXMP(pdf, s)
/** Sets the XMP subject of a document. */ /** Sets the XMP author of a document. */
public void setSubjectXMP(Pdf pdf, String str) throws CpdfError; function setSubjectXMP(pdf, s)
/** Sets the XMP keywords of a document. */ /** Sets the XMP keywords of a document. */
public void setKeywordsXMP(Pdf pdf, String str) throws CpdfError; function setKeywordsXMP(pdf, s)
/** Sets the XMP creator of a document. */ /** Sets the XMP creator of a document. */
public void setCreatorXMP(Pdf pdf, String str) throws CpdfError; function setCreatorXMP(pdf, s)
/** Sets the XMP producer of a document. */ /** Sets the XMP producer of a document. */
public void setProducerXMP(Pdf pdf, String str) throws CpdfError; function setProducerXMP(pdf, s)
/** Sets the XMP creation date of a document. */ /** Sets the XMP creation date of a document. */
public void setCreationDateXMP(Pdf pdf, String str) throws CpdfError; function setCreationDateXMP(pdf, s)
/** Sets the XMP modification date of a document. */ /** Sets the XMP modification date of a document. */
public void setModificationDateXMP(Pdf pdf, String str) throws CpdfError; function setModificationDateXMP(pdf, s)
/** Returns the components from a PDF date string in an array of length 8. /** Returns the components from a PDF date string. */
@param datestring date string function getDateComponents(string)
@param r return array */
public native void getDateComponents(String datestring, int[] r)
throws CpdfError;
/** Builds a PDF date string from individual components. */ /** Builds a PDF date string from individual components. */
public native String dateStringOfComponents(int year, int month, int day, function dateStringOfComponents(y, m, d, h, min, sec, hour_offset, minute_offset)
int hour, int minute,
int second, int hour_offset,
int minute_offset)
throws CpdfError;
/** Gets the viewing rotation for a given page. */ /** Gets the viewing rotation for a given page. */
public native int getPageRotation(Pdf pdf, int pagenumber) function getPageRotation(pdf, page)
throws CpdfError;
/** Returns <code>true</code> if the given page has the given box. E.g /** Returns true, if that page has the given box. E.g "/CropBox". */
"/CropBox". function hasBox(pdf, page, box)
@param pdf PDF document
@param pagenumber page number
@param boxname box name, e.g "/CropBox" */
public native boolean hasBox(Pdf pdf, int pagenumber, String boxname)
throws CpdfError;
/** These functions get a box given the document. The values are returned /** These functions get a box given the document, page number, min x, max x,
in a given array of length 4: min x, max x, min y, max y in points. Only min y, max y in points. Only succeeds if such a box exists, as checked by
succeeds if such a box exists, as checked by {@link #hasBox(Pdf, int, hasBox. */
String) hasBox}. */ function getMediaBox(pdf, pagenumber)
public native void getMediaBox(Pdf pdf, int pagenumber, double[] r)
throws CpdfError;
public native void getCropBox(Pdf pdf, int pagenumber, double[] r) /** These functions get a box given the document, page number, min x, max x,
throws CpdfError; min y, max y in points. Only succeeds if such a box exists, as checked by
hasBox. */
function getCropBox(pdf, pagenumber)
public native void getBleedBox(Pdf pdf, int pagenumber, double[] r) /** These functions get a box given the document, page number, min x, max x,
throws CpdfError; min y, max y in points. Only succeeds if such a box exists, as checked by
hasBox. */
function getArtBox(pdf, pagenumber)
public native void getArtBox(Pdf pdf, int pagenumber, double[] r) /** These functions get a box given the document, page number, min x, max x,
throws CpdfError; min y, max y in points. Only succeeds if such a box exists, as checked by
hasBox. */
function getBleedBox(pdf, pagenumber)
public native void getTrimBox(Pdf pdf, int pagenumber, double[] r) /** These functions get a box given the document, page number, min x, max x,
throws CpdfError; min y, max y in points. Only succeeds if such a box exists, as checked by
hasBox. */
function getTrimBox(pdf, pagenumber)
/** These functions set a box given the document page range, min x, max x, /** These functions set a box given the document, page range, min x, max x,
min y, max y in points. */ min y, max y in points. */
public native void setMediabox(Pdf pdf, Range range, double minx, function setMediabox(pdf, range, minx, maxx, miny, maxy)
double maxx, double miny, double maxy)
throws CpdfError;
public native void setCropBox(Pdf pdf, Range range, double minx, /** These functions set a box given the document, page range, min x, max x,
double maxx, double miny, double maxy) min y, max y in points. */
throws CpdfError; function setCropBox(pdf, range, minx, maxx, miny, maxy)
public native void setTrimBox(Pdf pdf, Range range, double minx, /** These functions set a box given the document, page range, min x, max x,
double maxx, double miny, double maxy) min y, max y in points. */
throws CpdfError; function setTrimBox(pdf, range, minx, maxx, miny, maxy)
public native void setArtBox(Pdf pdf, Range range, double minx, /** These functions set a box given the document, page range, min x, max x,
double maxx, double miny, double maxy) min y, max y in points. */
throws CpdfError; function setBleedBox(pdf, range, minx, maxx, miny, maxy)
public native void setBleedBox(Pdf pdf, Range range, double minx, /** These functions set a box given the document, page range, min x, max x,
double maxx, double miny, double maxy) min y, max y in points. */
throws CpdfError; function setArtBox(pdf, range, minx, maxx, miny, maxy)
/** Marks a document as trapped. */ /** Marks a document as trapped. */
public native void markTrapped(Pdf pdf) throws CpdfError; function markTrapped(pdf)
/** Marks a document as untrapped. */ /** Marks a document as untrapped. */
public native void markUntrapped(Pdf pdf) throws CpdfError; function markUntrapped(pdf)
/** Marks a document as trapped in XMP metadata. */ /** Marks a document as trapped in XMP metadata. */
public native void markTrappedXMP(Pdf pdf) throws CpdfError; function markTrappedXMP(pdf)
/** Marks a document as untrapped in XMP metadata. */ /** Marks a document as untrapped in XMP metadata. */
public native void markUntrappedXMP(Pdf pdf) throws CpdfError; function markUntrappedXMP(pdf)
/** Sets the page layout for a document, such as {@link #singlePage
singlePage} */
public native void setPageLayout(Pdf pdf, int layout) throws CpdfError;
/** Sets the page mode for a document, such as {@link #useNone useNone} */ /** Sets the page layout for a document. */
public native void setPageMode(Pdf pdf, int mode) throws CpdfError; function setPageLayout(pdf, layout)
/** Sets the page mode for a document. */
function setPageMode(pdf, mode)
/** Sets the hide toolbar flag. */ /** Sets the hide toolbar flag. */
public native void hideToolbar(Pdf pdf, boolean flag) throws CpdfError; function hideToolbar(pdf, flag)
/** Sets the hide menubar flag. */ /** Sets the hide menubar flag. */
public native void hideMenubar(Pdf pdf, boolean flag) throws CpdfError; function hideMenubar(pdf, flag)
/** Sets the hide window UI flag. */ /** Sets the hide window UI flag. */
public native void hideWindowUi(Pdf pdf, boolean flag) throws CpdfError; function hideWindowUi(pdf, flag)
/** Sets the fit window flag. */ /** Sets the fit window flag. */
public native void fitWindow(Pdf pdf, boolean flag) throws CpdfError; function fitWindow(pdf, flag)
/** Sets the center window flag. */ /** Sets the center window flag. */
public native void centerWindow(Pdf pdf, boolean flag) throws CpdfError; function centerWindow(pdf, flag)
/** Sets the display document title flag. */ /** Sets the display doc title flag. */
public native void displayDocTitle(Pdf pdf, boolean flag) throws CpdfError; function displayDocTitle(pdf, flag)
/** Sets the PDF to open, possibly with zoom-to-fit, at the given page /** Sets the PDF to open, possibly with zoom-to-fit, at the given page
number. number. */
@param pdf PDF document function openAtPage(pdf, fit, pagenumber)
@param fit if <code>true</code> zoom to fit
@param pagenumber page number */
public native void openAtPage(Pdf pdf, boolean fit, int pagenumber)
throws CpdfError;
/** Sets the XMP metadata of a document, given a file name. */ /** Sets the XMP metadata of a document, given a file name. */
public void setMetadataFromFile(Pdf pdf, String filename) throws CpdfError; function setMetadataFromFile(pdf, filename)
/** Sets the XMP metadata from an array of bytes. */ /** Sets the XMP metadata from an array of bytes. */
public native void setMetadataFromByteArray(Pdf pdf, byte[] data) function setMetadataFromByteArray(pdf, data)
throws CpdfError;
/** Removes the XMP metadata from a document. */ /** Removes the XMP metadata from a document. */
public native void removeMetadata(Pdf pdf) throws CpdfError; function removeMetadata(pdf)
/** Returns the XMP metadata from a document. */ /** Returns the XMP metadata from a document. */
public native byte[] getMetadata(Pdf pdf) throws CpdfError; function getMetadata(pdf)
/** Builds fresh XMP metadata as best it can from /** Builds fresh XMP metadata as best it can from existing metadata in the
existing metadata in the document. */ document. */
public native void createMetadata(Pdf pdf) throws CpdfError; function createMetadata(pdf)
/** Sets the metadata date for a PDF. The date is given in PDF date format. /** 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. */ cpdf will convert it to XMP format. The date 'now' means now. */
public native void setMetadataDate(Pdf pdf, String date) throws CpdfError; function setMetadataDate(pdf, date)
/** Adds page labels to a document. /** Adds page labels. The prefix is prefix text for each label. The range is
@param pdf PDF document the page range the labels apply to. Offset can be used to shift the numbering
@param style label style, such as {@link #decimalArabic decimalArabic} up or down. */
@param prefix text for each label function addPageLabels(pdf, style, prefix, offset, range, progress)
@param offset can be used to shift the numbering up or down
@param range page range
@param progress if <code>true</code>, labels progress */
public void addPageLabels(Pdf pdf, int style, String prefix, int offset,
Range range, boolean progress)
throws CpdfError
/** Removes the page labels from the document. */ /** Removes the page labels from the document. */
public native void removePageLabels(Pdf pdf) throws CpdfError; function removePageLabels(pdf)
/** Calculates the full label string for a given page, and returns it. */ /** Calculates the full label string for a given page, and returns it. */
public String getPageLabelStringForPage(Pdf pdf, int pagenumber) function getPageLabelStringForPage(pdf, pagenumber)
throws CpdfError
/** Gets page label data. Call {@link #startGetPageLabels(Pdf) /** Gets page label data. Call startGetPageLabels to find out how many
startGetPageLabels} to find out how many there are, then use these serial there are, then use these serial numbers to get the style, prefix, offset
numbers to get the style, prefix, offset and start value (note not a and start value (note not a range). Call endGetPageLabels to clean up.
range). Call {@link #endGetPageLabels() endGetPageLabels} to clean up.
<p>For example, a document might have five pages of introduction with roman For example, a document might have five pages of introduction with roman
numerals, followed by the rest of the pages in decimal arabic, numbered numerals, followed by the rest of the pages in decimal arabic, numbered from
from one: one:
<p>labelstyle = LowercaseRoman<br/> labelstyle = LowercaseRoman
labelprefix = ""<br/> labelprefix = ""
startpage = 1<br/> startpage = 1
startvalue = 1<br/> startvalue = 1
<p>labelstyle = DecimalArabic<br/> labelstyle = DecimalArabic
labelprefix = ""<br/> labelprefix = ""
startpage = 6<br/> startpage = 6
startvalue = 1<br> */ startvalue = 1 */
public native int startGetPageLabels(Pdf pdf) throws CpdfError; function startGetPageLabels(pdf)
function getPageLabelStyle(n)
public native void endGetPageLabels() throws CpdfError; function getPageLabelPrefix(n)
function getPageLabelOffset(n)
public native int getPageLabelOffset(int n) throws CpdfError; function getPageLabelRange(n)
function endGetPageLabels()
public native int getPageLabelStyle(int n) throws CpdfError;
public native int getPageLabelRange(int n) throws CpdfError;
public String getPageLabelPrefix(int n) throws CpdfError;

View File

@ -1,54 +1,41 @@
/* CHAPTER 12. File Attachments */ // CHAPTER 12. File Attachments
/** Attaches a file to the PDF. It is attached at document level. /** Attaches a file to the pdf. It is attached at document level. */
@param filename file name function attachFile(filename, pdf)
@param pdf PDF document */
public void attachFile(String filename, Pdf pdf) throws CpdfError;
/** Attaches a file to a page of the PDF. Given its file name, pdf, and the /** Attaches a file, given its file name, pdf, and the page number
page number to which it should be attached. to which it should be attached. */
@param filename file name function attachFileToPage(filename, pdf, pagenumber)
@param pdf PDF document
@param pagenumber page number to attach to */
public void attachFileToPage(String filename, Pdf pdf, int pagenumber)
throws CpdfError;
/** Attaches data from memory to a document. /** Attaches data from memory, just like attachFile. */
@param data attachment itself function attachFileFromMemory(data, filename, pdf)
@param filename file name to use to describe attachment
@param pdf PDF document */
public void attachFileFromMemory(byte[] data, String filename, Pdf pdf)
throws CpdfError;
/** Attaches data to a page from memory. /** Attaches to a page from memory, just like attachFileToPage. */
@param data attachment itself function attachFileToPageFromMemory(data, filename, pdf, pagenumber)
@param filename file name to use to describe attachment
@param pdf PDF document */
public void attachFileToPageFromMemory(byte[] data, String filename,
Pdf pdf, int pagenumber)
throws CpdfError;
/** Removes all page- and document-level attachments from a document. */ /** Removes all page- and document-level attachments from a document. */
public native void removeAttachedFiles(Pdf pdf) throws CpdfError; function removeAttachedFiles(pdf)
/** Lists information about attachments. Call /** Lists information about attachments. Call startGetAttachments(pdf) first,
{@link #startGetAttachments(pdf) startGetAttachments} first, then {@link then numberGetAttachments to find out how many there are. Then
#numberGetAttachments() numberGetAttachments} to find out how many there are. getAttachmentName etc. to return each one 0...(n - 1). Finally, call
Then {@link #getAttachmentName(int) getAttachmentName}, {@link endGetAttachments to clean up. */
#getAttachmentPage(int) getAttachmentPage}, or {@link #getAttachmentData(int) function startGetAttachments(pdf)
getAttachmentData}. to return each one <code>0...(n - 1)</code>. Finally, call
{@link #endGetAttachments() #endGetAttachments} to clean up. */
public native void startGetAttachments(Pdf pdf) throws CpdfError;
public native int numberGetAttachments() throws CpdfError; /** Lists information about attachments. Call startGetAttachments(pdf) first,
then numberGetAttachments to find out how many there are. Then
getAttachmentName etc. to return each one 0...(n - 1). Finally, call
endGetAttachments to clean up. */
function numberGetAttachments()
/** Gets the name of an attachment, given a serial number. */ /** Gets the name of an attachment. */
public native String getAttachmentName(int serial) throws CpdfError; function getAttachmentName(n)
/** Gets the page number, given a serial number. 0 = document level. */ /** Gets the page number. 0 = document level. */
public native int getAttachmentPage(int serial) throws CpdfError; function getAttachmentPage(n)
/** Gets the attachment data itself, given a serial number. */ /** Gets the attachment data itself. */
public native byte[] getAttachmentData(int serial) throws CpdfError; function getAttachmentData(n)
public native void endGetAttachments() throws CpdfError; /** Cleans up after getting attachments. */
function endGetAttachments()

View File

@ -1,28 +1,17 @@
/* CHAPTER 13. Images. */ //CHAPTER 13. Images
/** Gets image data, including resolution at all points of use. Call /** Gets image data, including resolution at all points of use. Call
{@link #startGetImageResolution(pdf, double) startGetImageResolution(pdf, startGetImageResolution(pdf, min_required_resolution) to begin the process of
min_required_resolution)} to begin the process of obtaining data on all obtaining data on all image uses below min_required_resolution, returning the
image uses below <code>min_required_resolution</code>, returning the total total number. So, to return all image uses, specify a very high
number. So, to return all image uses, specify a very high min_required_resolution. Then, call the other functions giving a serial number
<code>min_required_resolution</code>. Then, call the other functions giving 0..n - 1, to retrieve the data. Finally, call endGetImageResolution to clean
a serial number <code>0...n - 1</code>, to retrieve the data. Finally, call up. */
{@link #endGetImageResolution() endGetImageResolution} to clean up. */ function startGetImageResolution(pdf, min_required_resolution)
public native int startGetImageResolution(Pdf pdf, double res) function getImageResolutionPageNumber(n)
throws CpdfError; function getImageResolutionImageName(n)
function getImageResolutionXPixels(n)
public native int getImageResolutionPageNumber(int serial) function getImageResolutionYPixels(n)
throws CpdfError; function getImageResolutionXRes(n)
function getImageResolutionYRes(n)
public native String getImageResolutionImageName(int serial) function endGetImageResolution()
throws CpdfError;
public native int getImageResolutionXPixels(int serial) throws CpdfError;
public native int getImageResolutionYPixels(int serial) throws CpdfError;
public native double getImageResolutionXRes(int serial) throws CpdfError;
public native double getImageResolutionYRes(int serial) throws CpdfError;
public native void endGetImageResolution() throws CpdfError;

View File

@ -1,38 +1,21 @@
/* CHAPTER 14. Fonts. */ // CHAPTER 14. Fonts.
/** Retrieves font information. First, call {@link #startGetFontInfo(Pdf) /** Retrieves font information. First, call startGetFontInfo(pdf). Now call
startGetFontInfo}. Now call {@link #numberFonts() numberFonts} to return numberFonts to return the number of fonts. For each font, call one or more of
the number of fonts. For each font, call one or more of getFontPage, getFontName, getFontType, and getFontEncoding giving a serial
{@link #getFontPage(int) getFontPage}, {@link #getFontName(int) number 0..n - 1 to return information. Finally, call endGetFontInfo to clean
getFontName}, {@link #getFontType(int) getFontType}, and up. */
{@link #getFontEncoding(int) getFontEncoding} giving a serial number function startGetFontInfo(pdf)
<code>0...n - 1</code> to return information. Finally, call function numberFonts()
{@link #endGetFontInfo() endGetFontInfo} to clean up. */ function getFontPage(n)
public native void startGetFontInfo(Pdf pdf) throws CpdfError; function getFontName(n)
function getFontType(n)
public native int numberFonts() throws CpdfError; function getFontEncoding(n)
function endGetFontInfo()
public native String getFontName(int serial) throws CpdfError;
public native int getFontPage(int serial) throws CpdfError;
public native String getFontType(int setial) throws CpdfError;
public native String getFontEncoding(int serial) throws CpdfError;
public native void endGetFontInfo() throws CpdfError;
/** Removes all font data from a file. */ /** Removes all font data from a file. */
public native void removeFonts(Pdf pdf) throws CpdfError; function removeFonts(pdf)
/** Copies the given font /** Copies the given font from the given page in the 'from' PDF to every page
from the given page in the 'from' PDF to every page in the 'to' PDF. The in the 'to' PDF. The new font is stored under its font name. */
new font is stored under its font name. function copyFont(docfrom, docto, range, pagenumber, fontname)
@param from_pdf PDF document to copy from
@param to_pdf PDF document to copy to
@param range page range
@param pagenumber page number of the page to copy from
@param fontname font name */
public native void copyFont(Pdf from_pdf, Pdf to_pdf, Range range,
int pagenumber, String fontname)
throws CpdfError;

View File

@ -1,28 +1,15 @@
/* CHAPTER 15. PDF and JSON */ // CHAPTER 15. PDF and JSON
/** Outputs a PDF in JSON format to the given filename. /** Outputs a PDF in JSON format to the given filename. If parse_content is
@param filename file name true, page content is parsed. If no_stream_data is true, all stream data is
@param parse_content parse page content suppressed entirely. If decompress_streams is true, streams are decompressed. */
@param no_stream_data all stream data is suppressed entirely function outputJSON(filename, parse_content, no_stream_data, decompress_streams, pdf)
@param decompress_streams streams are decompressed
@param pdf PDF document */
public void outputJSON(String filename, boolean parse_content,
boolean no_stream_data, boolean decompress_streams,
Pdf pdf)
throws CpdfError;
/** Like outputJSON, but it writes to a byte array in memory. /** Like outputJSON, but it writes to a byte array in memory. */
@param pdf PDF document function outputJSONMemory(parse_content, no_stream_data, decompress_streams, pdf)
@param parse_content parse page content
@param no_stream_data all stream data is suppressed entirely
@param decompress_streams streams are decompressed */
public native byte[] outputJSONMemory(Pdf pdf, boolean parse_content,
boolean no_stream_data,
boolean decompress_streams)
throws CpdfError;
/** Loads a PDF from a JSON file given its filename. */ /** Loads a PDF from a JSON file given its filename. */
public Pdf fromJSON(String filename) throws CpdfError; function fromJSON(filename)
/** Loads a PDF from a JSON file in memory. */ /** Loads a PDF from a JSON file in memory. */
public native Pdf fromJSONMemory(byte[] data) throws CpdfError; function fromJSONMemory(data)

View File

@ -1,28 +1,23 @@
/* CHAPTER 16. Optional Content Groups */ // CHAPTER 16. Optional Content Groups
/** Begins retrieving optional content group names. The serial number /** Begins retrieving optional content group names. The serial number 0..n - 1
<code>0..n - 1</code> is returned. */ is returned. */
public native int startGetOCGList(Pdf pdf) throws CpdfError; function startGetOCGList(pdf)
/** Retrieves an entry in the optional content group list, given the serial /** Retrieves an OCG name, given its serial number 0..n - 1. */
number <code>0..n - 1</code>. */ function ocgListEntry(n)
public native String OCGListEntry(int serial) throws CpdfError;
/** Ends retrieval of optional content group names. */ /** Ends retrieval of optional content group names. */
public native void endGetOCGList() throws CpdfError; function endGetOCGList()
/** Renames an optional content group. /** Renames an optional content group. */
@param pdf PDF document function ocgRename(pdf, name_from, name_to)
@param f name to rename from
@param t name to rename to */
public native void OCGRename(Pdf pdf, String f, String t) throws CpdfError;
/** Ensures that every optional content group appears in the OCG order /** Ensures that every optional content group appears in the OCG order list. */
list. */ function ocgOrderAll(pdf)
public native void OCGOrderAll(Pdf pdf) throws CpdfError;
/** Coalesces optional content groups. For example, if we merge or stamp /** Coalesces optional content groups. For example, if we merge or stamp two
two files both with an OCG called "Layer 1", we will have two different files both with an OCG called "Layer 1", we will have two different optional
optional content groups. This function will merge the two into a single content groups. This function will merge the two into a single optional
optional content group. */ content group. */
public native void OCGCoalesce(Pdf pdf) throws CpdfError; function ocgCoalesce(pdf)

View File

@ -1,36 +1,16 @@
/* CHAPTER 17. Creating New PDFs */ // CHAPTER 17. Creating new PDFs
/** Creates a blank document with pages of the given width (in points), /** Creates a blank document with pages of the given width (in points), height
height (in points), and number of pages. (in points), and number of pages. */
@param w width of page function blankDocument(w, h, pages)
@param h height of page
@param pages number of pages */
public native Pdf blankDocument(double w, double h, int pages)
throws CpdfError;
/** Makes a blank document given a page size and number of pages. /** Makes a blank document given a page size and number of pages. */
@param papersize paper size, such as {@link #a0portrait a0portrait} function blankDocumentPaper(papersize, pages)
@param pages number of pages */
public native Pdf blankDocumentPaper(int papersize, int pages)
throws CpdfError;
/** Typesets a UTF8 text file ragged right on a page of size w * h in /** Typesets a UTF8 text file ragged right on a page of size w * h in points
points in the given font and font size. in the given font and font size. */
@param w width of page function textToPDF(w, h, font, fontsize, filename)
@param h height of page
@param font font, such as {@link #timesRoman timesRoman}
@param fontsize font size
@param filename file name */
public Pdf textToPDF(double w, double h, int font, double fontsize,
String filename)
throws CpdfError;
/** Typesets a UTF8 text file ragged right on a page of the given size in /** Typesets a UTF8 text file ragged right on a page of the given size in the
the given font and font size. given font and font size. */
@param papersize paper size, such as {@link #a0portrait a0portrait} function textToPDFPaper(papersize, font, fontsize, filename)
@param font font, such as {@link #timesRoman timesRoman}
@param fontsize font size
@param filename file name */
public Pdf textToPDFPaper(int papersize, int font, double fontsize,
String filename)
throws CpdfError;

View File

@ -1,91 +1,54 @@
/* CHAPTER 18. Miscellaneous */ //CHAPTER 18. Miscellaneous
/** Removes images on the given pages, replacing them with crossed boxes if /** Removes images on the given pages, replacing them with crossed boxes if
<code>boxes</code> is <code>true</code>. 'boxes' is true. */
@param pdf PDF document function draft(pdf, range, boxes)
@param range page range
@param boxes add crossed boxes */
public native void draft(Pdf pdf, Range range, boolean boxes)
throws CpdfError;
/** Removes all text from the given pages in a given document. */ /** Removes all text from the given pages in a given document. */
public native void removeAllText(Pdf pdf, Range range) throws CpdfError; function removeAllText(pdf, range)
/** Blackens all text on the given pages. */ /* Blackens all text on the given pages. */
public native void blackText(Pdf pdf, Range range) throws CpdfError; function blackText(pdf, range)
/** Blackens all lines on the given pages. */ /** Blackens all lines on the given pages. */
public native void blackLines(Pdf pdf, Range range) throws CpdfError; function blackLines(pdf, range)
/** Blackens all fills on the given pages. */ /** Blackens all fills on the given pages. */
public native void blackFills(Pdf pdf, Range range) throws CpdfError; function blackFills(pdf, range)
/** Thickens every line less than <code>min_thickness</code> to /** Thickens every line less than min_thickness to min_thickness. Thickness
<code>min_thickness</code>. Thickness given in points. given in points. */
@param pdf PDF document function thinLines(pdf, range, min_thickness)
@param range page range
@param min_thickness minimum thickness */
public native void thinLines(Pdf pdf, Range range, double min_thickness)
throws CpdfError;
/** Copies the <code>/ID</code> from one document to another. /** Copies the /ID from one document to another. */
@param pdf PDF document to copy from function copyId(pdf_from, pdf_to)
@param pdf2 PDF document to copy to */
public native void copyId(Pdf pdf, Pdf pdf2) throws CpdfError;
/** Removes a document's <code>/ID</code>. */ /** Removes a document's /ID. */
public native void removeId(Pdf pdf) throws CpdfError; function removeId(pdf)
/** Sets the minor version number of a document. /** Sets the minor version number of a document. */
@param pdf PDF document function setVersion(pdf, version)
@param version minor version number */
public native void setVersion(Pdf pdf, int version) throws CpdfError;
/** Sets the full version number of a document. /** Sets the full version number of a document. */
@param pdf PDF document function setFullVersion(pdf, major, minor)
@param major major version number
@param minor minor version nuber */
public native void setFullVersion(Pdf pdf, int major, int minor)
throws CpdfError;
/** Removes any dictionary entry with the given key anywhere in the /** Removes any dictionary entry with the given key anywhere in the document. */
document. function removeDictEntry(pdf, key)
@param pdf PDF document
@param key key to remove */
public native void removeDictEntry(Pdf pdf, String key) throws CpdfError;
/** Removes any dictionary entry with the given key whose value matches the /** Removes any dictionary entry with the given key whose value matches the
given search term. given search term. */
@param pdf PDF document function removeDictEntrySearch(pdf, key, searchterm)
@param key key to remove
@param searchterm search term */
public native void removeDictEntrySearch(Pdf pdf, String key,
String searchterm)
throws CpdfError;
/** Replaces the value associated with the given key. /** Replaces the value associated with the given key. */
@param pdf PDF document function replaceDictEntry(pdf, key, newval)
@param key key whose value to replace
@param newvalue value to replace with */
public native void replaceDictEntry(Pdf pdf, String key, String newvalue)
throws CpdfError;
/** Replaces the value associated with the given key if the existing value /** Replaces the value associated with the given key if the existing value
matches the search term. matches the search term. */
@param pdf PDF document function replaceDictEntrySearch(pdf, key, newval, searchterm)
@param key key whose value to replace
@param newvalue value to replace with
@param searchterm search term */
public native void replaceDictEntrySearch(Pdf pdf, String key,
String newvalue,
String searchterm)
throws CpdfError;
/** Removes all clipping from pages in the given range. */ /** Removes all clipping from pages in the given range. */
public native void removeClipping(Pdf pdf, Range range) throws CpdfError; function removeClipping(pdf, range)
/** Returns a JSON array containing any and all values associated with /* Returns a JSON array containing any and all values associated with the
the given key, and fills in its length. given key, and fills in its length. */
@param pdf PDF document function getDictEntries(pdf, key)
@param key key to search for */
public native byte[] getDictEntries(Pdf pdf, String key) throws CpdfError;

View File

@ -1,32 +1,2 @@
Jcpdf: Java interface to the cpdf PDF tools cpdf.js: JavaScript interface to the cpdf PDF tools
=========================================== ===================================================
The DLLs "libcpdf" and "libjcpdf" are required.
Before using the library, you must make sure your project or build environment
has access to the cpdf DLL, which is not part of the Java .jar. You can add as
am external requirement in your Java IDE. Or, you can install it in a standard
location, such as the Windows system folder.
On Windows, The DLL libcpdf.dll must be renamed to cpdf.dll, for Jcpdf to be
able to find it.
Follow the instructions at the end of Chapter 1 to write your first program. In
addition, the Jcpdf package provides documentation with each function, which
you can view in your IDE.
Usage
-----
Create an instance of the library with, for example:
Jcpdf.jcpdf = new Jcpdf()
You must call startup() to initialise the library prior to calling any other
function.
PDFs are of type Jcpdf.Pdf. Page ranges are of type Jcpdf.Range. Both PDFs and
ranges are not automatically garbage-collected. Use try or the close() method
to dispose of them.
Exceptions are of type Jcpdf.CpdfError and may be raised by any function.