PDF methods reference
Close()
Closes the PDF file. If changes were made but not saved, they are silently lost. All Page objects must be released before closing a PDF.
Syntax
Close()
Note: Before using Close() in Javascript, you should call the CollectGarbage() global method to ensure all references to pages are properly discarded. This additional statement is not required with other languages. For instance:
var objPDF = Watch.GetPDFEditObject();
objPDF.Open(Watch.GetJobFileName(), false);
var objPages = objPDF.Pages();
var objPage = null;
for(var i=0; i<objPages.Count(); i++) {
objPage = objPages.Item(i);
}
objPage=null;
objPages=null;
CollectGarbage();
objPDF.Close();
If you run the above code without calling the CollectGarbage() method, the Close() method will error out.
Create(filename)
Creates a new empty PDF file. See also: Save().
Syntax
Create(filename)
filename
String. Name of the file to create. The file is not physically written to disk until PDF.Save() is called.
GetInfos()
Retrieves the contents of the Document Information Dictionary from the PDF.
Syntax
PdfInfos GetInfos ()
Return value
A PdfInfos structure containing the PDF properties. Cannot be NULL.
GetXMP()
Retrieves the XMP attachment embedded in the PDF.
Syntax
GetXMP()
Return value
String containing the complete text of the PDF's XMP attachment.
GetXYML()
Retrieves the entire extractable text from the PDF in XYML format.
Syntax
GetXYML()
Return value
A string containing the complete text of the PDF in XYML format.
IsProtected(filename)
Returns True if the PDF file is password-protected. When a file is password-protected, the OpenEx() method must be used instead of the Open() method. See also: OpenEx(filename, password, doRepair).
Syntax
IsProtected(filename)
filename
String. Name of the file to check for password-protection.
Return value
Boolean. True if the file is password-protected, False otherwise.
MergeWith(pdfFilename)
Merges the pages of pdfFilename (the source) onto the pages of the current PDF (the destination ). Each page of the source is overlaid transparently onto the corresponding destination page, 1 on 1, 2 on 2, 3 on 3, etc. The source must have the same number of pages than the destination and each pair of pages should have the same size. The resulting file is not optimized.
This method is the same as calling: PDF.MergeWith2(pdfFilename, 1, 1, 0, 0, 1.0); (see MergeWith2(pdfFilename, xnum, ynum, xoffset, yoffset, scaleFactor)).
Syntax
MergeWith(pdfFilename)
pdfFilename
String. Name of the source PDF from which pages are taken to be overlaid on the pages of the destination PDF.
MergeWith2(pdfFilename, xnum, ynum, xoffset, yoffset, scaleFactor)
Merges the pages of pdfFilename (the source) onto the pages of the current PDF (the destination). Each page of the source is overlaid transparently onto a destination page in a grid whose size is specified by xnum and ynum. The pages are laid from left to right and then from top to bottom. The resulting file is not optimized.
In PlanetPress Suite, this method is useful for n-Up imposition. For example, (xnum=1, ynum=1, scaleFactor=1.0) means that each source is overlaid on the corresponding destination page, 1 on 1, 2 on 2, 3 on 3, etc. Having (xnum=3, ynum=2) with xoffset, yoffset and scaleFactor set accordingly results in a 3x2 mosaic looking like this:
1 |
2 |
3 |
4 |
5 |
6 |
There is no separator between the source pages on the destination page. A space can be obtained by using an offset bigger than the size of the scaled source page.
Syntax
MergeWith2(pdfFilename, xnum, ynum, xoffset, yoffset, scaleFactor)
pdfFilename
String. Name of the source PDF from which pages are taken.
xnum
Integer. Number of columns.
ynum
Integer. Number of rows.
xoffset
Integer. Horizontal space to put between the top left corner of each source page, in points.
yoffset
Integer. Vertical space to put between the top left corner of each source page, in points.
scaleFactor
Float. Scale at which to draw on source pages on the destination. Use 1.0 to draw the page at its nominal size.
Open(filename, doRepair)
Opens an existing PDF, optionally repairing it.
Syntax
Open(filename, doRepair)
filename
String. Name of the file to open.
doRepair
Boolean. If true, the software automatically attempts to repair the file if it is found to be damaged or corrupt. Otherwise, the operation fails if the file is damaged.
OpenEx(filename, password, doRepair)
Opens an existing, password-protected PDF, optionally repairing it. See also: IsProtected(filename).
Syntax
OpenEx(filename, password, doRepair)
filename
String. Name of the file to open.
password
String. Password to open the file.
doRepair
Boolean. If true, the software automatically attempts to repair the file if it is found to be damaged or corrupt. Otherwise, the operation fails if the file is damaged.
Pages()
Provides access to the Pages collection of the PDF.
Syntax
Pages()
Return value
A Pages collection object. Each page in the zero-based collection can be accessed through the Pages.Item() method. Note that since Item() is the collection's default method, it can be omitted altogether (i.e. Pages(0) is the same as Pages.Item(0)).
Print(printername, fromPage, toPage)
Prints a range of PDF pages to the specified Windows printer with default options. See also: PrintEx(printername, PdfPrintParams).
Syntax
Print(printername, fromPage, toPage)
printerName (optional)
String. Name of the printer to print to. The default options of the printer will be used. If NULL, the default printer is used.
fromPage
Integer. 0-based index of the first page to print.
toPage
Integer. 0-based index of the last page to print. To print all pages from fromPage to the end, use -1.
PrintEx(printername, PdfPrintParams)
Prints a range of PDF pages to the specified Windows printer with specific printer options stored in an PdfPrintParams structure. See also: Print(printername, fromPage, toPage).
Syntax
PrintEx(printername, PdfPrintParams)
printerName (optional)
String. Name of the printer to print to. The default options of the printer will be used. PdfPrintParams , if non-NULL, may override some of them. If NULL, the default printer is used.
PdfPrintParams (optional)
PdfPrintParams structure that specifies various print options. If NULL , default values are used.
Save()
Saves changes to the PDF file. The version of the PDF file format is the highest possible for a newly created file and is unchanged when saving an existing file, unless the SetVersion method was called in which case the file format used will be the one set by SetVersion. See also: SetVersion (major, minor).
Syntax
VOID Save (BOOL optimize)
optimize
If true, the file is optimized before being written to disk, i.e. objects are garbage-collected and/or regenerated, the PDF is linearized, etc.
SetInfos(Infos)
Sets the contents for the PDF's Document Information Dictionary.
Syntax
SetInfos(Infos)
Infos
PdfInfos structure containing the new values.
SetVersion (major, minor)
Sets the version of the underlying PDF file format. This is applied when the file is saved. See also: Save().
Syntax
SetVersion (major, minor)
major
Integer. Major version number.
minor
Integer. Minor version number.
SetXMP(xmpPacket)
Sets the XMP attachment by replacing the existing one with xmpPacket.
Syntax
SetXMP(xmpPacket)
xmpPacket
String. New XMP attachment to use instead of the existing one.