Skip to content

Scripting Interface

clawsoftware edited this page Apr 5, 2023 · 14 revisions

Intro

Starting from version 0.8.9, clawPDF has enabled the scripting interface, which facilitates the integration of clawPDF API into other applications or scripts. You can find some example scripts HERE.

clawPDF.JobQueue

Intro

The JobQueue manages incoming print jobs and provides various methods and properties to handle them. The methods and properties available are described in the following list:

Documentation

void Initialize()

This method must be called first after creating the COM Object to enable its use.

bool WaitForJob(int timeOut)

The queue waits for one job to arrive within the specified time limit, returns true if a job arrives within the time limit, otherwise false.

bool WaitForJobs(int jobCount, int timeOut)

The queue waits for a specified number of jobs to arrive within the specified time limit, returns true if all jobs arrive within the time limit, otherwise false.

PrintJob WaitForFirstJob()

The queue waits for the first job to arrive and returns the PrintJob object.

void SetProfileSetting(string name, string value)

This method sets a conversion profile property for all jobs using the specified name and value strings.

int Count

This property counts the number of current print jobs in the queue.

PrintJob NextJob

This property provides a reference to the next job in the queue as a PrintJob object.

PrintJob GetNextJobByIndex(int index)

This method provides a reference to the job at the specified index in the queue as a PrintJob object.

void MergeAllJobs()

This method merges all available jobs in the queue into one print job.

void MergeJobs(PrintJob job1, PrintJob job2)

This method merges two specified jobs from the queue into one print job.

void DeleteJob(int index)

This method deletes the job at the specified index from the queue.

void ReleaseCom()

This method releases the current COM object instance.

PrintJob

Intro

The PrintJob is used to manage each print job in the queue and offers various methods and properties. These are described below:

Example

...
Set clawPDFQueue = CreateObject("clawPDF.JobQueue")

If (Not clawPDFQueue.WaitForJob(10)) Then
    WScript.Echo "The print job did not reach the queue within 10 seconds"
Else
   WScript.Echo "Currently there are " & clawPDFQueue.Count & " job(s) in the queue"
   WScript.Echo "Getting job instance"
   Dim printJob
   Set printJob = clawPDFQueue.NextJob
   printJob.SetProfileByGuid("DefaultGuid")
   printJob.ConvertTo(fullPath)
End If

clawPDFQueue.ReleaseCom()
...

Documentation

void SetProfileByGuid(string profileGuid)

This method sets the conversion profile using the specified guid.

void ConvertTo(string path)

This method starts the actual conversion and saves the converted file to the specified location.

FileStream ConvertToFileStream(string fileName)

This method starts the actual conversion and saves the converted file to a FileStream.

bool ConvertToFileStream(out fileStream, string fileName)

This method starts the actual conversion and saves the converted file to a FileStream.

void ConvertToAsync(string path)

This method starts the actual conversion asynchronously and saves the converted file to the specified location.

void SetProfileSetting(string name, string value)

This method sets a conversion profile property using the specified name and value strings.

string GetProfileSetting(string name)

This method returns the value of the specified conversion profile property as a string.

OutputFiles GetOutputFiles()

This method returns a reference to the files produced by the conversion.

PrintJobInfo PrintJobInfo

This property provides a reference to a PrintJobInfo object, which allows for obtaining additional information on the PrintJob, such as its name and author.

void JobFinished()

This event is fired when the job is finished.

bool IsFinished

This property returns true if the conversion of the job has finished, otherwise false.

bool IsSuccessful

This property returns true if the conversion of the job was successful, otherwise false.

PrintJobInfo

Intro

The PrintJobInfo object provides information about a PrintJob object, such as its name, author, subject, keywords, and producer. The available properties are described below:

Documentation

string PrintJobName

This property gets or sets the name of the PrintJob object.

string PrintJobAuthor

This property gets or sets the author of the PrintJob object.

string Subject

This property gets or sets the subject of the PrintJob object.

string Keywords

This property gets or sets the keywords of the PrintJob object.

string Producer

This property gets the producer of the PrintJob object, which is the newest version of clawPDF.

OutputFiles

Intro

The OutputFiles object provides information about the files produced after the conversion process has finished. The available methods and properties are described below:

Documentation

int Count

This property returns the number of all produced output files.

string GetFilename(int index)

This method returns the name of the file at the specified position, which is determined by the index parameter. The return value is the name of the file.

Printers

Intro

