PDFE Object
Provides access to the root object for the My Scripts Host object model.
Remarks
The pdfe object is the root object of the My Scripts Host object model hierarchy. It never needs to be instantiated before invoking its properties and methods, and it is always available from any script. The pdfe object provides access to information such as: the list of selected files passed when the script started, the name of the running script and the list of defined metadata properties. The pdfe object allows you to: access the internal specific PDF processing objects, create objects, connect to objects, sync events, stop a script's execution programmatically and output information to the output window.
This object implements also many of the Windows Script Host WScript root object methods and properties, and to make the My Scripts Host compatible with scripts for the WSH, this pdfe root object also exists under the WScript name, so WSH compatible scripts can run without changes.
Example
The following JScript code echoes the title metadata property of all the selected files used to start the script.
for (i = 0; i < pdfe.SelectedFiles.Count; i++) { var Item = pdfe.SelectedFiles(i); pdfe.echo(Item.Metadata.Title); }
Properties
Arguments Property | FullName Property | Interactive Property | MetadataFieldsInfo Property | OpenDialog Property | ProgressBar Property | SaveDialog Property | ScriptFullName Property | ScriptName Property | SelectedFiles Property | Version Property
Methods
Alert Method | BringWindowToFront Method | ConnectObject Method | CreateDocumentMerger Method | CreateFileObject Method | CreateObject Method | Echo Method | MessageBox Method | Quit Method | Sleep Method | VarToStr Method
Properties description
Arguments : IArguments (read)
(WSH) - Returns the IArguments object (a collection of arguments).
FullName : String (read)
(WSH) - Returns the fully qualified path of the host executable.
Interactive : Boolean (read;write)
(WSH) - Sets or identifies the script user interaction mode. When on (the default), provides user interaction. In the off state, runs without user input/output functionality.
MetadataFieldsInfo : IMetadataFieldsInfo (read)
Returns the IMetadataFieldsInfo object (a collection of IMetadataFieldInfo objects).
OpenDialog : Object (read)
Provides a simple open file dialog object.
ProgressBar : IProgressBar (read)
Returns the IProgressBar object (an object to interface the My Scripts Host GUI main progress bar).
SaveDialog : Object (read)
Provides a simple save file dialog object.
ScriptFullName : String (read)
(WSH) - Returns the full path of the currently running script.
ScriptName : String (read)
(WSH) - Returns the currently running script name.
SelectedFiles : ISelectedFiles (read)
Returns the ISelectedFiles object (a collection of IFileObject).
Version : String (read)
(WSH) - Returns the version of the My Scripts Host.
Methods description
Alert( String msg )
Displays an alert box with a specified message and an OK button.
Parameters
- msg : String
BringWindowToFront( unsigned short hWnd, [Boolean KeepAlwaysOnTop] )
Brings the specified window to the top of the Z order.
Parameters
- hWnd : unsigned short
- KeepAlwaysOnTop : Boolean (optional)
(WSH) - Connects the object's event sources to functions with a given prefix.
Parameters
CreateDocumentMerger( ) : IDocumentMerger
Returns a IDocumentMerger object, used to merge several documents together in a new document.
CreateFileObject( String Filename ) : IFileObject
Creates a stand alone IFileObject
Parameters
- Filename : String
(WSH) - Creates a COM object.
Parameters
- ProgID : String
String value indicating the programmatic identifier (ProgID) of the object you want to create.
- Prefix : String (optional)
String value indicating the function prefix.
Example
The following JScript code creates an Internet Explorer object instance, and set the event functions prefix to "objIE_". It then navigates it doing a Google search for the first selected file author metadata property. It also shows how to use the event function prefix to catch events from the object.
var objIE = pdfe.CreateObject("InternetExplorer.Application", "objIE_"); objIE.Visible = true; objIE.Navigate('www.google.com/search?q=' + pdfe.SelectedFiles(0).Metadata.Author.replace(/\s+/g, '+')); pdfe.BringWindowToFront(objIE.HWND); boolBrowserRunning = true; while (boolBrowserRunning && objIE.Visible) { pdfe.Sleep(500); } function objIE_NavigateComplete2(pDisp, URL) { pdfe.Echo("You just navigated to :" + URL); } function objIE_OnQuit() { boolBrowserRunning = false; pdfe.Echo("Closed"); }
(WSH) - Outputs text to the output window.
Parameters
- msg : String
String value indicating the text to output.
- color : Integer (optional)
Integer value indicating the RGB color of the outputted text..
- append : Boolean (optional)
Used, if set to True, to append the passed text to the previous output line.
Example
pdfe.echo('Red',0xFF0000); pdfe.echo('Green',0x00FF00); pdfe.echo('Blue',0x0000FF); pdfe.echo('Default text color');
MessageBox( String lpText, String lpCaption, unsigned short uType ) : Integer
Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information. The message box returns an integer value that indicates which button the user clicked.
Parameters
- lpText : String
The message to be displayed. If the string consists of more than one line, you can separate the lines using a carriage return and/or linefeed character between each line.
- lpCaption : String
The dialog box title.
- uType : unsigned short
The contents and behavior of the dialog box. This parameter can be a combination of flags.
Quit( [Integer ErrorCode] )
(WSH) - Forces script execution to stop at any time.
Parameters
- ErrorCode : Integer (optional)(not used)
Sleep( Integer Duration )
(WSH) - Suspends script execution for a specified length of time, then continues execution.
Parameters
- Duration : Integer
Integer value indicating the interval (in milliseconds) you want the script process to be inactive.
ISelectedFiles Object
The collection of the selected files objects, filtered by the file types the script can handle and in the order in which they were originally entered.
Remarks
Example
Properties
Methods
This object has no methods
Properties description
Count : Integer (read)
Returns the number of ISelectedFile items in the collection
Item( Integer Index ) : IFileObject (read;default)
Exposes a specified IFileObject item from the collection.
IFileObject Object
It's the root object to access all the document processing functionalities.
Remarks
Example
Properties
AttachmentRoot Property | BookmarkRoot Property | DateLastModified Property | FileSize Property | Filename Property | Metadata Property | NumPages Property | Pages Property
Methods
Properties description
AttachmentRoot : IAttachment (read)
The attachments root folder for the attachments tree. This attachment does not physically exists as a real attachment but is a
programmatic construct used to access the attachments tree..
BookmarkRoot : IBookmark (read)
The root bookmark for the bookmark tree. This bookmark is not displayed to the user but is a
programmatic construct used to access the tree and the child bookmarks.
DateLastModified : Date (read)
Returns the file last modification date
FileSize : Integer (read)
Returns the file size
Filename : String (read)
Returns the full path filename
Metadata : IFileMetadata (read;default)
Returns the document IFileMetadata object
NumPages : Integer (read)
Returns the number of pages in the document
Pages : IPDFPages (read)
Returns the document IPDFPage object
Methods description
IPDFPages Object
The entire collection of pages of the document
Remarks
Example
Properties
Methods
Properties description
Methods description
IPDFPage Object
Represents a page object in the document.
Remarks
Example
Properties
ArtBox Property | BleedBox Property | CropBox Property | Height Property | MediaBox Property | Rotation Property | Text Property | TextEx Property | TrimBox Property | Width Property
Methods
This object has no methods
Properties description
ArtBox : IFloatRect (read;write)
Sets or returns the page ArtBox rectangle
BleedBox : IFloatRect (read;write)
Sets or returns the page BleedBox rectangle
CropBox : IFloatRect (read;write)
Sets or returns the page CropBox rectangle
Height : Single (read)
Gets the page height
MediaBox : IFloatRect (read;write)
Sets or returns the page MediaBox rectangle
Rotation : Integer (read;write)
Sets or returns the page rotation angle
Text : String (read)
Gets the page text content.
TextEx : Object (read)
Gets the page extended text object.
TrimBox : IFloatRect (read;write)
Sets or returns the page TrimBox rectangle
Width : Single (read)
Gets the page width
IMetadataFieldsInfo Object
Provides access to the entire collection of metadata fields definitions, standard and custom.
Remarks
Example
Properties
Methods
This object has no methods
Properties description
Count : Integer (read)
Returns the number of IFileMetadata items in the collection.
Item( Integer Index ) : IMetadataFieldInfo (read;default)
Exposes a specified IFileMetadata item from the collection.
IProgressBar Object
Provides access to the My Scripts Host GUI main progress bar.
Remarks
Example
Properties
Methods
This object has no methods
IFloatRect Object
A simple rectangle structure object
Remarks
Example
Properties
Methods
This object has no methods
IMetadataFieldInfo Object
A metadata field information object, to get information about its definition characteristics
Remarks
Example
Properties
Methods
This object has no methods
IArguments Object
(WSH) - Provides access to the entire collection of command-line parameters, in the order in which they were originally entered.
Remarks
Example
Properties
Methods
IFileMetadata Object
To read and write document metadata properties.
Remarks
Example
Properties
Author Property | Calculated Property | Count Property | CreationDate Property | Creator Property | Custom Property | EncryptLevel Property | Item Property | Keywords Property | ModificationDate Property | Producer Property | Subject Property | Title Property | Version Property
Methods
Properties description
Author : String (read;write)
Returns or sets the document author metadata field.
Count : Integer (read)
Returns the number of metadata items in the collection.
CreationDate : Variant (read;write)
Returns or sets the document creation date metadata field.
Creator : String (read;write)
Returns or sets the document creator metadata field.
Returns or sets a document, index specified, custom metadata field.
EncryptLevel : Integer (read)
Returns the document encrypt level.
Exposes a specified metadata item from the collection.
Keywords : String (read;write)
Returns or sets the document keywords metadata field.
ModificationDate : Variant (read;write)
Returns or sets the document modification date metadata field.
Producer : String (read;write)
Returns or sets the document producer metadata field.
Subject : String (read;write)
Returns or sets the document subject metadata field.
Title : String (read;write)
Returns or sets the document title metadata field.
Version : String (read)
Returns the document version.
Methods description
IAttachment Object
Represents a attachment object. The root attachment is obtained from the IFileObject AttachmentRoot property.
Remarks
Example
The following JScript dump the names and description of all the attachments in the document.
var ProgressBar = pdfe.ProgressBar; ProgressBar.max = pdfe.SelectedFiles.Count; for (var i = 0; i < pdfe.SelectedFiles.count; i++) { ProgressBar.position = i + 1; var doc = pdfe.SelectedFiles(i); if (doc.AttachmentRoot.Children.Count > 0) { pdfe.echo('>' + doc.filename, 0x0000FF); DumpAttachments(' ', doc.AttachmentRoot.Children); } } function DumpAttachments(parentName, Attachments) { if (Attachments) { for (var i = 0; i < Attachments.count; i++) { var attachment = Attachments(i); if (attachment.AttType == 1 /*attFile*/ ) { var desc = (attachment.description.length > 0) ? ' : ' + attachment.description : ""; pdfe.echo(parentName + attachment.name + desc); } else { DumpAttachments(parentName + attachment.name + '\\', attachment.Children); } } } }
Properties
Methods
Properties description
AttType : user defined type (read)
The type (attFolder=0,attFile=1) of the attachment.
Children : IAttachments (read)
A IAttachments object, that list the children, if this is a attachment of type attFolder
Description : String (read)
The text string for the attachment description that the user sees in the attachments panel
Name : String (read)
The text string for the attachment that the user sees in the attachments panel
Methods description
Saves the attachment to an external file or folder.
Parameters
- Path : String
If the attachment type is of attFolder, the full path directory name were to save all the contained attachments.
If of type attFile, can be just a full path directory name and the created file name will be the attachment name, or a full path and filename to also specify the file name to use.
IAttachments Object
Remarks
Example
Properties
Methods
This object has no methods
Properties description
IBookmark Object
Remarks
Example
The following JScript dump the bookmark names of the document bookmark tree.
var ProgressBar = pdfe.ProgressBar; ProgressBar.max = pdfe.SelectedFiles.Count; for (var i = 0; i < pdfe.SelectedFiles.count; i++) { ProgressBar.position = i + 1; var doc = pdfe.SelectedFiles(i); if (doc.BookmarkRoot && doc.BookmarkRoot.Children) { pdfe.echo('>' + doc.filename, 0x0000FF); DumpBookmark(doc.BookmarkRoot, 0); } } function DumpBookmark(bookmark, index) { if (bookmark) { if (index > 0) pdfe.echo(Array(index * 3).join(" ") + bookmark.name); var children = bookmark.Children; if (children) { for (var i = 0; i < children.count; i++) { DumpBookmark(children(i), index + 1); } } } }
Properties
Methods
This object has no methods
Properties description
Children : IBookmarks (read)
A IBookmarks object that list the children of this bookmark in the bookmark tree
DestPageIndex : Integer (read)
The target page, zero-based, index. Returns -1 if the target is not a page in the document or if the target could not be determined.
Name : String (read)
The text string for the bookmark that the user sees in the navigational panel
IDocumentMerger Object
A document merger object
Remarks
Example
The following JScript code exemplifies how to use the two different merge functions.
var Merger = pdfe.CreateDocumentMerger(); Merger.BookmarkAll1stPages = true; //merge all selected documents odd pages for (var i = 0; i < pdfe.SelectedFiles.Count; i++) { Merger.MergeDocument(pdfe.SelectedFiles(i).Filename,'odd'); } Merger.EndAndSaveTo('C:\\Temp\\Merged_OddPages.pdf'); //Merge all document 1st page, passing IPDFPage objects, and at same time rotate the page for (var i = 0; i < pdfe.SelectedFiles.Count; i++) { var page=pdfe.SelectedFiles(i).Pages(0); page.Rotation=90; Merger.MergePage(page); } Merger.EndAndSaveTo('C:\\Temp\\Merged_1sPages.pdf');
Properties
BookmarkAll1stPages Property | GroupBookmarksByDocument Property | GroupLayersByDocument Property | KeepBookmarks Property | KeepLayers Property | LastError Property
Methods
Properties description
BookmarkAll1stPages : Boolean (read;write)
Sets or identifies if a bookmark, for the document first page, should always be added, even for documents without bookmarks defined.
GroupBookmarksByDocument : Boolean (read;write)
If bookmarks are kept, sets or identifies if bookmarks are grouped by merged document.
GroupLayersByDocument : Boolean (read;write)
If layers are kept, sets or identifies if layers are grouped by merged document.
KeepBookmarks : Boolean (read;write)
Sets or identifies if the document bookmarks are kept.
KeepLayers : Boolean (read;write)
Sets or identifies if the document layers are kept
LastError : String (read)
If one of the merge function returns false, this property contains the related error message.
Methods description
Ends the merge operation, and save the result document to the specified file name. When done, the object is ready to start another merge operation.
Parameters
- Filename : String
Merge a blank page, specifying its width and height in millimeters
Parameters
Merge a document, specifying its file name and, optionally, the pages to include.