pdfcreator powershell

automate pdfcreator using powershell

Have you ever needed to automate the printing of PDF documents? Well, you can do that using PDFCreator and powershell.

Indeed, PDFCreator (version 2.3.2)  comes with an COM interface which you can use to automate almost everything with Powershell.

I summarized on this page the basics to get you started for your own pdfcreator and powershell automation needs.

If need to print webpages to pdf, I recommend you read my other article here.

With PDFCreator version 2.3.1, you can have access to a COM interface to for all the automation tasks. There are quite a few code samples in all the different languages you can dream of, but non of them are in Powershell. (This is why I took the initiative to write this blog post).

Read above to be sure you meet all the prerequisites needed for this to work.

The process is pretty simple, but when things are not documented, it make it a bit more difficult, but never impossible 😉

1 ) Create an instance of the PDFCreator.JobQueue

2 )   Initialize printer (this needs to be ‘after’ the page has been sent to the print by your application (in our case – Internet Explorer)

3) Wait for the print job to arrive to the printer

4) get a hold on the print job

5) Add specific print options (optional)

You can find a complete list of all the profileSettings that can be set or read at the end of this article

6) Save the PDF document

7) Release de COM object

And that’s it. Put all of that together, and you can automate the printing of anything to PDF using Powershell and COM.

PDFCreator Powershell Profile Settings