The Printers object provides information about the available printer devices to clawPDF. The available methods and properties are described below:

Documentation

int Count

This property returns the number of available printer devices.

string GetPrinterByIndex(int index)

This method returns the name of the printer device with the specified index. The index parameter is used to determine the position of the printer device in the list. The return value is the name of the printer device as a string.

clawPDF.clawPDFObj

Intro

The clawPDFObj provides information about clawPDF, including its current state and application settings. The available methods and properties are described below:

Printers GetclawPDFPrinters

This property returns a Printers object that provides information about the available printer devices to clawPDF.

bool IsInstanceRunning

This property checks if clawPDF is already running and returns true if it is, otherwise false. It is recommended to use this property before initializing the queue object.

void PrintFile(string filePath)

This method executes a print command on the file specified by the filePath parameter.

void PrintFileSwitchingPrinters(string path, bool allowDefaultPrinterSwitch)

This method executes a print command on the file specified by the path parameter and allows you to decide if the default printer should be temporarily switched. If the allowDefaultPrinterSwitch parameter is set to true, the default printer will be temporarily switched regardless of the current clawPDF application setting. Otherwise, it behaves like the PrintFile method.

void AddFileToQueue(string path)

This method adds a file directly to the queue without the need for printing. Currently, only .PS files can be added directly.

Setting Type Description
AuthorTemplate String Defines a template for the author field. The template may include tokens.
FileNameTemplate String Defines a template for the filename of the converted document. The template may include tokens.
Guid String The globally unique identifier (GUID) of the profile.
Name String The name of the profile.
OpenViewer Bool If true, opens the default viewer after converting the document.
OutputFormat Enum The default output format for the print job. Valid values are: Pdf, PdfA1B, PdfA2B, PdfA3B, PdfX, OCRTxt, PdfImage8, PdfImage24, PdfImage32, PdfOCR8, PdfOCR24, PdfOCR32, SVG, Jpeg, Png, Tif and Txt.
ShowProgress Bool If true, displays a progress window during conversion.
TitleTemplate String Defines a template for the title field. The template may include tokens.
AttachmentPage - Defines settings for appending one or more pages at the end of the converted document.
AttachmentPage.Enabled Bool If true, enables the AttachmentPage action.
AttachmentPage.File String The filename of the PDF that will be appended.
BackgroundPage - Defines settings for adding a page background to the resulting document.
BackgroundPage.Enabled Bool If true, enables the BackgroundPage action.
BackgroundPage.File String The filename of the PDF that will be used as background.
BackgroundPage.OnAttachment Bool If true, places the background on the attachment as well.
BackgroundPage.OnCover Bool If true, places the background on the cover as well.
BackgroundPage.Repetition Enum Defines the way the background document is repeated. Valid values are: NoRepetition, RepeatAllPages, RepeatLastPage.
CoverPage - Defines settings for inserting one or more pages at the beginning of the converted document.
CoverPage.Enabled Bool If true, enables the CoverPage action.
CoverPage.File String The filename of the PDF that will be inserted.
OCRSettings - Defines settings for OCR
OCRSettings.OCRLanguage string The language to be recognized in the given document.
EmailClient - Defines settings for opening the default email client with the converted document as an attachment.
EmailClient.Enabled Bool If true, enables the EmailClient action.
EmailClient.AddSignature Bool If true, adds the clawPDF signature to the email.
EmailClient.Content String The body text of the email.
EmailClient.Recipients String The list of recipients of the email, separated by semicolons.
EmailClient.Subject String The subject line of the email.
EmailSmtp - Defines settings for sending an email through SMTP without user interaction.
EmailSmtp.Enabled Bool If true, enables the EmailSmtp action.
EmailSmtp.AddSignature Bool If true, adds the clawPDF signature to the email.
EmailSmtp.Address String The email address that is displayed as the sender.
EmailSmtp.Content String The body text of the email.
EmailSmtp.Password String The password used to authenticate at the server.
EmailSmtp.Port Int The port number of the SMTP server
EmailSmtp.Recipients String The list of email addresses to receive the email, separated by semicolons
EmailSmtp.SameTextAsClientMail Bool If true, the email body from the EmailClient action will be used
EmailSmtp.Server String The hostname or IP address of the SMTP server
EmailSmtp.Ssl Bool If true, the connection to the SMTP server will be encrypted with SSL (if supported)
EmailSmtp.Subject String The subject line of the email
EmailSmtp.UserName String The username used to authenticate at the SMTP server
Ftp - FTP settings
Ftp.Enabled Bool If true, FTP upload action will be executed
Ftp.Directory String The target directory on the FTP server where the files will be uploaded
Ftp.EnsureUniqueFilenames Bool If true, files with the same name will not be overwritten on the FTP server. A counter will be appended instead (i.e. document_2.pdf)
Ftp.Password String The password used to authenticate at the FTP server
Ftp.Server String The hostname or IP address of the FTP server
Ftp.UserName String The username used to authenticate at the FTP server
Ghostscript - Ghostscript settings
Ghostscript.AdditionalGsParameters String Additional parameters to be passed to Ghostscript in addition to the clawPDF parameters
JpegSettings - Jpeg settings
JpegSettings.Color Enum The number of colors in the JPEG output. Valid values: Color24Bit, Gray8Bit
JpegSettings.Dpi Int The resolution (DPI) of the JPEG files
JpegSettings.Quality Int The quality factor of the resulting JPEG, with 100 being the best and 0 being the worst
PdfSettings - PDF settings
PdfSettings.ColorModel Enum The color model of the PDF (does not apply to images). Valid values: Rgb, Cmyk, Gray
PdfSettings.DocumentView Enum Defines which controls will be opened in the PDF reader. Valid values: NoOutLineNoThumbnailImages, Outline, ThumbnailImages, FullScreen, ContentGroupPanel, AttachmentsPanel
PdfSettings.FastWebView Bool If true, the PDF will be linearized, which allows the first pages to be displayed even if the rest of the document is still loading
PdfSettings.PageOrientation Enum Defines how pages are automatically rotated. Valid values: Automatic, Portrait, Landscape
PdfSettings.PageView Enum Defines how the PDF document will be opened in the reader. Valid values: OnePage, OneColumn, TwoColumnsOddLeft, TwoColumnsOddRight, TwoPagesOddLeft, TwoPagesOddRight
PdfSettings.ViewerStartsOnPage Int Defines the page number the PDF reader will start on when opening the document
PdfSettings.CompressColorAndGray.Compression Enum Specifies the compression method to be used for color and grayscale images. Valid options include: Automatic, JpegMaximum, JpegHigh, JpegMedium, JpegLow, JpegMinimum, JpegManual, and Zip.
PdfSettings.CompressColorAndGray.Dpi Int Sets the maximum resolution for color and grayscale images after resampling (if enabled).
PdfSettings.CompressColorAndGray.Enabled Bool Determines whether or not compression is applied to color and grayscale images. If set to false, images will remain uncompressed.
PdfSettings.CompressColorAndGray.JpegCompressionFactor Double Allows for the specification of a custom compression factor when using JpegManual as the compression method.
PdfSettings.CompressColorAndGray.Resampling Bool Determines whether or not images will be resampled to a maximum resolution.
PdfSettings.CompressMonochrome.Compression Enum Specifies the compression method to be used for monochrome images. Valid options include: CcittFaxEncoding, Zip, and RunLengthEncoding.
PdfSettings.CompressMonochrome.Dpi Int Sets the maximum resolution for monochrome images after resampling (if enabled).
PdfSettings.CompressMonochrome.Enabled Bool Determines whether or not compression is applied to monochrome images. If set to false, images will remain uncompressed.
PdfSettings.CompressMonochrome.Resampling Bool Determines whether or not images will be resampled to a maximum resolution.
PdfSettings.Security - PDF Security settings
PdfSettings.Security.AllowPrinting Bool Determines whether or not users are allowed to print the PDF document.
PdfSettings.Security.AllowScreenReader Bool Determines whether or not users are allowed to use a screen reader to access the PDF document.
PdfSettings.Security.AllowToCopyContent Bool Determines whether or not users are allowed to copy content from the PDF document.
PdfSettings.Security.AllowToEditAssembly Bool Determines whether or not users are allowed to make changes to the assembly of the PDF document.
PdfSettings.Security.AllowToEditComments Bool Determines whether or not users are allowed to edit comments within the PDF document.
PdfSettings.Security.AllowToEditTheDocument Bool Determines whether or not users are allowed to edit the PDF document.
PdfSettings.Security.AllowToFillForms Bool Determines whether or not users are allowed to fill in forms within the PDF document.
PdfSettings.Security.Enabled Bool Determines whether or not the PDF document is password protected.
PdfSettings.Security.EncryptionLevel Enum Specifies the encryption level to be used for password protection. Valid options include: Rc40Bit, Rc128Bit, and Aes128Bit.
PdfSettings.Security.OwnerPassword String Specifies a password that can be used to modify the PDF document.
PdfSettings.Security.RequireUserPassword Bool Determines whether or not a password is required to open the PDF document.
PdfSettings.Security.RestrictPrintingToLowQuality Bool Determines whether or not only low resolution printing is allowed.
PdfSettings.Security.UserPassword String Specifies the password required to open the PDF document (if set).
PdfSettings.Signature - Enables digital signature of the PDF document.
PdfSettings.Signature.Enabled Bool If set to true, the PDF document will display the digital signature.
PdfSettings.Signature.CertificateFile String Specifies the path to the certificate file used for the digital signature.
PdfSettings.Signature.SignPassword String Specifies the password for the digital signature certificate file.
PdfSettings.Signature.AllowMultiSigning Bool If set to true, the PDF document can be signed by multiple persons.
PdfSettings.Signature.SignLocation String Specifies the location of the digital signature.
PdfSettings.Signature.SignReason String Specifies the reason for the digital signature.
PdfSettings.Signature.SignContact String Specifies the contact name of the person who signed the PDF document.
PdfSettings.Signature.DisplaySignatureInDocument Bool If set to true, the PDF document will display the digital signature.
PdfSettings.Signature.SignaturePage Enum Specifies the page on which the digital signature will be displayed. Valid values are: FirstPage, LastPage, CustomPage.
PdfSettings.Signature.SignatureCustomPage Int If the digital signature page is set to custom, this property defines the page where the signature will be displayed.
PdfSettings.Signature.LeftX Int Specifies the X-coordinate of the top left corner of the digital signature.
PdfSettings.Signature.LeftY Int Specifies the Y-coordinate of the top left corner of the digital signature.
PdfSettings.Signature.RightX Int Specifies the X-coordinate of the bottom right corner of the digital signature.
PdfSettings.Signature.RightY Int Specifies the Y-coordinate of the bottom right corner of the digital signature.
PdfSettings.Signature.TimeServerUrl String Specifies the URL of a time server that provides a signed timestamp.
PdfSettings.Signature.TimeServerIsSecured Bool If set to true, the time server requires authentication.
PdfSettings.Signature.TimeServerLoginName String Specifies the login name for the time server.
PdfSettings.Signature.TimeServerPassword String Specifies the password for the time server.
PngSettings - Specifies the settings for the PNG output format.
PngSettings.Color Enum Specifies the number of colors used for the PNG image. Valid values are: Color32BitTransp, Color24Bit, Color8Bit, Color4Bit, Gray8Bit, BlackWhite.
PngSettings.Dpi Int The resolution of the PNG files.
Printing - Allows to print the document to a physical printer.
Printing.Enabled Bool If enabled, the document will be printed to a physical printer.
Printing.PrinterName String The name of the printer that will be used, if SelectedPrinter is set.
Printing.SelectPrinter Enum The method used to select the printer. Valid values are: DefaultPrinter, ShowDialog, SelectedPrinter.
Printing.Duplex Enum Defines the duplex printing mode. Valid values are: Disable, LongEdge, ShortEdge.
Scripting - Allows to run a script after the conversion.
Scripting.Enabled Bool If true, the given script or application will be executed.
Scripting.ScriptFile String The path to the script or application.
Scripting.ParameterString String Additional parameters that will be passed to the script along with the output files.
Scripting.WaitForScript Bool If true, waits until the script execution has ended.
Scripting.HideProcess Bool If true, the process is hidden during execution.
Stamping - Allows to place a stamp text on all pages of the document.
Stamping.Enabled Bool If true, all pages of the document will be stamped with the specified text.
Stamping.StampText String The text that will be stamped.
Stamping.FontName String The name of the font. (Note: this is only used as a hint, the PostScriptFontName contains the actual name.)
Stamping.PostScriptFontName String The PostScript name of the stamp font.
Stamping.FontSize Float The size of the font.
Stamping.FontOutlineWidth Int The width of the outline.
Stamping.FontAsOutline Bool If true, the text will be rendered as an outline. If false, it will be filled.
Stamping.Color Color The color of the stamp text.
TiffSettings - Settings for the TIFF output format.
TiffSettings.Dpi Int The resolution of the TIFF files.
TiffSettings.Color Enum The number of colors. Valid values are: Color24Bit, Color12Bit, Gray8Bit, BlackWhite.
Clone this wiki locally