Setting Type Description
AuthorTemplate String Template for the Author field. This may contain tokens.
FileNameTemplate String Template of which the filename will be created. This may contain Tokens.
Guid String GUID of the profile
Name String Name of the profile
OpenViewer Bool Open the default viewer after converting the document
OpenWithPdfArchitect Bool If the output is a PDF, use PDF Architect instead of the default PDF viewer
OutputFormat Enum Default format for this print job. Valid values are: Pdf, PdfA1B, PdfA2B, PdfX, Jpeg, Png, Tif
ShowProgress Bool If true, a progress window will be shown during conversion
TitleTemplate String Template for the Title field. This may contain tokens.
AttachmentPage
Appends one or more pages at the end of the converted document
AttachmentPage.Enabled Bool Enables the AttachmentPage action
AttachmentPage.File String Filename of the PDF that will be appended
BackgroundPage
Adds a page background to the resulting document
BackgroundPage.Enabled Bool Enables the BackgroundPage action
BackgroundPage.File String Filename of the PDF that will be used as background
BackgroundPage.OnAttachment Bool If true, the background will be placed on the attachment as well
BackgroundPage.OnCover Bool If true, the background will be placed on the cover as well
BackgroundPage.Repetition Enum Defines the way the background document is repeated. Valid values are: NoRepetition, RepeatAllPages, RepeatLastPage
CoverPage
Inserts one or more pages at the beginning of the converted document
CoverPage.Enabled Bool Enables the CoverPage action
CoverPage.File String Filename of the PDF that will be inserted
EmailClient
Opens the default E-mail client with the converted document as attachment
EmailClient.AddSignature Bool Add the PDFCreator signature to the mail
EmailClient.Content String Body text of the E-mail
EmailClient.Enabled Bool Enables the EmailClient action
EmailClient.Recipients String The list of receipients of the E-mail, i.e. info@someone.com; me@mywebsite.org
EmailClient.Subject String Subject line of the E-mail
EmailSmtp
Sends a mail without user interaction through SMTP
EmailSmtp.AddSignature Bool Add the PDFCreator signature to the mail
EmailSmtp.Address String E-mail address that is displayed as sender
EmailSmtp.Content String Body text of the mail
EmailSmtp.Enabled Bool If true, this action will be executed
EmailSmtp.Password String Password that is used to authenticate at the server
EmailSmtp.Port Int SMTP server port
EmailSmtp.Recipients String The list of receipients of the E-mail, i.e. info@someone.com; me@mywebsite.org
EmailSmtp.SameTextAsClientMail Bool If true, the body of the EmailClient action will be used
EmailSmtp.Server String Hostname or IP address of the SMTP server
EmailSmtp.Ssl Bool If true, the connection will be encrypted with SSL (must be supported by the server)
EmailSmtp.Subject String Subject line of the E-mail
EmailSmtp.UserName String User name that is used to authenticate at the server
Ftp
Upload the converted documents with FTP
Ftp.Directory String Target directory on the server
Ftp.Enabled Bool If true, this action will be executed
Ftp.EnsureUniqueFilenames Bool If true, files with the same name will not be overwritten on the server. A counter will be appended instead (i.e. document_2.pdf)
Ftp.Password String Password that is used to authenticate at the server
Ftp.Server String Hostname or IP address of the FTP server
Ftp.UserName String User name that is used to authenticate at the server
Ghostscript
Ghostscript settings
Ghostscript.AdditionalGsParameters String These parameters will be provided to Ghostscript in addition to the PDFCreator parameters
JpegSettings
Settings for the JPEG output format
JpegSettings.Color Enum Number of colors. Valid values are: Color24Bit, Gray8Bit
JpegSettings.Dpi Int Resolution of the JPEG files
JpegSettings.Quality Int Quality factor of the resulting JPEG (100 is best, 0 is worst)
PdfSettings
Settings for the PDF output format
PdfSettings.ColorModel Enum Color model of the PDF (does not apply to images). Valid values are: Rgb, Cmyk, Gray
PdfSettings.DocumentView Enum Defines which controls will be opened in the reader. Valid values are: 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 still is loading.
PdfSettings.PageOrientation Enum Define how pages are automatically rotated. Valid values are: Automatic, Portrait, Landscape
PdfSettings.PageView Enum Defines how the document will be opened in the reader. Valid values are: OnePage, OneColumn, TwoColumnsOddLeft, TwoColumnsOddRight, TwoPagesOddLeft, TwoPagesOddRight
PdfSettings.ViewerStartsOnPage Int Defines the page number the viewer will start on when opening the document
CompressColorAndGray
Compression settings for color and greyscale images
PdfSettings.CompressColorAndGray.Compression Enum Settings for the compression method. Valid values are: Automatic, JpegMaximum, JpegHigh, JpegMedium, JpegLow, JpegMinimum, JpegManual, Zip
PdfSettings.CompressColorAndGray.Dpi Int Images will be resampled to this maximum resolution of the images, if resampling is enabled
PdfSettings.CompressColorAndGray.Enabled Bool If true, color and grayscale images will be processed according to the algorithm. If false, they will remain uncompressed
PdfSettings.CompressColorAndGray.JpegCompressionFactor Double Define a custom compression factor (requires JpegManual as method)
PdfSettings.CompressColorAndGray.Resampling Bool If true, the images will be resampled to a maximum resolution
CompressMonochrome
Compression settings for monochrome images
PdfSettings.CompressMonochrome.Compression Enum Settings for the compression method. Valid values are: CcittFaxEncoding, Zip, RunLengthEncoding
PdfSettings.CompressMonochrome.Dpi Int Images will be resampled to this maximum resolution of the images, if resampling is enabled
PdfSettings.CompressMonochrome.Enabled Bool If true, monochrome images will be processed according to the algorithm. If false, they will remain uncompressed
PdfSettings.CompressMonochrome.Resampling Bool If true, the images will be resampled to a maximum resolution
Security
PDF Security options
PdfSettings.Security.AllowPrinting Bool Allow to user to print the document
PdfSettings.Security.AllowScreenReader Bool Allow to user to use a screen reader
PdfSettings.Security.AllowToCopyContent Bool Allow to user to copy content from the PDF
PdfSettings.Security.AllowToEditAssembly Bool Allow to user to make changes to the assembly
PdfSettings.Security.AllowToEditComments Bool Allow to user to edit comments
PdfSettings.Security.AllowToEditTheDocument Bool Allow to user to edit the document
PdfSettings.Security.AllowToFillForms Bool Allow to user to fill in forms
PdfSettings.Security.Enabled Bool If true, the PDF file will be password protected
PdfSettings.Security.EncryptionLevel Enum Defines the encryption level. Valid values are: Rc40Bit, Rc128Bit, Aes128Bit
PdfSettings.Security.OwnerPassword String Password that can be used to modify the document
PdfSettings.Security.RequireUserPassword Bool If true, a password is required to open the document.
PdfSettings.Security.RestrictPrintingToLowQuality Bool If true, only printing in low resolution will be supported
PdfSettings.Security.UserPassword String Password that must be used to open the document (if set)
Signature
Digitally sign the PDF document
PdfSettings.Signature.AllowMultiSigning Bool If true, the PDF file may be signed by additional persons
PdfSettings.Signature.CertificateFile String Path to the certificate
PdfSettings.Signature.DisplaySignatureInDocument Bool If true, the signature will be displayed in the PDF file
PdfSettings.Signature.Enabled Bool If true, the signature will be displayed in the PDF document
PdfSettings.Signature.LeftX Int Signature location: Top left corner (X part)
PdfSettings.Signature.LeftY Int Signature location: Top left corner (Y part)
PdfSettings.Signature.RightX Int Signature location: Bottom right corner (X part)
PdfSettings.Signature.RightY Int Signature location: Bottom right corner (Y part)
PdfSettings.Signature.SignContact String Contact name of the signature
PdfSettings.Signature.SignLocation String Signature location
PdfSettings.Signature.SignReason String Reason for the signature
PdfSettings.Signature.SignatureCustomPage Int If the signature page is set to custom, this property defines the page where the signature will be displayed
PdfSettings.Signature.SignaturePage Enum Defines the page on which the signature will be displayed. Valid values are: FirstPage, LastPage, CustomPage
PdfSettings.Signature.SignaturePassword String Password for the certificate file
PdfSettings.Signature.TimeServerIsSecured Bool Set to true, if the time server needs authentication
PdfSettings.Signature.TimeServerLoginName String Login name for the time server
PdfSettings.Signature.TimeServerPassword String Password for the time server
PdfSettings.Signature.TimeServerUrl String URL of a time server that provides a signed timestamp
PngSettings
Settings for the PNG output format
PngSettings.Color Enum Number of colors. Valid values are: Color32BitTransp, Color24Bit, Color8Bit, Color4Bit, Gray8Bit, BlackWhite
PngSettings.Dpi Int Resolution of the PNG files
Printing
Print the document to a physical printer
Printing.Duplex Enum Defines the duplex printing mode. Valid values are: Disable, LongEdge, ShortEdge
Printing.Enabled Bool If enabled, the document will be printed to a physical printer
Printing.PrinterName String Name of the printer that will be used, if SelectedPrinter is set.
Printing.SelectPrinter Enum Method to select the printer. Valid values are: DefaultPrinter, ShowDialog, SelectedPrinter
Scripting
The scripting action allows to run a script after the conversion
Scripting.Enabled Bool If true, the given script or application will be executed
Scripting.ParameterString String Parameters that will be passed to the script in addition to the output files
Scripting.ScriptFile String Path to the script or application
Scripting.WaitForScript Bool Wait until the script excution has ended
Stamping
Place a stamp text on all pages of the document
Stamping.Color Color Color of the text
Stamping.Enabled Bool If true, the document all pages will be stamped with a text
Stamping.FontAsOutline Bool If true, the text will be rendered as outline. If false, it will be filled.
Stamping.FontName String Name of the font. (this is only used as a hint, the PostScriptFontName contains the real name)
Stamping.FontOutlineWidth Int Width of the outline
Stamping.FontSize Float Size of the font
Stamping.PostScriptFontName String PostScript name of the stamp font.
Stamping.StampText String Text that will be stamped
TiffSettings
Settings for the TIFF output format
TiffSettings.Color Enum Number of colors. Valid values are: Color24Bit, Color12Bit, Gray8Bit, BlackWhite
TiffSettings.Dpi Int Resolution of the TIFF files