PNSrv10 COM Interface5 PNSrv10 COM Interface Introduction Terminology Terminology Terminology...
Transcript of PNSrv10 COM Interface5 PNSrv10 COM Interface Introduction Terminology Terminology Terminology...
Copyright © 2008-2015
Updated: 4/9/2015
PNSrv10 COM Interface
Programmer's Reference
TIFF Image Printer 10.0PDF Image Printer 10.0Raster Image Printer 10.0
Supports the following PEERNET printers:
Version
PEERNET Inc.
1.0
i
PNSrv10 COM Interface
Table of Contents
................................................................................................. 1Introduction............................................................................................................... 2Legal Notices
............................................................................................................... 3Requirements and Prerequisites
............................................................................................................... 5Terminology
................................................................................................. 7Getting Started............................................................................................................... 9Referencing the PNSrv10 COM Interface
............................................................................................................... 12Migrating from PNSrv9Lib or earlier to PNSrv10Lib
............................................................................................................... 16Using the PNSrv10 COM Interface
............................................................................................................ 17Event-based (Asynchronous) Calling Sequence
............................................................................................................ 38Single-threaded (Synchronous) Calling Sequence
............................................................................................................... 57How Do I ?
............................................................................................................ 58How do I tell when my file is converted?
............................................................................................................ 62How do I customize the name of my output file?
................................................................................................. 66PNSrv10 COM Interface Object Reference............................................................................................................... 69PNSrv10 COM Interface Heirarchy Chart
............................................................................................................... 70Collections Objects Hierarchy
............................................................................................................... 72IPNSession
............................................................................................................ 79Initialization Methods
............................................................................................................ 86Job Tracking Methods
............................................................................................................ 91Property Methods
............................................................................................................ 235Properties
............................................................................................................ 238Events
............................................................................................................ 248Driver Preferences Method Map
............................................................................................................... 251IPNPrintSession
............................................................................................................ 253Methods
............................................................................................................ 280Properties
............................................................................................................... 284IPNJobs Collection
............................................................................................................ 285Methods
ii
PNSrv10 COM Interface
............................................................................................................ 287Properties
............................................................................................................... 288IPNJob
............................................................................................................ 290Methods
............................................................................................................ 294Properties
............................................................................................................ 313Job Properties Event Map
............................................................................................................... 317IPNFiles Collection
............................................................................................................ 318Methods
............................................................................................................ 320Properties
............................................................................................................... 321IPNFile
............................................................................................................ 322Properties
............................................................................................................... 327IPNPages Collection
............................................................................................................ 328Methods
............................................................................................................ 330Properties
............................................................................................................... 331IPNPage
............................................................................................................ 333Properties
............................................................................................................... 343IPNImages Collection
............................................................................................................ 344Methods
............................................................................................................ 347Properties
............................................................................................................... 349IPNImage
............................................................................................................ 350Properties
............................................................................................................... 360Enumerations
............................................................................................................ 360pnBWCompressionMethod
............................................................................................................ 361pnColorCompressionMethod
............................................................................................................ 363pnColorReduction
............................................................................................................ 364pnDitheringMethod
............................................................................................................ 365pnEmailDialog
............................................................................................................ 366pnEmailService
............................................................................................................ 367pnErrorMessageBoxStyle
............................................................................................................ 368pnFaxPageScaling
............................................................................................................ 369pnFaxPageScalingHAlign
............................................................................................................ 370pnFaxPageScalingVAlign
............................................................................................................ 371pnFaxPaperHeight
iii
PNSrv10 COM Interface
............................................................................................................ 372pnFaxPaperWidth
............................................................................................................ 373pnFaxProfile
............................................................................................................ 374pnFaxResolution
............................................................................................................ 375pnGrayscaleCompressionMethod
............................................................................................................ 376pnImageCopyScaling
............................................................................................................ 377pnImageCopyScalingHAlign
............................................................................................................ 378pnImageCopyScalingVAlign
............................................................................................................ 379pnIndexedCompressionMethod
............................................................................................................ 380pnJobVariable
............................................................................................................ 381pnMAPIEmailLogon
............................................................................................................ 382pnNamingProfile
............................................................................................................ 383pnOutputFileFormat
............................................................................................................ 384pnPDFContentEncodingMethod
............................................................................................................ 385pnPDFEncryption
............................................................................................................ 386pnPrinterColorMode
............................................................................................................ 387pnPrinterOrientation
............................................................................................................ 388pnPrinterResolution
............................................................................................................ 389pnResampleUnits
............................................................................................................ 390pnRotation
............................................................................................................ 391pnRunCommmandsWaitMode
............................................................................................................ 392pnRunCommmandWindowState
............................................................................................................ 393pnShellAndCommandWaitMode
............................................................................................................ 394pnTextEncoding
............................................................................................................ 395pnTextEOL
............................................................................................................ 396pnTextLayout
............................................................................................................ 397pnUnits
............................................................................................................ 398pnUserVariable
............................................................................................................ 399pnWatermarkPosition
1
PNSrv10 COM Interface
Introduction
Introduction
The PEERNET PNSrv10 COM Interface was designed to make it easier for you, the developer,to integrate PEERNET's printers into your own applications.
The PNSrv10 COM Interface provides the ability to control and communicate with theassociated printer during the printing and file creation process. It replaces and greatlyenhances the older script file methodology used in the previous versions of the printer.
All of the printer's printing preferences can be controlled through the PNSrv10 COMInterface, as well as being able to:
easily wait until the file has been created to continue your workflow
use a pool of printers to increase processing capacity
attach to events to add custom processing at key points
track the files printed and the output files associated with each file
retrieve detailed information about the output files created
PNSrv10 COM Interface
2 IntroductionLegal Notices
Legal Notices
Copyright © 2008-2015 by PEERNET Inc. All rights reserved.
PEERNET is a registered trademark of PEERNET Incorporated. Microsoft and Windows areregistered trademarks of Microsoft Corporation. All other trademarks and registeredtrademarks are the properties of their respective holders.
PEERNET Inc.18 Deakin Street Suite 208Ottawa, Ontario K2E 8B7
Information in this document is accurate up to the time of publication, but does notnecessarily reflect enhancements made to PEERNET Inc.’s products, which are releasedwithout notice. The software described in this document is furnished under a licenseagreement. It is against the law to copy the software onto any medium, or to use thesoftware for any purpose, except as specifically allowed in the license agreement. No part ofthis help system may be reproduced or transmitted in any form or by any means, electronicor mechanical, for any purpose other than the licensed operator’s personal use, without theexpress written permission of PEERNET Inc.
3
PNSrv10 COM Interface
IntroductionRequirements and Prerequisites
Requirements and Prerequisites
Required Files for Distribution
You do not need to include any additional files with your application but the end-user musthave the appropriate printer installed and licensed.
The PNSrv10 COM Interface object is distributed with the following PEERNET printers and isregistered as part of their printer installation. The PNSrv10 COM Interface object will notwork with earlier versions of PEERNET printers.
TIFF Image Printer 10.0 .000 or higher
PDF Image Printer 10.0.000 or higher
Raster Image Printer 10.0.000 or higher
The code examples shown in the following pages are written using the TIFF Image Printer10.0 but are also applicable to both Raster Image Printer 10.0 and PDF Image Printer 10.0unless otherwise stated in the Supported Printers section for each method or enumeration.
All code samples are provided in both VB.NET and C#.NET.
Supported Development Environments
Visual Basic 6.0
Visual Basic .NET 2002, 2003, 2005, 2008, 2010, 2012
Visual C# .NET 2002, 2003, 2005, 2008, 2010, 2012
Visual C++ 2002, 2003, 2005, 2008, 2010, 2012
VBA Script
Supported Operating Systems
The PNSrv10 COM Interface object was developed for and supports the following Microsoft®Windows operating systems:
Windows 8
Windows Server 2012
Windows 7
Windows Server 2008 R2
Windows Vista (up to SP2)
Windows Server 2008 (up to SP2)
Windows Vista (up to SP2)
Windows Server 2003 (up to SP2)
PNSrv10 COM Interface
4 IntroductionRequirements and Prerequisites
Windows XP (up to SP3)
Windows 2000 (up to SP4) Rollup#1
5
PNSrv10 COM Interface
IntroductionTerminology
Terminology
Terminology Conventions
This guide uses terminology common to Windows applications, as well as some termsspecific to the PNSrv10 COM Interface. The following terms are used throughout the guide:
asynchronousAn asynchronous operation executes in a thread separate from the main applicationthread. This leaves the main application window free to continue executing while thesecond thread performs its time-consuming task. Programming with events and eventhandlers is asynchronous. See also synchronous.
factory defaultsThe default settings used for the printer properties when the printer was installed.
integerA 32-bit signed value.
JobIDA JobID is a non-unique number associated with every print job submitted to a printqueue. It is initially set to zero and is automatically incremented by the printer at thestart of every print job submitted to that printer. Each printer has its own JobID counter.
job trackingWhen enabled, the Jobs collection in the IPNSession object is maintained with a newobject added for every job printed through any printer in the session's pool. Job trackingis enabled through the IPNSession TrackingOn property. The feature is off by default.
objectAn instance of any COM interface class, such as IPNSession, or IPNJob.
printerAn installed PEERNET printer, such as TIFF Image Printer 10.0.
printing applicationThe application being used to print a document, usually the same application used toopen the document.
print jobA print job is a file that has been sent to a printer to be printed. Most often there is asingle print job for each file (or document) printed, but occasionally printing a single file
PNSrv10 COM Interface
6 IntroductionTerminology
will create multiple print jobs in a print queue.
print queueEach printer has its own printer queue. A print queue shows which documents (or printjobs) are being printed or are waiting to be printed.
print spoolerThe print spooler is part of the Windows printing subsystem. It manages communicationbetween the printing application and the printers on your computer.
printer poolA group of printers that is created and used by the PNSrv10 COM Interface. A printerpool has a minimum of one printer, and can have as many printers in the pool asneeded.
printing applicationThe application being used to print a document to a printer in the PNSrv10 COMInterface 's printer pool.
session objectAn instance of the IPNSession COM interface object.
synchronousSynchronous programming occurs in the same thread in a linear manner. When makinga call that blocks until it returns. program execution is halted until the call returns.
7
PNSrv10 COM Interface
Getting Started
Getting Started
The following sections are designed to give you an overview of how the PNSrv10 COMInterface works and how to do some of the more common tasks. It provides a programmaticway to control the printing process and the resulting output file(s) for easy integration intoyour application.
In order to understand how the PNSrv10 COM Interface COM interface works, anunderstanding of PNSrv10 COM Interface printers and the Windows printing subsystem isneeded.
PEERNET Printers
PNSrv10 COM Interface printers work just like a hardware printer, except that they create afile on your computer instead of printing a paper copy of your document. Depending on theprinter being used, the file created can be a TIFF or JPEG image, or a PDF file, or one ofmany other image formats. Other settings in the printer control the individual options forcreating the different file types. For instance, with TIFF Image Printer, you can create colorTIFF images, or faxable black and white TIFF images, with PDF Image Printer you can createPDF files, and with the Raster Image Printer you can create JPEG images, PDF files, TIFFfiles and many other image formats.
Each printer has its own set of options particular to the type of output it creates. The UserGuide for each printer explains the different options available for that particular driver.Some options are available for all drivers while other options are specific to each driver. Forinstance, options to create faxable TIFF images can only be used with the TIFF Image Printerand Raster Image Printer, while the PDF security options are specific to PDF Image Printerand Raster Image Printer.
The code examples shown in the following pages are written using the TIFF Image Printer10.0 driver for the most part, but are also applicable to PDF Image Printer 10.0 and RasterImage Printer 10.0 unless otherwise stated in the Supported Printers section for that methodor enumeration.
Windows Printing
The main component of the Windows printing subsystem is the print spooler. It manages allcommunication between the printing application and the desired printer. Each printer has itsown print queue, and each time a document is printed, a print job, or a series of print jobs,is added to that printer's print queue. Most of the time there is only a single print job in thequeue for each document printed, but some applications will send more than one job.
PNSrv10 COM Interface
8 Getting Started
When a print job is submitted, it goes through several states. The first state is spooling,meaning the printing application is still sending the document to the printer. Once finishedspooling, it switches to spooled. At this point the print job is ready to be printed and willenter the printing state. If there is more than one job spooled in the print queue, a singleprint job may stay in the spooled state until the printer is finished with job currently beingprinted. When all pages are printed, the state of the print job is set to printed. After a printjob is printed, it is then deleted from the print queue by first entering the deleting state, andthen finally going to the deleted state. At this point, the print job is removed from printqueue and, if there are more than one job in the queue, the printer begins processing thenext job.
9
PNSrv10 COM Interface
Getting StartedReferencing the PNSrv10 COM Interface
Referencing the PNSrv10 COM Interface
The PNSrv10 COM Interface is installed and registered with the following PEERNET printers.
TIFF Image Printer 10.0 .000 or higher
PDF Image Printer 10.0.000 or higher
Raster Image Printer 10.0.000 or higher
Using PNSrv10Lib in Your Application
To add PNSrv10Lib as a COM reference in your application select PNSrv10 1.0 Type Libraryfrom the list of available COM objects.
If you are updating an older application that uses a previous version of the COM interfacesee Migrating from PNSrv9 COM Interface to PNSrv10 COM Interface for completeinstructions.
Late Binding with PNSrv10Lib
Late binding is used when you need to dynamically use a COM object independent of theversion installed on the target computer.
Class Late Binding Name
PNSession PNSrv10.PNSession
IPNPrintSession PNSrv10.PNPrintSession
IPNJobs PNSrv10.PNJobs
PNSrv10 COM Interface
10 Getting StartedReferencing the PNSrv10 COM Interface
IPNJob PNSrv10.PNJob
IPNFiles PNSrv10.PNFiles
IPNFile PNSrv10.PNFile
IPNPages PNSrv10.PNPages
IPNPage PNSrv10.PNPages
Visual Basic
Imports System.Runtime.InteropServicesImports System.Reflection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ProgID As Type Dim sessionObject As Object Dim printerName, portName As String
sessionObject = Nothing printerName = "TIFF Image Printer 10.0" portName = ""
Try ' Get the IPNSession Object type id ProgID = Type.GetTypeFromProgID("PNSrv10.PNSession")
' Create IPNSession object instance sessionObject = Activator.CreateInstance(ProgID)
Catch ex As Exception MessageBox.Show("Error getting PNSession object. [" + ex.ToString() + "]") Finally
If Not sessionObject Is Nothing Then Try System.Runtime.InteropServices.Marshal.FinalReleaseComObject(sessionObject) Catch ex As Exception
Finally sessionObject = Nothing End Try End If
End TryEnd Sub
C#
using System.Runtime.InteropServices;using System.Reflection;
Type ProgID;object sessionObject = null;string Printername = "TIFF Image Printer 10.0", portName = "";
try{ // Get the IPNSession Object type id ProgID = Type.GetTypeFromProgID("PNSrv10.PNSession");
// Create IPNSession object instance sessionObject = Activator.CreateInstance(ProgID);
11
PNSrv10 COM Interface
Getting StartedReferencing the PNSrv10 COM Interface
}catch (Exception ex){ MessageBox.Show("Error getting PNSession object. [" + ex.ToString() + "]");}finally{ // cleanup if (sessionObject != null) { try { InteropServices.Marshal.FinalReleaseComObject(sessionObject); } catch { } finally { sessionObject = null; } }}
PNSrv10 COM Interface
12 Getting StartedMigrating from PNSrv9Lib or earlier to PNSrv10Lib
Migrating from PNSrv9Lib or earlier to PNSrv10Lib
If you need to migrate existing applications that use PNSrv9 COM Interface or earlierversions to use PNSrv10 COM Interface and version 10.0 printers, the following steps outlinewhat you need to change in your code.
1. Updating the References in Your Application
The first step is to update the references in your application from PNSrv9 COM Interface toPNSrv10 COM Interface. If you are late-binding to the COM object using theSystem.Runtime.InteropServices and System.Reflection namespaces, you do not need to do thisstep.
1. Find and delete the PNSrv9Lib from the list of reference for your project.
2. Right click on the References node and select Add Reference...
3. From the Add Reference dialog, select PNSrv10 1.0 Type Library.
13
PNSrv10 COM Interface
Getting StartedMigrating from PNSrv9Lib or earlier to PNSrv10Lib
2. Update any using Statements
Any using statements (for C#) or Imports statements (for VB) referencing PNSrv9Lib or earliermust be updated to reference PNSrv10Lib.
Visual Basic
' Update to use the new version' Imports PNSrv9Lib Imports PNSrv10Lib
C#
// Update to use the new version// using PNSrv9Lib;using PNSrv10Lib;
3. Updating the Printer Name
Any calls to SetSessionPrinter also need to be updated to use the new printer name.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean
Dim Session As PNSession Dim bCompleted As Boolean
' initialize the printer and the number of printers in the printer pool Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, Nothing, False)
... End Function
C#
private void ConvertFile(String strFile){ PNSession session = new PNSession(); bool bCompleted = false ;
PNSrv10 COM Interface
14 Getting StartedMigrating from PNSrv9Lib or earlier to PNSrv10Lib
// initialize the printer and the number of printers in the printer pool session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false); ....
}
4. Updating and Replacing any Deprecated Methods from PNSrv8Lib
With the release of PNSrv9Lib and now PNSrv10Lib, several methods from PNSrv8Lib havebeen deprecated and replaced with newer methods. These newer methods were necessary toadd support for all of PEERNET's printer drivers into the PNSrv10 COM Interface.
The following table outlines the methods that have changed. If you are using any of thesemethods in your application, it is recommended that the be updated to use the newmethods. The older methods will still work but are not compatible with all printers. See thehelp documentation for each method to see which PEERNET printers it supports.
Deprecated IPNSession Methods
SetCompressionOptions
ClearCompressionOptions
[Deprecated - use SetJPEGCompressionOptions,SetPDFCompressionOptions, orSetTIFFCompressionOptions instead.]Set or clear color reduction, dithering andcompression methods for color. indexed,greyscale and monochrome images.
SetFileNamingOptions
ClearFileNamingOptions
[Deprecated - use SetSaveOptions andClearSaveOptions instead.]Set or clear serialized or multi-page output,append mode and set file location and base filenaming options.
SetPDFFileFormatOptions
ClearPDFFileFormatOptions
[Deprecated - use SetSaveOptions, ClearSaveOptions, SetPDFCompressionOptions,or ClearPDFCompressionOptions instead.]Set or clear PDF file format options includingcolor reduction, dithering and compressionmethods for color. indexed, greyscale andmonochrome images.
Updated IPNSession Methods
15
PNSrv10 COM Interface
Getting StartedMigrating from PNSrv9Lib or earlier to PNSrv10Lib
SetLandscapeWatermarkOptions
SetPortraitWatermarkOptions
SetPageBrightness
Watermark image and page brightness rangehas been changed. The brightness range is asfollows:
-100 to -1: darkens the image, with -100being black0 : no change1 to 100: lightens the image, with 100 beingwhite
PNSrv10 COM Interface
16 Getting StartedUsing the PNSrv10 COM Interface
Using the PNSrv10 COM Interface
The following steps demonstrate the general calling sequences to follow when using thePNSrv10 COM Interface. Which sequence you will need to use depends on your requirementsand the programming language you are using.
For example, if the programming language does not support adding event handlers you mayneed to use the single-threaded, or synchronous, calling sequence. For programminglanguages that do support event handlers, such as C#, VB.NET and C++, you can use theevent-based, or asynchronous calling sequence.
Event-based (Asynchronous) Calling Sequence
Single-threaded (Synchronous) Calling Sequence
17
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Event-based (Asynchronous) Calling Sequence
The steps below outline the basic calls needed to use the PNSrv10 COM Interface in anevent-based calling sequence. The sample code shown here has had any necessary errorchecking removed to make the code easier to read.
Step 1: Initialize an IPNSession object
Step 2: Adding IPNSession event handlers
Step 3: Setting IPNSession properties
Step 4: Get an IPNPrintSession object
Step 5: Printing the document
Step 6: Complete Code Sample
Click on any of the boxes in the diagram above to go to the appropriate step.
PNSrv10 COM Interface
18 Getting StartedUsing the PNSrv10 COM Interface
Step 1: Initialize an IPNSession object
The starting point of working with the PNSrv10COM Interface is the IPNSession interface.Once you have an instance of a IPNSessionobject, that object is then associated with oneof PEERNET's printers through a call to SetSessionPrinter. This establishes the printerthat will be used by this IPNSession object andthe number of available printer queues in theprinter pool for this session.
Each printer queue in the printer pool isrepresented as an IPNPrintSession object. Themore printers you have in your printer pool,the more documents you can potentiallyprocess in parallel, but keep in mind thatprinting can be resource intensive and there isalways a balance between number of printersand the resources available.
Below, we have created an instance of an IPNSession object, and used it to create a printerpool of 2 TIFF Image Printer 10.0 printers to be used exclusively by this session.
Once we have processed the file or files, we wait for the IPNSession object to tell us that ithas finished processing all of the jobs, then we can release the object. Releasing the objecttells the PNSrv10 COM Interface that we are done and that it can clean up the pool oftemporary printers.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean
Dim Session As PNSession Dim bCompleted As Boolean
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' initialize settings and process document here ...
' Wait for all the jobs to be complete and do cleanup here bCompleted = False While Not bCompleted bCompleted = Session.WaitForCompletion(120000) End While
'clean up - Release objects to allow the temporary printers to be deleted InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
C#
private void ConvertFile(String strFile){ bool bCompleted = false ;
19
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
// initialize the printer and the number of printers in the printer pool PNSession session = new PNSession(); session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// initialize printer settings and print document here ....
// Wait for all the jobs to be complete and do cleanup here bCompleted = false ; while (!bCompleted) { session.WaitForCompletion(120000) ); }
// Clean up and release objects to allow temporary printers to be deleted Marshal.FinalReleaseComObject(Session); session = null;}
PNSrv10 COM Interface
20 Getting StartedUsing the PNSrv10 COM Interface
Step 2: Adding IPNSession event handlers
The IPNSession object exposes events that allow you intercept and control the printing andconversion, and to apply custom actions at key points of the process. There are 10 events intotal, each one passes an PNSrv10 COM Interface object containing necessary informationabout the current printing and conversion state.
Event Object Passed
OnStartJob
OnEndJobIPNJob
OnOpenFile
OnCloseFileIPNFile
OnStartPage
OnEndPageIPNPage
OnStartImage
OnEndImageIPNImage
OnGetNextFileName IPNJob
OnReportError Error message as String
The most commonly used events are OnGetNextFileName, which is used to customize thefilename of the output file, and OnEndJob, which is fired when the output file has beencreated.
Below event handlers are added for the most commonly used events, OnGetNextFileNameand OnEndJob.
The OnGetNextFileName event is fired whenever the print driver needs a name to create anew file and allows customization of the output filename through the IPNJob object passed .In the case of multi-paged output, this event would be fired once for every print jobsubmitted in the print queue, and once for every page in print job if serialized output wasbeing created. In the sample code below we are using a global file counter to number eachfile created.
The OnEndJob event is fired when the output file is created and is ready to be viewed,copied, uploaded to an archive system, or whatever custom action you want to do with theoutput file. The IPNJob object passed in to the event handler contains the IPNFiles collectionof all files that were created. This information can be used to determine the output files anddo custom processing. In the code below, each file is passed to a function that uploads thenew files to an archive system.
The OnReportError event is fired when an error occurs in the printer driver; such as nothaving permissions to create the files is the output folder.
It is important to note that in the event handlers we are synchronizing access to any globalvariables we are using in order to safely share them between both event handlers and themultiple calls to the event handlers from the PNSrv10 COM Interface.
21
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Visual Basic
Public LockObject, UploadLock As ObjectPublic m_currentFileNumber As Integer
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim bCompleted As Boolean
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' add event handlers AddHandler Session.OnEndJob, AddressOf Session_OnEndJob AddHandler Session.OnGetNextFileName, AddressOf Session_OnGetNextFileName
'set settings and process document here ...
'clean up ' remove added event handlers RemoveHandler Session.OnEndJob, AddressOf Session_OnEndJob RemoveHandler Session.OnGetNextFileName, AddressOf Session_OnGetNextFileName
'Release objects InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
Private Sub Session_OnGetNextFileName(ByVal pJob As IPNJob)
Dim strCombinedBaseName As String
' synchronize access to the global page number counter SyncLock LockObject
' format the new output file base name strCombinedBaseName = "TestFile_" + _ String.Format("{0:000000}", m_currentFileNumber)
' sets the new output file name into the job pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, _ strCombinedBaseName)
' increment file counter m_currentFileNumber = m_currentFileNumber + 1 ' release job object pointer InteropServices.Marshal.FinalReleaseComObject(pJob) End SyncLock
End Sub
Private Sub Session_OnEndJob(ByVal pJob As IPNJob) ' synchronize access SyncLock UploadLock
' Loop through files collection for this job and upload all created ' files to the archive system Dim pFilesList as IPNFiles pFilesList = pJob.Files
For Each pnFile As IPNFile In pFilesList UploadToArchive(pnFile.Filename)
' release file object pointer InteropServices.Marshal.FinalReleaseComObject(pnFile)
Next
PNSrv10 COM Interface
22 Getting StartedUsing the PNSrv10 COM Interface
' release files list object pointer InteropServices.Marshal.FinalReleaseComObject(pFilesList)
' release job object pointer InteropServices.Marshal.FinalReleaseComObject(pJob) End SyncLock
End Sub
C#
private Object LockObject = new Object(); private Object UploadLock = new Object(); int m_currentFileNumber;
private void ConvertFile(String strFile){ bool bCompleted = false ; PNSession session = new PNSession(); session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// add event handlers session.OnEndJob += new _IPNSessionEvents_OnEndJobEventHandler(session_OnEndJob); session.OnGetNextFileName += new _IPNSessionEvents_OnGetNextFileNameEventHandler(session_OnGetNextFileName);
// initialize setting and process documents here .... // remove added event handlers session.OnEndJob += null; session.OnGetNextFileName += null;
//Release objects Marshal.FinalReleaseComObject(Session); Session = null;}
void session_OnGetNextFileName(IPNJob pJob){ string filename ;
lock (LockObject) { filename = "TestFile_" + String.Format("{0:000000}", m_currentFileNumber); m_currentFileNumber++; }
// sets the new output file name into the job pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, filename);
// release job object pointer Marshal.FinalReleaseComObject(pJob);}
void session_OnEndJob(IPNJob pJob){ lock (UploadLock) { // Loop through files collection for this job and upload all created // files to the archive system IPNFiles pFilesList = pJob.Files; foreach (IPNFile file in pFilesList) { UploadToArchive(file.Filename);
23
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
// release file object pointer Marshal.FinalReleaseComObject(file); } Marshal.FinalReleaseComObject(pFilesList); }
// release job object pointer Marshal.FinalReleaseComObject(pJob);}
PNSrv10 COM Interface
24 Getting StartedUsing the PNSrv10 COM Interface
Step 3: Setting IPNSession properties
The IPNSession object also establishes the print job settings used for each print job sent toone of the printers in the pool. These settings must be configured prior to calling either NewPrintSession or NewPrintSessionEx to get the IPNPrintSession object used to print thedocument. If no settings are set for the session object, the factory default settings for theprinter will be used.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim bCompleted As Boolean Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set the print job properties ' Reduce to black and white, dithering set to Halftone, use G4 compression ' set name and save location, create multipage tiff and append all into ' a single file. Don't use jobid, don't prompt, always overwrite Session.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, True, _ pnColorReductionBlackAndWhite, pnDitheringHalftone, _ False, False, True, True, True, False)
Session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
' print document here ... 'Release objects System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
C#
private void ConvertFile(String strFile){ bool bCompleted = false ; PNSession session = new PNSession(); session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// set the print job properties // Reduce to black and white, dithering set to Halftone, use G4 compression // set name and save location, create multipage tiff and append all into // a single file. Don't use jobid, don't prompt, always overwrite session.SetSaveOptions("C:\\TIFFOutput\\", "TIFFReport", pnOutputFileFormatTIFFMultipaged, true, pnColorReductionBlackAndWhite, pnDitheringHalftone, false, false, true, true, true, false);
session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
// Process document here .... //Release objects
25
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Marshal.FinalReleaseComObject(Session); Session = null;}
PNSrv10 COM Interface
26 Getting StartedUsing the PNSrv10 COM Interface
Step 4: Get an IPNPrintSession object
The IPNPrintSession object is used to print a single document. A new IPNPrintSession objectis needed for each document printed.
When NewPrintSessionEx (or NewPrintSession) is called on an IPNSession object to createan IPNPrintSession object, two things happen:
the current print job settings contained in the IPNSession object are copied to thenew IPNPrintSession object
a non-busy printer is obtained from the pool of available printers in the IPNSessionobject and associated with the new IPNPrintSession object.
Any printer in the printer pool being used by an IPNPrintSession object is marked as busy.NewPrintSessionEx (and NewPrintSession) will wait a user-specified timeout period for aprinter in the printer pool to be free, or non-busy. If the timeout period expires without aprinter being freed, no IPNPrintSession (NULL) is returned.
To minimize the amount of time that a printer in the pool is marked as busy, the IPNPrintSession object should not be retrieved until just before you are about to print thedocument and should be released back into the printer pool as soon as possible.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim documentPrintSession As IPNPrintSession Dim oWordApp As New Word.ApplicationClass Dim oDoc As New Word.DocumentClass Dim bCompleted As Boolean
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set the print job properties ...
' open document oDoc = oWordApp.Documents.Open(strFile, False, True, False)
' do any document formatting here
' Get a documentPrintSession object documentPrintSession = Nothing While documentPrintSession Is Nothing Try ' Get a new print session for this document with: ' ' int Timeout ' 5 second timeout for an available printSession to be returned ' int FirstJobTimeout ' 1 minute max timeout for a job to appear in the queue before ' releasing the printer back to the pool; applies only after ' the printSession has been released ' int AvailableTimeout ' 1/4 second timeout waiting between jobs entering the queue. ' If a new job is not seen in the print queue in the timeout ' period, the printer is released back into the printer pool. ' int OptionFlags ' reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0)
'Alternate call - not as customizable. ' Wait max 5 seconds for an available printer
27
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
' Wait max 2 seconds for another print job to appearin the queue ' documentPrintSession = Session.NewPrintSession(5000, 2000)
Catch ex As Exception MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")") Exit While End Try End While
If Not documentPrintSession Is Nothing Then
' print document here ...
' release print session Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
End If
' Wait for all the jobs to be complete and do cleanup here bCompleted = False While Not bCompleted bCompleted = Session.WaitForCompletion(120000) End While
' close document oDoc.Close(SaveChanges:=False)
' close application oWordApp.Quit(False)
'clean up
'Release Word automation objects InteropServices.Marshal.FinalReleaseComObject(oDoc) InteropServices.Marshal.FinalReleaseComObject(oWordApp)
'Release PNSrv10Lib objects InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
C#
private void ConvertFile(String strFile){ PNSession session = new PNSession(); IPNPrintSession documentPrintSession = null; WordApp._Application oWordApp = new WordApp.Application(); WordApp._Document oDoc = null; object myTrue = true, filename = strFile, optMissing = System.Type.Missing; bool bCompleted = false ;
session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// Set the print job properties ...
// open the document oDoc = oWordApp.Documents.Open(ref filename, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing,
PNSrv10 COM Interface
28 Getting StartedUsing the PNSrv10 COM Interface
ref optMissing);
// Now get the documentPrintSession documentPrintSession = null; while (documentPrintSession == null) { try { // Get a new print session for this document with: // // int Timeout // 5 second timeout for an available printSession to be returned // int FirstJobTimeout // 1 minute max timeout for a job to appear in the queue before // releasing the printer back to the pool; applies only after // the printSession has been released // int AvailableTimeout // 1/4 second timeout waiting between jobs entering the queue. // If a new job is not seen in the print queue in the timeout // period, the printer is released back into the printer pool. // int OptionFlags // reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0);
} catch (Exception ex) { MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")"); break; } }
if ( documentPrintSession != null ) {
// print document here ...
// release print session Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null; }
// Wait for all the jobs to be complete and do cleanup here bCompleted = false ; while (!bCompleted) { session.WaitForCompletion(120000) ); }
oDoc.Close(ref optMissing, ref optMissing, ref optMissing); oWordApp.Quit(ref optMissing, ref optMissing, ref optMissing);
// Release Word objects Marshal.FinalReleaseComObject(oDoc); Marshal.FinalReleaseComObject(oWordApp);
// Release objects Marshal.FinalReleaseComObject(Session); Session = null;}
29
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Step 5: Printing the document
The IPNPrintSession object is used to obtain the name of the printer to which we print thedocument, as well as providing a series of wait methods used to tell when the printing iscomplete and the process can move on to the next step.
There are four different methods that allow you to wait for the different stages of printing.
WaitForJobsSpooling - returns as soon as document starts to spool in the printerqueue.
WaitForJobsSpooled - returns as soon as the document is completely spooled in theprinter queue.
WaitForJobsPrinted - returns as soon as the document has been printed; this doesnot mean that the output file is completely created.
WaitForJobsCompleted - returns as soon as the output file is created and is ready tobe used.
In all cases, it is a good idea to call WaitForJobsSpooling to verify that the documentactually started printing. If the document is never printed, the print session needs to becanceled in order to allow the printer to be released back into the printer pool as soon aspossible.
The other methods may need to be called depending on the behaviour of the application youare printing the document with. For example, when automating Word with backgroundprinting turned on, as in the sample code below, once it has been verified that the documentstarted spooling, no other wait calls are needed as the Word automation object has aBackgroundPrintingStatus flag that can be queried. We need to know when it is safe to closethe file and the application as closing too early will cause the print jobs to be aborted.
The print session will wait infinitely for a print job to appear in the associated print queue.After the first print job has appeared,it will wait for a second user-specified timeout periodfor any new print jobs to be submitted to the printer queue. If no print jobs are submittedwithin the timeout period, and the IPNPrintSession has been released by the callingapplication, the printer will return to non-busy status and be released back into the printerpool.
If the print session is released but the file fails to print to the printer, the print session willbe held in a busy state for 2 minutes before being released back into the printer pool. Youcan control this timeout by calling NewPrintSessionEx instead of NewPrintSession to get theprint session object.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim documentPrintSession As IPNPrintSession Dim oWordApp As New Word.ApplicationClass Dim oDoc As New Word.DocumentClass Dim bCompleted, bDocSpooling As Boolean Dim maxSpoolingWait, currentSpoolingWait As Integer
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set the print job properties
PNSrv10 COM Interface
30 Getting StartedUsing the PNSrv10 COM Interface
...
' open the document and get an IPNPrintSession for it ...
If Not documentPrintSession Is Nothing Then
' Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe 'oWordApp.ActivePrinter = PrintSession.PrinterName With oWordApp.Dialogs(Word.WdWordDialog.wdDialogFilePrintSetup) .Printer = PrintSession.PrinterName .DoNotSetAsSysDefault = True .Execute() End With
' Print the document oDoc.PrintOut(Background:=True) ' print in the background
' Test that file made it to the printer. We are using a maximum wait time of ' 1 minute, looping every 10 seconds. ' This should be adjusted to reflect the size of your documents. bDocSpooling = False maxSpoolingWait = 60000 currentSpoolingWait = 0 While (Not bDocSpooling And currentSpoolingWait < maxSpoolingWait) bDocSpooling = documentPrintSession.WaitForJobsSpooling(10000) currentSpoolingWait = currentSpoolingWait + 10000 End While
' The document did not enter the print queue so we need to cancel this ' printSession to allow the printer to return to the printer pool. If Not bDocSpooling Then documentPrintSession.Cancel() End If
' release print session Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
' Make sure Word is done printing While (oWordApp.BackgroundPrintingStatus > 0) System.Threading.Thread.Sleep(250) End While End If
' Wait for all the jobs to be complete and do cleanup here ...
End Function
C#
private void ConvertFile(String strFile){ PNSession session = new PNSession(); IPNPrintSession documentPrintSession = null; WordApp._Application oWordApp = new WordApp.Application(); WordApp._Document oDoc = null; object myTrue = true, filename = strFile, optMissing = System.Type.Missing; bool bCompleted. bDocSpooling = false; int maxSpoolingWait = 0, currentSpoolingWait = 0;
session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// set the print job properties ...
31
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
// open the document and get an IPNPrintSession for it ...
if ( documentPrintSession != null ) {
// Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe object oWordbasic = oWordApp.WordBasic; object[] argValues = new object[] { documentPrintSession.PrinterName, 1 }; String[] argNames = new String[] { "Printer", "DoNotSetAsSysDefault" };
oWordbasic.GetType().InvokeMember("FilePrintSetup", System.Reflection.BindingFlags.InvokeMethod, null, oWordbasic, argValues, null, null, argNames);
// print in the background oDoc.PrintOut(ref myTrue, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// Test that file made it to the printer. We are using a maximum wait time of // 1 minute, looping every 10 seconds. // This should be adjusted to reflect the size of your documents maxSpoolingWait = 60000; currentSpoolingWait = 0; while (!bDocSpooling && currentSpoolingWait < maxSpoolingWait) { bDocSpooling = documentPrintSession.WaitForJobsSpooling(10000); currentSpoolingWait = currentSpoolingWait + 10000; }
// The document did not enter the print queue so we need to cancel this // printSession to allow the printer to return to the printer pool. if (!bDocSpooling) { documentPrintSession.Cancel(); }
// release print session Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null;
// Make sure Word is done printing while (oWordApp.BackgroundPrintingStatus > 0) { System.Threading.Thread.Sleep(250); }
}
// Wait for all the jobs to be complete and do cleanup here ...}
PNSrv10 COM Interface
32 Getting StartedUsing the PNSrv10 COM Interface
Step 6: Complete Code Sample
The complete code sample for the asynchronous calling sequence is listed here.
Visual Basic
Public LockObject, UploadLock As ObjectPublic m_currentFileNumber As Integer
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim documentPrintSession As IPNPrintSession Dim oWordApp As New Word.ApplicationClass Dim oDoc As New Word.DocumentClass Dim bCompleted, bDocSpooling As Boolean Dim maxSpoolingWait, currentSpoolingWait As Integer
' STEP 1: Initialize an IPNSession object Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' STEP 2: Add event handlers AddHandler Session.OnEndJob, AddressOf Session_OnEndJob AddHandler Session.OnGetNextFileName, AddressOf Session_OnGetNextFileName
' STEP 3: Set the print job properties for saving and compression ' Reduce to black and white, dithering set to Halftone ' Set name and save location, create multipage tiff and append all into ' a single file. Don't use jobid, don't prompt, always overwrite Session.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, True, _ pnColorReductionBlackAndWhite, pnDitheringHalftone, _ False, False, True, True, True, False)
' Use G4 compression for black and white Session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
' open document oDoc = oWordApp.Documents.Open(strFile, False, True, False)
' do any document formatting here
' STEP 4: Get an IPNPrintSession object for this document documentPrintSession = Nothing While documentPrintSession Is Nothing Try ' Get a new print session for this document with: ' ' int Timeout ' 5 second timeout for an available printSession to be returned ' int FirstJobTimeout ' 1 minute max timeout for a job to appear in the queue before ' releasing the printer back to the pool; applies only after ' the printSession has been released ' int AvailableTimeout ' 1/4 second timeout waiting between jobs entering the queue. ' If a new job is not seen in the print queue in the timeout ' period, the printer is released back into the printer pool. ' int OptionFlags ' reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0)
'Alternate call - not as customizable. ' Wait max 5 seconds for an available printer ' Wait max 2 seconds for another print job to appearin the queue ' documentPrintSession = Session.NewPrintSession(5000, 2000)
Catch ex As Exception
33
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")") Exit While End Try End While
' STEP 5: Print the document and check for successful print If Not documentPrintSession Is Nothing Then
' Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe 'oWordApp.ActivePrinter = PrintSession.PrinterName With oWordApp.Dialogs(Word.WdWordDialog.wdDialogFilePrintSetup) .Printer = PrintSession.PrinterName .DoNotSetAsSysDefault = True .Execute() End With
' Print the document oDoc.PrintOut(Background:=True) ' print in the background
' Test that file made it to the printer. We are using a maximum wait time of ' 1 minute, looping every 10 seconds. ' This should be adjusted to reflect the size of your documents. bDocSpooling = False maxSpoolingWait = 60000 currentSpoolingWait = 0 While (currentSpoolingWait < maxSpoolingWait) bDocSpooling = documentPrintSession.WaitForJobsSpooling(10000) currentSpoolingWait = currentSpoolingWait + 10000 End While
' The document did not enter the print queue so we need to cancel this ' printSession to allow the printer to return to the printer pool. If Not bDocSpooling Then documentPrintSession.Cancel() End If
' STEP 4: Release print session when you are finished with it Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
' Make sure Word is done printing While (oWordApp.BackgroundPrintingStatus > 0) System.Threading.Thread.Sleep(250) End While End If
' Wait for all the jobs to be complete and do cleanup here ' This is needed to ensure the event handlers get called before we clean up bCompleted = False While Not bCompleted bCompleted = Session.WaitForCompletion(120000) End While
' close document oDoc.Close(SaveChanges:=False)
' close application oWordApp.Quit(False)
'clean up
'Release Word automation objects System.Runtime.InteropServices.Marshal.FinalReleaseComObject(oDoc) System.Runtime.InteropServices.Marshal.FinalReleaseComObject(oWordApp)
'STEP 2: remove added event handlers RemoveHandler Session.OnEndJob, AddressOf Session_OnEndJob RemoveHandler Session.OnGetNextFileName, AddressOf Session_OnGetNextFileName
PNSrv10 COM Interface
34 Getting StartedUsing the PNSrv10 COM Interface
'STEP 1: Release IPNSession objects System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing System.GC.Collect()
End Function
' STEP 2: Event handler for getting a custom file name Private Sub Session_OnGetNextFileName(ByVal pJob As IPNJob)
Dim strCombinedBaseName As String
' synchronize access to the global page number counter SyncLock LockObject
' format the new output file base name strCombinedBaseName = "TestFile_" + _ String.Format("{0:000000}", m_currentFileNumber)
' sets the new output file name into the job pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, _ strCombinedBaseName)
' increment file counter m_currentFileNumber = m_currentFileNumber + 1 ' release job object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob)
End SyncLock
End Sub
'STEP 2: Event handler for custom action when the file is created Private Sub Session_OnEndJob(ByVal pJob As IPNJob)
' synchronize access SyncLock UploadLock
Dim pFilesList As IPNFiles
' Loop through files collection for this job and upload all created ' files to the archive system pFilesList = pJob.Files For Each pnFile As IPNFile In pFilesList
UploadToArchive(pnFile.Filename)
' release file object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pnFile)
Next
' release files list object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFilesList)
' release job object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob)
End SyncLock
End Sub
C#
private Object LockObject = new Object(); private Object UploadLock = new Object();
35
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
int m_currentFileNumber;
private void ConvertFile(String strFile){ PNSession session = null ; IPNPrintSession documentPrintSession = null; WordApp._Application oWordApp = new WordApp.Application(); WordApp._Document oDoc = null; object myTrue = true, filename = strFile, optMissing = System.Type.Missing; bool bCompleted. bDocSpooling = false; int maxSpoolingWait = 0, currentSpoolingWait = 0;
// STEP 1: Initialize an IPNSession object session = new PNSession(); session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// STEP 2: Add event handlers session.OnEndJob += new _IPNSessionEvents_OnEndJobEventHandler(session_OnEndJob); sssion.OnGetNextFileName += new _IPNSessionEvents_OnGetNextFileNameEventHandler(session_OnGetNextFileName);
// STEP 3: Set the print job properties for saving and compression // Reduce to black and white, dithering set to Halftone // Set name and save location, create multipage tiff and append all into // a single file. Don't use jobid, don't prompt, always overwrite session.SetSaveOptions("C:\\TIFFOutput\\", "TIFFReport", pnOutputFileFormatTIFFMultipaged, true, pnColorReductionBlackAndWhite, pnDitheringHalftone, false, false, true, true, true, false); // Use G4 compression for black and white session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
// open the document oDoc = oWordApp.Documents.Open(ref filename, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// do any document formatting using Word Automation here
// STEP 4: Get an IPNPrintSession object for this document documentPrintSession = null; while (documentPrintSession == null) { try { // Get a new print session for this document with: // // int Timeout // 5 second timeout for an available printSession to be returned // int FirstJobTimeout // 1 minute max timeout for a job to appear in the queue before // releasing the printer back to the pool; applies only after // the printSession has been released // int AvailableTimeout // 1/4 second timeout waiting between jobs entering the queue. // If a new job is not seen in the print queue in the timeout // period, the printer is released back into the printer pool. // int OptionFlags // reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0);
// Alternate call - not as customizable.
PNSrv10 COM Interface
36 Getting StartedUsing the PNSrv10 COM Interface
// Wait max 5 seconds for an available printer // Wait max 2 seconds for another print job to appearin the queue // documentPrintSession = Session.NewPrintSession(5000, 2000) } catch (Exception ex) { MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")"); break; } }
// STEP 5: Print the document and check for successful print if ( documentPrintSession != null ) {
// Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe object oWordbasic = oWordApp.WordBasic; object[] argValues = new object[] { documentPrintSession.PrinterName, 1 }; String[] argNames = new String[] { "Printer", "DoNotSetAsSysDefault" };
oWordbasic.GetType().InvokeMember("FilePrintSetup", System.Reflection.BindingFlags.InvokeMethod, null, oWordbasic, argValues, null, null, argNames);
// print in the background oDoc.PrintOut(ref myTrue, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// Test that file made it to the printer. We are using a maximum wait time of // 1 minute, looping every 10 seconds. // This should be adjusted to reflect the size of your documents maxSpoolingWait = 60000; currentSpoolingWait = 0; while (currentSpoolingWait < maxSpoolingWait) { bDocSpooling = documentPrintSession.WaitForJobsSpooling(10000); currentSpoolingWait = currentSpoolingWait + 10000; }
// The document did not enter the print queue so we need to cancel this // printSession to allow the printer to return to the printer pool. if (!bDocSpooling) { documentPrintSession.Cancel(); }
// STEP 4: Release print session when you are finished with it Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null;
// Make sure Word is done printing while (oWordApp.BackgroundPrintingStatus > 0) { System.Threading.Thread.Sleep(250); }
}
// Wait for all the jobs to be complete and do cleanup here bCompleted = false ; while (!bCompleted) { session.WaitForCompletion(120000) ); }
oDoc.Close(ref optMissing, ref optMissing, ref optMissing); oWordApp.Quit(ref optMissing, ref optMissing, ref optMissing);
37
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
// release Word automation objects Marshal.FinalReleaseComObject(oDoc); Marshal.FinalReleaseComObject(oWordApp);
// STEP 2: Remove added event handlers session.OnEndJob += null; session.OnGetNextFileName += null;
'STEP 1: Release IPNSession objects Marshal.FinalReleaseComObject(Session); Session = null;
}
// STEP 2: Event handler for getting a custom file name void session_OnGetNextFileName(IPNJob pJob){ string filename ;
lock (LockObject) { filename = "TestFile_" + String.Format("{0:000000}", m_currentFileNumber); m_currentFileNumber++; }
// sets the new output file name into the job pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, filename);
// release job object pointer Marshal.FinalReleaseComObject(pJob);}
// STEP 2: Event handler for custom action when the file is created void session_OnEndJob(IPNJob pJob){ lock (UploadLock) { // Loop through files collection for this job and upload all created // files to the archive system IPNFiles pFilesList = pJob.Files; foreach (IPNFile file in pFilesList) { UploadToArchive(file.Filename);
// release file object pointer Marshal.FinalReleaseComObject(file); } } // release files list object pointer Marshal.FinalReleaseComObject(pFilesList);
// release job object pointer Marshal.FinalReleaseComObject(pJob);}
PNSrv10 COM Interface
38 Getting StartedUsing the PNSrv10 COM Interface
Single-threaded (Synchronous) Calling Sequence
The steps below outline the basic calls needed to use the PNSrv10 COM Interface in ansingle-threaded calling sequence. The sample code shown here has had any necessary errorchecking removed to make the samples easier to read.
Step 1: Initialize an IPNSession object
Step 2: Setting IPNSession properties
Step 3: Get an IPNPrintSession object
Step 4: Printing the document
Step 5: Synchronize with the file creation
Step 6: Complete Code Sample
Click on any of the boxes in the diagram above to go to the appropriate step.
39
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Step 1: Initialize an IPNSession object
The starting point of working with the PNSrv10COM Interface is the IPNSession interface.Once you have an instance of a IPNSessionobject, that object is then associated with asingle PEERNET printer through a call to SetSessionPrinter to establish the printer andthe number of available printer queues in theprinter pool for this session.
Each printer queue in the printer pool isrepresented as an IPNPrintSession object. Themore printers you have in your printer pool,the more documents you can potentiallyprocess in parallel, but keep in mind thatprinting can be resource intensive and there isalways a balance between number of printersand the resources available.
In the case of single-threaded processing, having more than one printer in the pool is notalways to your advantage. If the printing process is tightly coupled to the output file havingto be created before moving on to the next file, there is only ever going to be one printer inuse at a time so only one printer would be needed in the printer pool.
To determine what files have been created, job tracking has to be enabled in the IPNSessionobject through the TrackingOn property. When job tracking is enabled a new IPNJob objectis added to the Jobs collection property each time a file is printed to one of the printers inthe printer pool for this session. The IPNJob object contains information about each printjob, such as the number of pages printed, and a list of files created. This collection can becleared using the Reset method.
Below, we have created an instance of an IPNSession object, use it to create a printer poolof containing one TIFF Image Printer 10.0 printer to be used exclusively by this session, andturned on job tracking. Also shown is how to create an instance of an IPNSession object witha printer pool of a single printer using pre-created local ports.
Once we have processed the file or files, we wait for the IPNSession object to tell us that ithas finished processing all of the jobs, then we can release the object. Releasing the objecttells the PNSrv10 COM Interface that we are done and that it can clean up the pool oftemporary printers. If you are not clearing the
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean
Dim Session As PNSession Dim bCompleted As Boolean
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, Nothing, False)
' initialize settings and process document here ...
' Wait for all the jobs to be complete and do cleanup here
PNSrv10 COM Interface
40 Getting StartedUsing the PNSrv10 COM Interface
bCompleted = False While Not bCompleted bCompleted = Session.WaitForCompletion(120000) End While
'clean up
'Release objects to allow the temporary printers to be deleted InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
C#
private void ConvertFile(String strFile){ PNSession session = new PNSession(); bool bCompleted = false ;
// initialize the printer and the number of printers in the printer pool session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// initialize settings and process document here ....
// Wait for all the jobs to be complete and do cleanup here bCompleted = false ; while (!bCompleted) { session.WaitForCompletion(120000) ); }
//Release objects Marshal.FinalReleaseComObject(Session); Session = null;}
41
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Step 2: Setting IPNSession properties
The IPNSession object also establishes the print job settings used for each print job sent toone of the printers in the pool. These settings must be configured prior to calling NewPrintSessionEx (or NewPrintSession) to get the IPNPrintSession object used to print thedocument. If no settings are set for the session object, the factory default settings for theprinter will be used.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim bCompleted As Boolean Session = New PNSession
Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set the print job properties ' Reduce to black and white, dithering set to Halftone, use G4 compression ' set name and save location, create multipage tiff and append all into ' a single file. Don't use jobid, don't prompt, always overwrite Session.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, True, _ pnColorReductionBlackAndWhite, pnDitheringHalftone, _ False, False, True, True, True, False)
Session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
' process document here ... End Function
C#
private void ConvertFile(String strFile){ bool bCompleted = false ; PNSession session = new PNSession();
session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// set the print job properties // Reduce to black and white, dithering set to Halftone, use G4 compression // set name and save location, create multipage tiff and append all into // a single file. Don't use jobid, don't prompt, always overwrite session.SetSaveOptions("C:\\TIFFOutput\\", "TIFFReport", pnOutputFileFormatTIFFMultipaged, true, pnColorReductionBlackAndWhite, pnDitheringHalftone, false, false, true, true, true, false);
session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
// Process document here ....
}
PNSrv10 COM Interface
42 Getting StartedUsing the PNSrv10 COM Interface
Step 3: Get an IPNPrintSession object
The IPNPrintSession object is used to print a single document. A new IPNPrintSession objectis needed for each document printed.
When NewPrintSession or NewPrintSessionEx is called on an IPNSession object to create anIPNPrintSession object, two things happen:
the current print job settings contained in the IPNSession object are copied to thenew IPNPrintSession object
a non-busy printer is obtained from the pool of available printers in the IPNSessionobject and associated with the new IPNPrintSession object.
Any printer in the printer pool being used by an IPNPrintSession object is marked as busy.Both NewPrintSessionEx and NewPrintSession will wait a user-specified timeout period for aprinter in the printer pool to be free, or non-busy. If the timeout period expires without aprinter being freed, no IPNPrintSession (NULL) is returned.
To minimize the amount of time that a printer in the pool is marked as busy, the IPNPrintSession object should not be retrieved until just before you are about to print thedocument and should be released back into the printer pool as soon as possible.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim documentPrintSession As IPNPrintSession Dim oWordApp As New Word.ApplicationClass Dim oDoc As New Word.DocumentClass Dim bCompleted As Boolean
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set the print job properties ...
' open document oDoc = oWordApp.Documents.Open(strFile, False, True, False)
' Get a documentPrintSession object documentPrintSession = Nothing While documentPrintSession Is Nothing Try ' Get a new print session for this document with: ' ' int Timeout ' 5 second timeout for an available printSession to be returned ' int FirstJobTimeout ' 1 minute max timeout for a job to appear in the queue before ' releasing the printer back to the pool; applies only after ' the printSession has been released ' int AvailableTimeout ' 1/4 second timeout waiting between jobs entering the queue. ' If a new job is not seen in the print queue in the timeout ' period, the printer is released back into the printer pool. ' int OptionFlags ' reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0)
'Alternate call - not as customizable. ' Wait max 5 seconds for an available printer ' Wait max 2 seconds for another print job to appearin the queue ' documentPrintSession = Session.NewPrintSession(5000, 2000)
43
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Catch ex As Exception MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")") Exit While End Try End While
If Not documentPrintSession Is Nothing Then
' print document here ...
' wait for output file to be created here ...
' release print session Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
End If
oDoc.Close(SaveChanges:=False) oWordApp.Quit(False)
Marshal.FinalReleaseComObject(oDoc) Marshal.FinalReleaseComObject(oWordApp)
' finish cleanup of objects here ...
End Function
C#
private void ConvertFile(String strFile){ PNSession session = new PNSession(); IPNPrintSession documentPrintSession = null; WordApp._Application oWordApp = new WordApp.Application(); WordApp._Document oDoc = null; object myTrue = true, filename = strFile, optMissing = System.Type.Missing; bool bCompleted = false ;
session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// set the print job properties ...
// open the document oDoc = oWordApp.Documents.Open(ref filename, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// Now get the documentPrintSession documentPrintSession = null; while (documentPrintSession == null) { try { // Get a new print session for this document with: // // int Timeout // 5 second timeout for an available printSession to be returned // int FirstJobTimeout
PNSrv10 COM Interface
44 Getting StartedUsing the PNSrv10 COM Interface
// 1 minute max timeout for a job to appear in the queue before // releasing the printer back to the pool; applies only after // the printSession has been released // int AvailableTimeout // 1/4 second timeout waiting between jobs entering the queue. // If a new job is not seen in the print queue in the timeout // period, the printer is released back into the printer pool. // int OptionFlags // reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0);
// Alternate call - not as customizable. // Wait max 5 seconds for an available printer // Wait max 2 seconds for another print job to appearin the queue // documentPrintSession = Session.NewPrintSession(5000, 2000) } catch (Exception ex) { MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")"); break; } }
if ( documentPrintSession != null ) {
// print document here ...
// wait for output file to be created here ...
// release print session Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null;
}
oDoc.Close(ref optMissing, ref optMissing, ref optMissing); oWordApp.Quit(ref optMissing, ref optMissing, ref optMissing);
//Release objects Marshal.FinalReleaseComObject(oDoc); Marshal.FinalReleaseComObject(oWordApp);
// Finish object cleanup ...}
45
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Step 4: Print the document
The IPNPrintSession object is used to obtain the name of the printer to which we print thedocument, as well as providing a series of wait methods used to tell when the printing iscomplete and the process can move on to the next step.
There are four different functions that allow you to wait for the different stages of printing.
WaitForJobsSpooling - returns as soon as document starts to spool in the printerqueue.
WaitForJobsSpooled - returns as soon as the document is completely spooled in theprinter queue.
WaitForJobsPrinted - returns as soon as the document has been printed; this doesnot mean that the output file is completely created.
WaitForJobsCompleted - returns as soon as the output file is created and is ready tobe used.
In all cases, it is a good idea to call WaitForJobsSpooling to verify that the documentactually started printing. If the document is never printed, the print session needs to becanceled in order to allow the printer to be released back into the printer pool as soon aspossible.
In a single-threaded calling sequence, you need to wait using WaitForJobsCompleted if youare doing something else with the output file, in order to know when it is safe to use the file.
Even if you do not have to wait for the output file to be completed, the other wait methodsare needed to determine when it is safe to close the file and the application.Which method isneeded will depend on the behaviour of the application you are using to print the document.
For example, when automating Word with background printing turned on, as in the samplecode below, once it has been verified that the document started spooling, no other wait callsare needed as the Word automation object has a BackgroundPrintingStatus flag that can bequeried. Once the background printing flag is cleared it is safe to close the file and theapplication. Closing too early will cause the print jobs to be aborted. In other applications,such as PowerPoint, you need to use the WaitForJobsSpooled method before it is safe toclose the file.
The print session will wait infinitely for a print job to appear in the associated print queue.After the first print job has appeared,it will wait for a second user-specified timeout periodfor any new print jobs to be submitted to the printer queue. If no print jobs are submittedwithin the timeout period, and the IPNPrintSession has been released by the callingapplication, the printer will return to non-busy status and be released back into the printerpool.
If the print session is released but the file fails to print to the printer, the print session willbe held in a busy state for 2 minutes before being released back into the printer pool. Youcan control this timeout by calling NewPrintSessionEx instead of NewPrintSession to get theprint session object.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession
PNSrv10 COM Interface
46 Getting StartedUsing the PNSrv10 COM Interface
Dim documentPrintSession As IPNPrintSession Dim oWordApp As New Word.ApplicationClass Dim oDoc As New Word.DocumentClass Dim bCompleted, bDocSpooling As Boolean Dim maxSpoolingWait, currentSpoolingWait As Integer
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set the print job properties ...
' open document and get an IPNPrintSession object ....
' Print the document to the IPNPrintSession printer If Not documentPrintSession Is Nothing Then ' Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe 'oWordApp.ActivePrinter = PrintSession.PrinterName With oWordApp.Dialogs(Word.WdWordDialog.wdDialogFilePrintSetup) .Printer = PrintSession.PrinterName .DoNotSetAsSysDefault = True .Execute() End With
oDoc.PrintOut(Background:=True) ' print in the background
' Test that file made it to the printer. We are using a maximum wait time of ' 1 minute, looping every 10 seconds. ' This should be adjusted to reflect the size of your documents. bDocSpooling = False maxSpoolingWait = 60000 currentSpoolingWait = 0 While (currentSpoolingWait < maxSpoolingWait) bDocSpooling = documentPrintSession.WaitForJobsSpooling(10000) currentSpoolingWait = currentSpoolingWait + 10000 End While
' The document did not enter the print queue so we need to cancel this ' printSession to allow the printer to return to the printer pool. If Not bDocSpooling Then documentPrintSession.Cancel() Else ' wait for output file to be created here ... End If
' release print session Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
' Make sure Word is done printing While (oWordApp.BackgroundPrintingStatus > 0) System.Threading.Thread.Sleep(250) End While End If
' Wait for all the jobs to be complete and do cleanup here ... End Function
C#
private void ConvertFile(String strFile){ PNSession session = new PNSession();
47
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
IPNPrintSession documentPrintSession = null; WordApp._Application oWordApp = new WordApp.Application(); WordApp._Document oDoc = null; object myTrue = true, filename = strFile, optMissing = System.Type.Missing; bool bCompleted. bDocSpooling = false; int maxSpoolingWait = 0, currentSpoolingWait = 0;
session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// set the print job properties ... // open the document and get an IPNPrintSession object ...
// Print the document to the IPNPrintSession printer if ( documentPrintSession != null ) {
// Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe object oWordbasic = oWordApp.WordBasic; object[] argValues = new object[] { documentPrintSession.PrinterName, 1 }; String[] argNames = new String[] { "Printer", "DoNotSetAsSysDefault" };
oWordbasic.GetType().InvokeMember("FilePrintSetup", System.Reflection.BindingFlags.InvokeMethod, null, oWordbasic, argValues, null, null, argNames);
// print in the background oDoc.PrintOut(ref myTrue, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// Test that file made it to the printer. We are using a maximum wait time of // 1 minute, looping every 10 seconds. // This should be adjusted to reflect the size of your documents maxSpoolingWait = 60000; currentSpoolingWait = 0; while (currentSpoolingWait < maxSpoolingWait) { bDocSpooling = documentPrintSession.WaitForJobsSpooling(10000); currentSpoolingWait = currentSpoolingWait + 10000; }
// The document did not enter the print queue so we need to cancel this // printSession to allow the printer to return to the printer pool. if (!bDocSpooling) { documentPrintSession.Cancel(); } else {
// wait for output file to be created ... }
// release print session Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null;
// Make sure Word is done printing while (oWordApp.BackgroundPrintingStatus > 0) { System.Threading.Thread.Sleep(250); }
PNSrv10 COM Interface
48 Getting StartedUsing the PNSrv10 COM Interface
}
// Wait for all the jobs to be complete and do cleanup here ...
}
49
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
Step 5: Synchronize with the file creation
If you need to process the file before moving on to the next, the WaitForJobsCompletedmethod is used to determine when the output file has been created and it is safe to use thefile. The wait function is passed a timeout value and returns when the the file is created, orthe timeout period elapsed, whichever is first. By combining a while loop and a smallertimeout period, you can loop waiting for the file to be created and still provide responsivefeedback.
When WaitForJobsCompleted returns successfully, the output file is created and is ready touse. By iterating through the Jobs collection and it's file collection, you can retrieve the pathto the file and perform any custom actions needed.
The sample below shows how to loop and wait for the file to be created, and how to iteratethe Jobs collection to find the output files.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim documentPrintSession As IPNPrintSession Dim oWordApp As New Word.ApplicationClass Dim oDoc As New Word.DocumentClass Dim bCompleted, bDocSpooling As Boolean Dim maxSpoolingWait, currentSpoolingWait As Integer Dim maxCompletedWait, currentCompletedWait As Integer
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set the print job properties ...
' open document and get an IPNPrintSession object ...
If Not documentPrintSession Is Nothing Then
' Print the document and test that it was printed ...
' The document did not enter the print queue so we need to cancel this ' printSession to allow the printer to return to the printer pool. If Not bDocSpooling Then documentPrintSession.Cancel() Else ' wait for output file to be created here
'maximum wait time of 10 minutes, looping every 20 seconds. ' This should be adjusted to reflect the size of your documents. bCompleted = False maxCompletedWait = 600000 currentCompletedWait = 0 While (Not bCompleted And currentCompletedWait < maxCompletedWait) bCompleted = documentPrintSession.WaitForJobsCompleted(20000) currentCompletedWait = currentCompletedWait + 20000 End While
If Not bCompleted Then documentPrintSession.Cancel() Else
' Loop through jobs collection and upload new files Dim pJobList As IPNJobs pJobList = Session.Jobs
PNSrv10 COM Interface
50 Getting StartedUsing the PNSrv10 COM Interface
For Each pnJob As IPNJob In pJobList Dim pFileList as IPNFiles pFileList = pnJob.Files For Each pnFile As IPNFile In pFileList UploadToArchive(pnFile.Filename) Marshal.FinalReleaseComObject(pnFile) Next Marshal.FinalReleaseComObject(pFileList) Marshal.FinalReleaseComObject(pnJob) Next Marshal.FinalReleaseComObject(pJobList) End If End If
' release print session Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
' Make sure Word is done printing While (oWordApp.BackgroundPrintingStatus > 0) System.Threading.Thread.Sleep(250) End While End If
' Wait for all the jobs to be complete and do cleanup here ...
End Function
C#
private void ConvertFile(String strFile){ PNSession session = new PNSession(); IPNPrintSession documentPrintSession = null; WordApp._Application oWordApp = new WordApp.Application(); WordApp._Document oDoc = null; object myTrue = true, filename = strFile, optMissing = System.Type.Missing; bool bCompleted. bDocSpooling = false; int maxSpoolingWait = 0, currentSpoolingWait = 0; int maxCompleted = 0, currentCompletedWait = 0;
session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// set the print job properties ...
// open document and get an IPNPrintSession object ...
if ( documentPrintSession != null ) { // Print the document and test that it was printed ... // The document did not enter the print queue so we need to cancel this // printSession to allow the printer to return to the printer pool. if (!bDocSpooling) { documentPrintSession.Cancel(); } else {
// wait for output file to be created here // maximum wait time of 10 minutes, looping every 20 seconds. // This should be adjusted to reflect the size of your documents.
51
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
bCompleted = false; maxCompletedWait = 600000; currentCompletedWait = 0; while (!bCompleted && (currentCompletedWait < maxCompletedWait) ) { bCompleted = documentPrintSession.WaitForJobsSpooling(20000); currentCompletedWait = currentCompletedWait + 20000; }
if (!bCompleted) { documentPrintSession.Cancel(); } else { // Loop through files collection for this job and // upload all created files to the archive system IPNJobs pJobList = Session.Jobs; foreach (IPNJob pJob in pJobList) { IPNFiles pFileList = pJob.Files; foreach (IPNFile pFile in pFileList) { UploadToArchive(pFile.Filename); Marshal.FinalReleaseComObject(pFile); } Marshal.FinalReleaseComObject(pFileList); Marshal.FinalReleaseComObject(pJob); } Marshal.FinalReleaseComObject(pJobList); } }
// release print session Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null;
// Make sure Word is done printing while (oWordApp.BackgroundPrintingStatus > 0) { System.Threading.Thread.Sleep(250); } }
// Wait for all the jobs to be complete and do cleanup here ...}
PNSrv10 COM Interface
52 Getting StartedUsing the PNSrv10 COM Interface
Step 6: Complete Code Sample
The complete code sample for the single-threaded (synchronous) calling sequence is listedhere.
Visual Basic
Private Function ConvertFile(ByVal strFile As String) As Boolean Dim Session As PNSession Dim documentPrintSession As IPNPrintSession Dim oWordApp As New Word.ApplicationClass Dim oDoc As New Word.DocumentClass Dim bCompleted, bDocSpooling As Boolean Dim maxSpoolingWait, currentSpoolingWait As Integer Dim maxCompletedWait, currentCompletedWait As Integer
' STEP 1: Initialize an IPNSession object Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' STEP 2: Set the print job properties ' Reduce to black and white, dithering set to Halftone, ' set name and save location, create multipage tiff and append all into ' a single file. Don't use jobid, don't prompt, always overwrite Session.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, True, _ pnColorReductionBlackAndWhite, pnDitheringHalftone, _ False, False, True, True, True, False) ' use G4 compression Session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
' open document oDoc = oWordApp.Documents.Open(strFile, False, True, False)
' STEP 3: Get an IPNPrintSession object for this document documentPrintSession = Nothing While documentPrintSession Is Nothing Try ' Get a new print session for this document with: ' ' int Timeout ' 5 second timeout for an available printSession to be returned ' int FirstJobTimeout ' 1 minute max timeout for a job to appear in the queue before ' releasing the printer back to the pool; applies only after ' the printSession has been released ' int AvailableTimeout ' 1/4 second timeout waiting between jobs entering the queue. ' If a new job is not seen in the print queue in the timeout ' period, the printer is released back into the printer pool. ' int OptionFlags ' reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0)
'Alternate call - not as customizable. ' Wait max 5 seconds for an available printer ' Wait max 2 seconds for another print job to appearin the queue ' documentPrintSession = Session.NewPrintSession(5000, 2000)
Catch ex As Exception MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")") Exit While End Try End While
' STEP 4: Print the document to the IPNPrintSession printer If Not documentPrintSession Is Nothing Then
53
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
' Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe 'oWordApp.ActivePrinter = PrintSession.PrinterName With oWordApp.Dialogs(Word.WdWordDialog.wdDialogFilePrintSetup) .Printer = PrintSession.PrinterName .DoNotSetAsSysDefault = True .Execute() End With
oDoc.PrintOut(Background:=True) ' print in the background
' STEP 5: Synchronize with file creation; wait until file is created. ' Test that file made it to the printer. We are using a maximum wait time of ' 1 minute, looping every 10 seconds. ' This should be adjusted to reflect the size of your documents. bDocSpooling = False maxSpoolingWait = 60000 currentSpoolingWait = 0 While (currentSpoolingWait < maxSpoolingWait) bCompleted = documentPrintSession.WaitForJobsSpooling(10000) currentSpoolingWait = currentSpoolingWait + 10000 End While
' The document did not enter the print queue so we need to cancel this ' printSession to allow the printer to return to the printer pool. If Not bDocSpooling Then documentPrintSession.Cancel() Else ' wait for output file to be created here 'maximum wait time of 10 minutes, looping every 20 seconds. ' This should be adjusted to reflect the size of your documents. bCompleted = False maxCompletedWait = 600000 currentCompletedWait = 0 While (currentCompletedWait < maxCompletedWait) bCompleted = documentPrintSession.WaitForJobsCompleted(20000) currentCompletedWait = currentCompletedWait + 20000 End While
If Not bCompleted Then documentPrintSession.Cancel() Else ' Loop through jobs collection and upload new files Dim pJobList As IPNJobs pJobList = Session.Jobs For Each pnJob As IPNJob In pJobList Dim pFileList as IPNFiles pFileList = pnJob.Files For Each pnFile As IPNFile In pFileList UploadToArchive(pnFile.Filename) Marshal.FinalReleaseComObject(pnFile) Next Marshal.FinalReleaseComObject(pFileList) Marshal.FinalReleaseComObject(pnJob) Next Marshal.FinalReleaseComObject(pJobList) End If End If
'STEP 3: Release IPNPrintSession object Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
' Make sure Word is done printing While (oWordApp.BackgroundPrintingStatus > 0) System.Threading.Thread.Sleep(250) End While End If
' Wait for all the jobs to be complete and do cleanup here
PNSrv10 COM Interface
54 Getting StartedUsing the PNSrv10 COM Interface
bCompleted = False While Not bCompleted bCompleted = Session.WaitForCompletion(120000) End While
' close document oDoc.Close(SaveChanges:=False) oWordApp.Quit(False)
' Clean up word automation System.Runtime.InteropServices.Marshal.FinalReleaseComObject(oDoc) System.Runtime.InteropServices.Marshal.FinalReleaseComObject(oWordApp)
' STEP 1: Release IPNSession object System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
C#
private void ConvertFile(String strFile){ PNSession session = null; IPNPrintSession documentPrintSession = null; WordApp._Application oWordApp = new WordApp.Application(); WordApp._Document oDoc = null; object myTrue = true, filename = strFile, optMissing = System.Type.Missing; bool bCompleted. bDocSpooling = false; int maxSpoolingWait = 0, currentSpoolingWait = 0; int maxCompleted = 0, currentCompletedWait = 0;
// STEP 1: Initialize an IPNSession object session = new PNSession(); session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// STEP 2: Set the print job properties // Reduce to black and white, dithering set to Halftone, // set name and save location, create multipage tiff and append all into // a single file. Don't use jobid, don't prompt, always overwrite session.SetSaveOptions("C:\\TIFFOutput\\", "TIFFReport", pnOutputFileFormatTIFFMultipaged, true, pnColorReductionBlackAndWhite, pnDitheringHalftone, false, false, true, true, true, false); // Use G4 compression for black and white images session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
// open the document oDoc = oWordApp.Documents.Open(ref filename, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// STEP 3: Get an IPNPrintSession object for this document documentPrintSession = null; while (documentPrintSession == null) { try { // Get a new print session for this document with: // // int Timeout
55
PNSrv10 COM Interface
Getting StartedUsing the PNSrv10 COM Interface
// 5 second timeout for an available printSession to be returned // int FirstJobTimeout // 1 minute max timeout for a job to appear in the queue before // releasing the printer back to the pool; applies only after // the printSession has been released // int AvailableTimeout // 1/4 second timeout waiting between jobs entering the queue. // If a new job is not seen in the print queue in the timeout // period, the printer is released back into the printer pool. // int OptionFlags // reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0);
// Alternate call - not as customizable. // Wait max 5 seconds for an available printer // Wait max 2 seconds for another print job to appearing the queue // documentPrintSession = Session.NewPrintSession(5000, 2000) } catch (Exception ex) { MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")"); break; } }
// STEP 4: Print the document to the IPNPrintSession printer if ( documentPrintSession != null ) { // Set active printer with FilePrintSetup, .ActivePrinter is not thread-safe object oWordbasic = oWordApp.WordBasic; object[] argValues = new object[] { documentPrintSession.PrinterName, 1 }; String[] argNames = new String[] { "Printer", "DoNotSetAsSysDefault" };
oWordbasic.GetType().InvokeMember("FilePrintSetup", System.Reflection.BindingFlags.InvokeMethod, null, oWordbasic, argValues, null, null, argNames);
// print in the background oDoc.PrintOut(ref myTrue, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// STEP 5: Synchronize with file creation // Test that file made it to the printer. We are using a maximum wait time of // 1 minute, looping every 10 seconds. // This should be adjusted to reflect the size of your documents maxSpoolingWait = 60000; currentSpoolingWait = 0; while (currentSpoolingWait < maxSpoolingWait) { bDocSpooling = documentPrintSession.WaitForJobsSpooling(10000); currentSpoolingWait = currentSpoolingWait + 10000; }
// The document did not enter the print queue so we need to cancel this // printSession to allow the printer to return to the printer pool. if (!bDocSpooling) { documentPrintSession.Cancel(); } else {
// wait for output file to be created here // maximum wait time of 10 minutes, looping every 20 seconds. // This should be adjusted to reflect the size of your documents. bCompleted = false; maxCompletedWait = 600000; currentCompletedWait = 0; while (currentCompletedWait < maxCompletedWait)
PNSrv10 COM Interface
56 Getting StartedUsing the PNSrv10 COM Interface
{ bCompleted = documentPrintSession.WaitForJobsSpooling(20000); currentCompletedWait = currentCompletedWait + 20000; }
if (!bCompleted) { documentPrintSession.Cancel(); } else { // Loop through files collection for this job and // upload all created files to the archive system IPNJobs pJobList = Session.Jobs; foreach (IPNJob pJob in pJobList) { IPNFiles pFileList = pJob.Files; foreach (IPNFile pFile in pFileList) { UploadToArchive(pFile.Filename); Marshal.FinalReleaseComObject(pFile); } Marshal.FinalReleaseComObject(pFileList); Marshal.FinalReleaseComObject(pJob); } Marshal.FinalReleaseComObject(pJobList); } }
// STEP 3: Release print session Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null;
// Make sure Word is done printing while (oWordApp.BackgroundPrintingStatus > 0) { System.Threading.Thread.Sleep(250); } }
// Wait for all the jobs to be complete and do cleanup here bCompleted = false ; while (!bCompleted) { bCompleted = session.WaitForCompletion(120000) ); }
oDoc.Close(ref optMissing, ref optMissing, ref optMissing); oWordApp.Quit(ref optMissing, ref optMissing, ref optMissing);
// Clean up word automation objects Marshal.FinalReleaseComObject(oDoc); Marshal.FinalReleaseComObject(oWordApp);
// STEP 1: Release IPNSession object Marshal.FinalReleaseComObject(Session); Session = null;}
57
PNSrv10 COM Interface
Getting StartedHow Do I ?
How Do I ?
The following sections are designed to give you an overview of how the PNSrv10 COMInterface works and how to do some of the more common tasks.
How do I tell when my file is converted?
How do I customize the name of my output file?
PNSrv10 COM Interface
58 Getting StartedHow Do I ?
How do I tell when my file is converted?
With the PNSrv10 COM Interface it is easy to determine when the output file has beencreated, or "done". In many cases, this information is needed in order to know when tocontinue processing the file, such as uploading it to a website or into a document archivingsystem. There are two different methodologies that can be used to accomplish this.
Using the PNSrv10 COM Interface OnEndJob event
The best way is to attach an event handler to the OnEndJob event to catch when the fileis complete. The OnEndJob event handler is passed an IPNJob interface from which youcan extract information about the job, such as the name if the file, or files, created. Thisallows you to get the exact name of the file created, even when serialized or othercustom file naming properties have been set.
Visual Basic
Public WithEvents Session As New PNSession
' event handler To upload filesPrivate Sub Session_OnEndJob(ByVal pJob As IPNJob) Handles Session.OnEndJob Dim w32Error As New Win32Exception(pJob.ConversionStatus)
If w32Error.NativeErrorCode = 0 Then
Dim pFilesList As IPNFiles pFilesList = pJob.Files foreach (IPNFile pFile In pFilesList) { SendFileToArchive(pFile.Filename); System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFile) } System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFilesList)
End IfEnd Sub
Private Function ConvertFile(ByVal strFile As String) As Boolean
Dim bCompleted As Boolean Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, Nothing, False)
' add event handlers AddHandler Session.OnEndJob, AddressOf Session_OnEndJob
' Get a documentPrintSession object documentPrintSession = Nothing While documentPrintSession Is Nothing Try ' Get a new print session for this document with: documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) Catch ex As Exception MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")") Exit While End Try End While
If Not documentPrintSession Is Nothing Then ' print the document to the printer ' using the printer name in documentPrintSession ...
End If
' Wait for the job to be spooled
59
PNSrv10 COM Interface
Getting StartedHow Do I ?
' Waiting max 1 minute bResult = documentPrintSession.WaitForJobsSpooled(60000)
' Don't need processing code here, the event handler code ' will upload files when they have been completed If bResult == False Then ' event handler will check job status MessageBox.Show("Failed to print (timeout): " + strFile ) End If ' Wait for all the jobs to be complete and do cleanup here ' This is needed to ensure the event handlers get called before we clean up bCompleted = False While Not bCompleted bCompleted = Session.WaitForCompletion(120000) End While
'clean up
' remove added event handlers RemoveHandler Session.OnEndJob, AddressOf Session_OnEndJob
'Release objects System.Runtime.InteropServices.Marshal.FinalReleaseComObject(documentPrintSession) System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
C#
PNSession printSession = null;IPNPrintSession documentPrintSession = null;
// event handler to upload filesvoid session_OnEndJob(IPNJob pJob){ // Loop through files collection for this job and upload all created // files to the archive system IPNFiles pFilesList = pJob.Files; foreach (IPNFile file in pFilesList) { UploadToArchive(file.Filename);
// release file object pointer Marshal.FinalReleaseComObject(file); } // release files list object pointer Marshal.FinalReleaseComObject(pFilesList);
// release job object pointer Marshal.FinalReleaseComObject(pJob);}
private void ConvertFile(String strFile){ // initialize the printer and the number of printers in the printer pool PNSession session = new PNSession(); session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// add event handlers session.OnEndJob += new _IPNSessionEvents_OnEndJobEventHandler(session_OnEndJob);
// Now get the documentPrintSession IPNPrintSession documentPrintSession = null; while (documentPrintSession == null) { try
PNSrv10 COM Interface
60 Getting StartedHow Do I ?
{ documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } catch (Exception ex) { MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")"); break; } }
if ( documentPrintSession != null ) { // print the document to the printer // using the printer name in documentPrintSession ...
}
// Wait for the job to be spooled // Waiting max 1 minutes bResult = documentPrintSession.WaitForJobsSpooled(60000);
// Don't need processing code here, the event handler code will upload files // when they have been completed based on the job status if ( bResult == False ) { MessageBox.Show("Failed to print (timeout): " + strFile ) ; }
// Wait for all the jobs to be complete and do cleanup here Boolean bCompleted = false ; while (!bCompleted) { session.WaitForCompletion(120000) ); }
// Clean up and release objects to allow temporary printers to be deleted
// remove added event handlers session.OnEndJob += null; Marshal.FinalReleaseComObject(documentPrintSession); Marshal.FinalReleaseComObject(Session); session = null;
}
Using the WaitForJobsCompleted method
The other way is to use the WaitForJobsCompleted method after printing the file. Thismethod does not return until the file has been created, or until a specified timeout periodhas expired. If the timeout period has not expired then the printer has created the fileand it is available for further processing. This methodology works when the exactfilename created is not needed, such as when creating all output files in a specific folder,and then uploading the entire folder contents to an archive system.
Visual Basic
oDoc.PrintOut(True) ' print in the background
' wait for Word to finish printing While oWordApp.BackgroundPrintingStatus <> 0 System.Threading.Thread.Sleep(500)End While
61
PNSrv10 COM Interface
Getting StartedHow Do I ?
' Wait for the job to be completed ' Waiting max 2 minutesbResult = documentPrintSession.WaitForJobsCompleted(120000)
If bResult = True Then ' do further processing here with user function SendFolderToArchive( "C:\Archive\UploadTIFFs\")Else MessageBox.Show("Failed to print (timeout): " + filename ) ;End If
C#
// print in the backgroundoDoc.PrintOut(ref myTrue, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing,ref optMissing,ref optMissing, ref optMissing,ref optMissing, ref optMissing,ref optMissing, ref optMissing,ref optMissing,ref optMissing, ref optMissing, ref optMissing,ref optMissing) ;
// Make sure all of the documents are gone from the queuewhile(oWordApp.BackgroundPrintingStatus > 0){ System.Threading.Thread.Sleep(500);}
// Wait for the job to be completed // Waiting max 2 minutesbResult = documentPrintSession.WaitForJobsCompleted(120000);
if ( bResult == True ){ // do further processing here with user function ( "C:\\Archive\\UploadTIFFs\\");}else{ MessageBox.Show("Failed to print (timeout): " + filename ) ;}
PNSrv10 COM Interface
62 Getting StartedHow Do I ?
How do I customize the name of my output file?
Providing custom file naming for your output files is simple with the PNSrv10 COM Interface.The main object IPNSession has an event OnGetNextFileName for just this purpose.
The OnGetNextFileName event is fired each time a printer needs to create a new file on disk.For example, when creating a single, multi-paged file from a single print job, the event willbe fired exactly once, but when creating a serialized output files where one output file iscreated for each page in a single print job, the event will be fired once for each page.
Visual Basic
Public WithEvents Session As New PNSessionPublic m_currentFileNumber As IntegerPublic lockObject As Object
Private Sub Session_OnGetNextFileName(ByVal pJob As IPNJob) _ Handles Session.OnGetNextFileName Dim baseName, strNewName As String Try ' get the pre-set base name, this is the second argument passed ' to the SetSaveOptions method below, 'Doc_CaseFile1234' baseName = pJob.GetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName)
' synchronize access to the global page number counter SyncLock LockObject ' Set the new output file name base name strNewName = baseName + "_" + _ String.Format("{0:000000}", m_currentFileNumber)
pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, strNewName)
' increment global file number counter m_currentFileNumber = m_currentFileNumber + 1
End SyncLock
Finally InteropServices.Marshal.FinalReleaseComObject(pJob) End Try
End Sub
Private Function ConvertFile(ByVal strFile As String) As Boolean
Dim bCompleted As Boolean Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, Nothing, False)
' add event handlers AddHandler Session.OnGetNextFileName, AddressOf Session_OnGetNextFileName
' Set print options, these are copied by the IPNPrintSession ' object to initialize the printer settings
' Creating a multipage file, name is customized in the OnGetNextFileName ' event handler Session.SetSaveOptions("C:\Reports\", "Doc_CaseFile1234_", _ pnOutputFileFormatTIFFMultipaged, False, _ pnColorReductionBlackAndWhite, pnDitheringHalftone, _ False, False, True, True, True, False)
' Get a documentPrintSession object documentPrintSession = Nothing While documentPrintSession Is Nothing Try
63
PNSrv10 COM Interface
Getting StartedHow Do I ?
' Get a new print session for this document with: documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) Catch ex As Exception MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")") Exit While End Try End While
If Not documentPrintSession Is Nothing Then
' print the document to the printer ' using the printer name in documentPrintSession ...
End If
' Wait for the job to be spooled ' Waiting max 1 minute bResult = documentPrintSession.WaitForJobsSpooled(60000)
If bResult == False Then MessageBox.Show("Failed to print (timeout): " + strFile ) End If ' Wait for all the jobs to be complete and do cleanup here ' This is needed to ensure the event handlers get called before we clean up bCompleted = False While Not bCompleted bCompleted = Session.WaitForCompletion(120000) End While
'clean up
' remove added event handlers RemoveHandler Session.OnEndJob, AddressOf Session_OnGetNextFileName
'Release objects System.Runtime.InteropServices.Marshal.FinalReleaseComObject(documentPrintSession) System.Runtime.InteropServices.Marshal.FinalReleaseComObject(Session) Session = Nothing
End Function
C#
private Object LockObject = new Object();int m_currentFileNumber;
// event handler to customize namingvoid session_OnGetNextFileName(IPNJob pJob){ String baseName, strNewName;
// synchronize access to m_currentFileNumber variable lock (LockObject) { try { // get the pre-set base name, this is the second argument passed // to the SetSaveOptions method below, "Doc_CaseFile1234" baseName = pJob.GetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName);
// Set the new output file name base name strNewName = baseName + "_" + String.Format("{0:000000}", m_currentFileNumber);
pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, strNewName);
PNSrv10 COM Interface
64 Getting StartedHow Do I ?
// increment global file number counter m_currentFileNumber += 1; } finally { // release job object pointer Marshal.FinalReleaseComObject(pJob); } }}
private void ConvertFile(String strFile){ // initialize the printer and the number of printers in the printer pool PNSession session = new PNSession(); session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// add event handlers session.OnGetNextFileName += new _IPNSessionEvents_OnGetNextFileNameEventHandler(session_OnGetNextFileName);
// Set print options, these are copied by the IPNPrintSession // object to initialize the printer settings
// Creating a multipage file, name is customized in the OnGetNextFileName // event handler session.SetSaveOptions("C:\\Reports\\", "Doc_CaseFile1234_", pnOutputFileFormatTIFFMultipaged, false, pnColorReductionBlackAndWhite, pnDitheringHalftone, false, false, true, true, true, false)
// Set the file formatting to be a single string and use the OnGetFileName event // to control the file name session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileMultipage, "%s", "$(OutputFileName)", true);
// Now get the documentPrintSession IPNPrintSession documentPrintSession = null; while (documentPrintSession == null) { try { documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } catch (Exception ex) { MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")"); break; } }
if ( documentPrintSession != null ) { // print the document to the printer // using the printer name in documentPrintSession ...
}
// Wait for the job to be spooled, Waiting max 1 minute bResult = documentPrintSession.WaitForJobsSpooled(60000);
if ( bResult == False ) { MessageBox.Show("Failed to print (timeout): " + strFile ) ; }
// Wait for all the jobs to be complete and do cleanup here Boolean bCompleted = false ; while (!bCompleted)
65
PNSrv10 COM Interface
Getting StartedHow Do I ?
{ session.WaitForCompletion(120000) ); }
// Clean up event handlers and release objects to allow temporary printers to be deleted session.OnGetNextFileName += null; Marshal.FinalReleaseComObject(documentPrintSession); Marshal.FinalReleaseComObject(Session); session = null;
}
PNSrv10 COM Interface
66 PNSrv10 COM Interface Object Reference
PNSrv10 COM Interface Object Reference
PNSrv10 COM Interface provides developers with the ability to control the PEERNET printerthrough their own application code for easy print automation. You can easily configure theprinter settings and you have complete control over the printing process right to the end.
Objects
Object Description
IPNSession The IPNSession object is the starting point for workingwith the PNSrv10 COM Interface. It is associated with asingle PEERNET printer, and creates a pool of printerscontaining one or more copies of the printer requestedusing the SetSessionPrinter method.
IPNPrintSession Represents a single printer from the pool of PEERNETprinters held by the IPNSession object. Each documentprinted needs its own IPNPrintSession object to controland synchronize the printing process.
IPNJobs A collection of IPNJob objects, one for every job that hasbeen printed.
IPNJob Each IPNJob object represents a single print job sent toany one of the printer queues in the current IPNSessionobject.
IPNFiles A collection of IPNFile objects, one for every file createdby the printer.
IPNFile An IPNFile object is created for every file created by theprinter and represents the physical file on disk.
IPNPages A collection of IPNPage objects, one for every page of adocument printed.
IPNPage An IPNPage object is created for every page of theprinted document or file
IPNImages A collection of IPNImage objects, one for every page inthe output file on disk.
IPNImage An image object represents a single page in the outputphysical file on disk.
Enumerations
Enumeration Descripion
pnBWCompressionMethod Compression algorithms for monochrome, orblack and white, images.
pnColorCompressionMethod Compression algorithms for color images.
pnColorReduction Color reduction options for reducing thenumber of colors in true color images.
pnDitheringMethod Dithering algorithms to control how colorimages are reduces to black and white.
pnEmailDialog The type of dialog box to use when creatingnew email messages.
pnEmailService The type of e-mail service used toautomatically e-mail the created output
67
PNSrv10 COM Interface
PNSrv10 COM Interface Object Reference
Enumeration Descripion
files.
pnErrorMessageBoxStyle Choose the level of error message display.
pnFaxPageScaling Scale the original information is placed onthe fax sized paper.
pnFaxPageScalingHAlign Horizontally align the incoming image on thefax sized paper.
pnFaxPageScalingVAlign Vertically align the incoming image on thefax sized paper.
pnFaxPaperHeight Height of the fax paper.
pnFaxPaperWidth Width of the fax paper.
pnFaxProfile Choose the fax profile used to create a faximage.
pnFaxResolution The resolution of the fax image.
pnGreyscaleCompressionMethod Compression algorithms for greyscaleimages.
pnImageCopyScaling Determines how the original page is placedon the new image.
pnImageCopyScalingHAlign Horizontally align the image on the outputpage when copying the image to a new pagesize.
pnImageCopyScalingVAlign Vertically align the image on the outputpage when copying the image to a new pagesize.
pnIndexedCompressionMethod Compression algorithms for indexed images.
pnJobVariable Job properties that can be set or retrievedduring IPNSession events.
pnMAPIEmailLogon The type of MAPI email logon behaviour touse.
pnNamingProfile The naming profile to use when creatingfiles.
pnOutputFileFormat The type of file to create.
pnPDFContentEncodingMethod The content encoding, or compressionmethods used by PDF files.
pnPDFEncryption The encryption levels for PDF files.
pnPrinterColorMode Sets the color mode for the printer.
pnPrinterOrientation Sets the paper orientation for the printer
pnPrinterResolution Sets the printer resolution, or dots per inch(DPI) for the printer.
pnResamplUnits How to scale the output image.
pnRotation How much to rotate the output image.Rotation is counter-clockwise.
pnRunCommandsWaitMode The wait mode when running commandsthrough the printer
pnRunCommandWindowState The window state of applications launchedwhen running commands through theprinter.
pnShellAndCommandWaitMode The printed document state to wait for when
PNSrv10 COM Interface
68 PNSrv10 COM Interface Object Reference
Enumeration Descripion
printing using the shell commands or thecommand line.
pnTextEncoding The encoding formats for the output textextraction file.
pnTextEOL The end-of-line encoding formats of theoutput text extraction
pnTextLayout The layout of the text in the output textextraction file.
pnUnits The unit of measure used to enter optionsrequiring a unit of measure.
pnUserVariable User variables for storing custominformation.
pnWatermarkPosition How the watermark image is placed on thepage
69
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferencePNSrv10 COM Interface Heirarchy Chart
PNSrv10 COM Interface Heirarchy Chart
The following diagram outlines the main objects and collections in the PNSrv10 COMInterface.
Click on any object in the diagram to go to the class definition for that object.
PNSrv10 COM Interface
70 PNSrv10 COM Interface Object ReferenceCollections Objects Hierarchy
Collections Objects Hierarchy
The following diagrams outline how the individual collection objects are created during theprinting and conversion process.
Printing a single document to a multi-paged output file
Printing a single document to a serialized output file
71
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceCollections Objects Hierarchy
Appending two documents into a single serialized output file
PNSrv10 COM Interface
72 PNSrv10 COM Interface Object ReferenceIPNSession
IPNSession
Description
The IPNSession object is the starting point for working with the PNSrv10 COM Interface. It isassociated with a single PEERNET printer, and creates a pool of printers containing one ormore copies of the printer requested using the SetSessionPrinter method.
The IPNSession object also holds the settings used to control the each print job's output.The settings are configured using the property methods listed in the table below; not allmethods are valid for all printers. The printer settings must be configured before callingNewPrintSession or NewPrintSessionEx to get an IPNPrintSession object.
The IPNPrintSession object returned contains a copy of the settings contained in theIPNSession object and is associated with a single non-busy printer from the pool of printers.A new IPNPrintSession object is needed for each document printed.
To further control the print and conversion process, there are several events that are firedthat enable an application to intercept and apply specific custom logic. For example, the OnGetNextFileName event can be used to customize filename used to store the output file.
There are two main groups of methods for the IPNSession object. The first group, the initialization methods, are methods used to initialize the object and provide access to top-level objects. For example,NewPrintSession returns an IPNPrintSession object. The propertymethods, the second group of methods, are used to establish the settings for the print jobs.
Optionally, you can choose to track job information as the documents are printed. Thisoption is off by default and can be turned on by setting the IPNSession property TrackingOnto TRUE. When job tracking is enabled, the Jobs property, an IPNJobs collection, ispopulated with an IPNJob object for every print job processed.
Initialization Methods
AddSessionPrinter Reserved for future use, not implemented.
SetSessionPrinter Initializes the IPNSession object to work with aparticular PEERNET printer.
NewPrintSession [Deprecated - use NewPrintSessionEx instead.]Returns a new instance of an IPNPrintSessionobject.
NewPrintSessionEx Returns a new instance of an IPNPrintSessionobject.
Job Tracking Methods
Reset Clears any accumulated job information whenjob information is being tracked.
WaitForCompletion Waits a given timeout period for all jobs in all
73
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
print sessions to be completed before returningcontrol back to the calling application.
Property Methods
GetProperty Retrieves settings from the printer using akeyword string.
SetProperty Set individual printer settings using section andproperty names. See each individual set optionscall for a list of section and property names foreach call.
EnableControlStrings Enabled or disables control string processing inthe printer
ForcePrinterColorMode Forces the printer to print in color or black andwhite.
ForcePrinterOrientation Forces the printer to print in either portrait orlandscape orientation.
ForcePrinterPaperSize Forces the printer to use a particular paper size,such as "Letter", "Legal", or "A4".
ForcePrinterResolution Forces the printer to print a particularresolution, or dots per inch.
SetCompressionOptions
ClearCompressionOptions
[Deprecated - use SetJPEGCompressionOptions,SetPDFCompressionOptions, orSetTIFFCompressionOptions instead.]Set or clear color reduction, dithering andcompression methods for color. indexed,greyscale and monochrome images.
SetCustomPaperOn Enable or disable any custom paper size set.
SetCustomPaperOptions
ClearCustomPaperOptions
Set or clear custom paper size options. Custompaper must be enabled using SetCustomPaperOn for these options to be used.
SetDevModeSettings
ClearDevModeSettings
[Deprecated - use ForcePrinteColorMode ,ForcePrinterResolution, ForcePrinterOrientationand ForcePrinterPaperSize instead.]Set or clear the printer orientation , color mode,resolution and paper size. Other printer optionssuch as custom paper and fax mode canoverride these settings.
PNSrv10 COM Interface
74 PNSrv10 COM Interface Object ReferenceIPNSession
SetEmailMessageOptions
ClearEmailMessageOptions
Set or clear options for automatically emailingoutput files. Email must be enabled by calling SetEmailOn for these options to be used. Thetype of email service used must also be setusing SetEmailService, and one ofSetMAPIEmailService, SetSMTPEmailService, orSetVIMEmailService.
SetEmailOn Enable or disable the email options.
SetEmailService
ClearEmailService
Sets the type of email service to be used. Usewith one of SetMAPIEmailService,SetSMTPEmailService, or SetVIMEmailService.
SetErrorReporting
ClearErrorReporting
Enables and disabled error reporting and debugtracing, sets trace file location.
SetFaxModeOn Enable or disable fax mode.
SetFaxOptions
ClearFaxOptions
Sets or clears fax options. Fax mode must beenabled by calling SetFaxModeOn for theseoptions to be used.
SetFileNamingOptions
ClearFileNamingOptions
[Deprecated - use SetSaveOptions andClearSaveOptions instead.]Set or clear serialized or multi-page output,append mode and set file location and base filenaming options.
SetHardwareMargins
ClearHardwareMargins
Set or clear printer hardware margins.
SetImageCopyToOn Enable or disabled image copy to options.
SetImageCopyToOptions
ClearImageCopyToOptions
Set or clear image copy options. Image Copy Tooptions must be enabled by calling SetImageCopyToOn for these options to beapplied.
SetJPEGCompressionOptions
ClearJPEGCompressionOptions
Sets or clears the color and greyscalecompression options for creating JPEG files, orJPEG-compressed TIFF or PDF files.
SetLandscapeWatermarkOptions
SetPortraitWatermarkOptions
ClearWatermarkOptions
Sets or clears watermarking options forlandscape and portrait images. Watermarkingmust be enabled by calling SetWatermarkOptionsOn for these options to beapplied.
75
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
SetMAPIEmailService Sets options for MAPI email.
SetMessageBoxAlerts
ClearMessageBoxAlerts
Set and clear error message box display options.
SetNamingProfileFormat
ClearNamingProfileFormat
Set and clear the advanced naming profileinformation for the specified file naming profile.
SetPageBrightness
ClearPageBrightness
Set and clear any page brightness options.
SetPageCropAreaOptions
ClearPageCropAreaOptions
Set and clear any page cropping area options.Page cropping must be enabled by calling SetPageCropOn for these options to be applied.Only one of SetPageCropAreaOptions or SetPageCropMarginOptions can be set at anyone time. Whichever method is last calleddetermines whether margins or a page area iscropped.
SetPageCropMarginOptions
ClearPageCropMarginOptions
Set and clear any page cropping margin options.Page cropping must be enabled by calling SetPageCropOn for these options to be applied.Only one of SetPageCropAreaOptions orSetPageCropMarginOptions can be set at anyone time. Whichever method is last calleddetermines whether margins or a page area iscropped.
SetPageCropOn Enable or disable page cropping options.
SetPageRotationOptions
ClearPageRotationOptions
Set or clear page rotation options for portraitand landscape pages.
SetPageTrimOptions
ClearPageTrimOptions
Set or clear page trimming options
SetPDFCompressionOptions
ClearPDFCompressionOptions
Set or clear PDF compression options for color.indexed, greyscale and monochrome images.
SetPDFFileFormatOptions
ClearPDFFileFormatOptions
[Deprecated - use SetSaveOptions, ClearSaveOptions, SetPDFCompressionOptions,or ClearPDFCompressionOptions instead.]Set or clear PDF file format options includingcolor reduction, dithering and compressionmethods for color. indexed, greyscale andmonochrome images.
PNSrv10 COM Interface
76 PNSrv10 COM Interface Object ReferenceIPNSession
SetPDFPassword
ClearPDFPassword
Sets or clears the password options for PDFfiles.
SetPDFSecurity
ClearPDFSecurity
Sets or clears the security options for PDF files.
SetPortraitWatermarkOptions Sets watermarking options for portrait images.Watermarking must be enabled by calling SetWatermarkOptionsOn for these options to beapplied.
SetResamplingOn Enable or disable resampling options.
SetResamplingOptions
ClearResamplingOptions
Set or clear resampling options. Resamplingmust be enabled by calling SetResamplingOn forthese options to be applied.
SetRunAtEndCommand
ClearRunAtEndCommand
Set or clear any Run at End of Job commands.These commands are provided for compatibilitywith programs using previous versions of theprinters; new applications should use theIPNSession events to perform custom actions.
SetRunAtFileCloseCommand
ClearRunAtFileCloseCommand
Set or clear any Run at End of Job commands.These commands are provided for compatibilitywith programs using previous versions of theprinters; new applications should use theIPNSession events to perform custom actions.
SetRunAtPageCommand
ClearRunAtPageCommand
Set or clear any Run at Page commands. Thesecommands are provided for compatibility withprograms using previous versions of theprinters; new applications should use theIPNSession events to perform custom actions.
SetRunAtStartCommand
ClearRunAtStartCommand
Set or clear any Run at Start commands. Thesecommands are provided for compatibility withprograms using previous versions of theprinters; new applications should use theIPNSession events to perform custom actions.
SetSaveOptions
ClearSaveOptions
Set or clear file location and base file namingoptions, as well as append, prompting andoverwrite options.
SetSMTPEmailService Sets options for SMTP email.
SetTextExtractionOn Enable or disable the text extraction options.
77
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
SetTextExtractionOptions
ClearTextExtractionOptions
Set or clear the text extraction options. Textextraction must be enabled by calling SetTextExtractionOn for these options to beapplied.
SetTIFFAdvancedOptions
ClearTIFFAdvancedOptions
Set or clear TIFF options such as fill order,photometric and byte alignment.
SetTIFFCompressionOptions
ClearTIFFCompressionOptions
Set or clear TIFF compression options for color,indexed, greyscale and monochrome images.
SetUserExit32
SetUserExit64
ClearUserExits
Set or clear user exit calls. The user exits callsare are included for backwards compatibilitywith previous applications using this method,but new applications should use the IPNSessionevents to perform custom actions at theappropriate stage.
SetUserVariable Set or clear any custom information.
SetVIMEmailService Sets options for Lotus Notes/Domino email.
SetWatermarkOptionsOn Enable or disable watermarking options.
Properties
Jobs Read-only; A collection of IPNJob objects, onefor each file printed.
TrackingOn Read/Write; A boolean flag to turn jobinformation tracking on or off.
Events
OnGetNextFileName Event is fired each time a filename is needed,allowing full customization of the output filenames.
OnStartJob Event is fired when a new print job has enteredthe print queue.
OnOpenFile This event is fired each time a new output file isopened.
OnStartPage This event is fired each time a new page in anoutput file is created.
PNSrv10 COM Interface
78 PNSrv10 COM Interface Object ReferenceIPNSession
OnStartImage This event is fired each time a new output imageis about to be created. This event is fired oncefor each page created.
OnEndImage This event is fired each time a new output imageis completed. Currently This event is fired oncefor each page created.
OnEndPage This event is fired each time a new page in anoutput file is completed.
OnCloseFile This event is fired each time a new output file isclosed
OnEndJob This event is fired each time the print job hascompleted.
OnReportError This event is fired when an error is reported bythe driver.
OnLogMessage Reserved for future use, not implemented.
79
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Initialization Methods
AddSessionPrinter
This feature is reserved for future use and is not implemented in the current product.
SetSessionPrinter
Description
Sets the active printer used by the session and the number of temporary printers tocreate in the printer pool. Having more than one printer in the pool of printers allowsmore than one file to be submitted at a time. While you can have as many printers inyour pool as you want, care must be taken to balance the number of printers with yoursystem resources. Each printer is created with a unique name, and is deleted when allreferences to IPNSession are closed.
Each printer can also be configured to create and use a unique port name. The portnames can be dynamically generated for each printer, created based on a given string ofcharacters, or set to use existing ports already created on the system. Combiningmultiple printers with unique port names allows for parallel processing, or processingmore than one file at a time.
When a string is specified for the port name, the port(s) are created using the namespecified in the string and appended with the number of the printer in the printer pool.For example, specifying "myport" with a printer pool of two printers will create the ports"myport1" and "myport2". If the ports are precreated and Precreated is True, the samenaming scheme applies.
Creating printers ports requires that the user has the SERVER_ACCESS_ADMINISTERright granting them the right to administer print servers.
Syntaxexpression.SetSessionPrinter(PrinterName,PrinterPoolSize,PortBaseName,PortsPreCreated)
where expression is a IPNSession object.
Parameters
String PrinterNameThe name of the PEERNET printer to use. Can be one of TIFF Image Printer 10.0, PDFImage Printer 10.0, or Raster Image Printer 10.0. The respective printer must beinstalled on the computer.
Integer PrinterPoolSizeThe number of temporary printers to create in the printer pool.
String PortBaseNameThe base string to use for the port name. This can be an empty string, in which casethe port name is created based on the temporary printer’s unique name.
Boolean PortsPreCreatedIf True, then the ports are already created and PortBaseName is used to determinethe port name for each printer.
PNSrv10 COM Interface
80 PNSrv10 COM Interface Object ReferenceIPNSession
Exceptions
An exception will be thrown if any of the following is true:
The printer cannot be found; check that the printer exists and that the printer name isspelled correctly
You do not have sufficient privileges to create copies of the printer, or to create localprinter ports
SetSessionPrinter is called more than once on a single IPNSession object
Examples
Visual Basic
Public WithEvents Session As PNSession...
Try Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)Catch ex As Exception MsgBox(ex.Message)End Try
C#
PNSession session = null;...
//allocate print sessionsession = new PNSession();
// Set the printer and the number of printer clones to usesession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: NewPrintSession
NewPrintSession
This method has been superseded by the NewPrintSessionEx method.
Description
Returns a new instance of an IPNPrintSession object. A new print session object isneeded for each file printed, and represents one printer from the pool of printers. TheIPNPrintSession object copies the current settings from the IPNSession object and isused the monitor the status of the file as it is printed.
Syntaxexpression.NewPrintSession(Timeout,AvailableTimeout)
81
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
where expression is a IPNSession object.
Returns a new IPNPrintSession instance , or NULL if a new printer session could not beretrieved.
Parameters
Integer TimeooutHow long to wait, in milliseconds, for a printer in the printer pool to becomeavailable.
Integer AvailableTimeoutHow long to wait, in milliseconds, for a second job to appear in the printer queue. Aslong as new print jobs are continuing to be submitted to the printer, the printer is notavailable. When AvailableTimeout milliseconds have passed with no more print jobshaving been added to the printer queue, the printer is made available and returnedto the printer pool.
Remarks
After the document has been printed the print session object needs to be garbagecollected in order to be released back into the printer pool. In .NET, use the method InteropServices.Marshal.FinalReleaseComObject to trigger the garbage collection.
If the print session is released but the file fails to print to the printer, the IPNPrintSessionobject will wait a maximum of 2 minutes before being released back into the printerpool. If you need to control this wait period, use NewPrintSessionEx instead.
To determine if the file has been sent to the printer call the WaitForDocSpooling methodon the print session object before calling FinalReleaseComObject to release the printsession.
Examples
Visual Basic
Public WithEvents Session As PNSessionDim documentPrintSession As IPNPrintSession
...
' allocate a sessionSession = New PNSession
' Set the printer and the number of printer clones to use in this sessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Get a documentPrintSession objectWhile documentPrintSession Is Nothing
Try ' Get a new print session for this document with: ' int Timeout ' 5 second timeout waiting for an available printSession to be returned ' int AvailableTimeout ' 1/4 second timeout waiting between jobs entering the queue. If a new job ' is not seen in the print queue in the timeout period, the printer is free to ' be released back into the printer pool. documentPrintSession = session.NewPrintSession(5000, 250)
PNSrv10 COM Interface
82 PNSrv10 COM Interface Object ReferenceIPNSession
Catch ex As Exception MessageBox.Show("Exception on NewPrintSession (" + ex.Message + ")") Exit While End TryEnd While
' print the document...
' Release the print session so another documentPrintSession may start printingInteropServices.Marshal.FinalReleaseComObject(documentPrintSession)documentPrintSession = Nothing
C#
PNSession session = null;IPNPrintSession documentPrintSession = null;
...
// allocate a sessionsession = new PNSession();
// Set the printer and the number of printer clones to use in this sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Get a documentPrintSession objectwhile (documentPrintSession == null){ try { // Get a new print session for this document with: // int Timeout // 5 second timeout waiting for an available printSession to be returned // int AvailableTimeout // 1/4 second timeout waiting between jobs entering the queue. If a new job // is not seen in the print queue in the timeout period, the printer is free to // be released back into the printer pool documentPrintSession = session.NewPrintSession(5000, 250); } catch (Exception ex) { lock (worker) { MessageBox.Show("Exception on NewPrintSession (" + ex.Message + ")"); } break; }}
// print the document...
// Release the print session so another documentPrintSession may start printingInteropServices.Marshal.FinalReleaseComObject(documentPrintSession);documentPrintSession = null;
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: NewPrintSessionEx SetSessionPrinter
83
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
NewPrintSessionEx
Description
Returns a new instance of an IPNPrintSession object. A new print session objectrepresents one printer from the pool of printers. A separate print session is needed foreach file printed. The IPNPrintSession object copies the current settings from theIPNSession object and is used to monitor the status of the file as it is printed.
Syntaxexpression.NewPrintSessionEx(Timeout,FirstJobTimeout, AvailableTimeout, OptionsFlags)
where expression is a IPNSession object.
Returns a new IPNPrintSession instance , or NULL if a new printer session could not beretrieved.
Parameters
Integer TimeooutHow long to wait, in milliseconds, for a printer in the printer pool to becomeavailable.
Integer FirstJobTimeoutHow long to wait, in milliseconds, for a job to appear in the printer queue beforeputting the printer back into the printer pool. This timeout only comes into effectafter the printSession object has been released by the calling application.
Integer AvailableTimeoutHow long to wait, in milliseconds, for a second job to appear in the printer queue. Aslong as new print jobs are submitted to the printer, the printer is not available.When AvailableTimeout milliseconds have passed with no additional jobs in theprinter queue, the printer is made available and returned to the printer pool.
Integer OptionsFlagsReserverd for future use; specify 0 for this parameter.
Remarks
After the document has been printed the print session object needs to be garbagecollected in order to be released back into the printer pool. In .NET, use the method InteropServices.Marshal.FinalReleaseComObject to trigger the garbage collection.
If the print session is released but the file fails to print to the printer, the IPNPrintSessionobject will wait the timeout specified in the FirstJobTimeout parameter before beingreleased back into the printer pool.
To determine if the file has been sent to the printer call the WaitForDocSpooling methodon the print session object before calling FinalReleaseComObject to release the printsession.
Examples
PNSrv10 COM Interface
84 PNSrv10 COM Interface Object ReferenceIPNSession
Visual Basic
Public WithEvents Session As PNSessionDim documentPrintSession As IPNPrintSession
...
' allocate a sessionSession = New PNSession
' Set the printer and the number of printer clones to use in this sessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Get a documentPrintSession objectWhile documentPrintSession Is Nothing
Try ' Get a new print session for this document with: ' int Timeout - 5 second timeout waiting for an available printSession ' to be returned ' int FirstJobTimeout - 1 minute max timeout to wait for a job to appear ' in the queue before releasing the printer back to the pool; applies only ' after the printSession has been released. ' int AvailableTimeout - 1/4 second timeout waiting between jobs entering ' the queue. If a new job is not seen in the print queue in the timeout ' period, the printer is free to be released back into the printer pool. ' int OptionFlags - reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0)
Catch ex As Exception MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")") Exit While End TryEnd While
' print the document...
' Release the print session so another documentPrintSession may start printingInteropServices.Marshal.FinalReleaseComObject(documentPrintSession)documentPrintSession = Nothing
C#
PNSession session = null;IPNPrintSession documentPrintSession = null;
...
// allocate a sessionsession = new PNSession();
// Set the printer and the number of printer clones to use in this sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Get a documentPrintSession objectwhile (documentPrintSession == null){ try { // Get a new print session for this document with: // int Timeout - 5 second timeout waiting for an available printSession // to be returned // int FirstJobTimeout - 1 minute max timeout to wait for a job to appear // in the queue before releasing the printer back to the pool; applies only // after the printSession has been released. // int AvailableTimeout - 1/4 second timeout waiting between jobs entering // the queue. If a new job is not seen in the print queue in the timeout
85
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
// period, the printer is free to be released back into the printer pool. // int OptionFlags - reserved for future use documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } catch (Exception ex) { lock (worker) { MessageBox.Show("Exception on NewPrintSessionEx (" + ex.Message + ")"); } break; }}
// print the document...
// Release the print session so another documentPrintSession may start printingInteropServices.Marshal.FinalReleaseComObject(documentPrintSession);documentPrintSession = null;
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: NewPrintSession SetSessionPrinter
PNSrv10 COM Interface
86 PNSrv10 COM Interface Object ReferenceIPNSession
Job Tracking Methods
Reset
Description
Clears any currently accumulated job tracking information from the Jobs collection. Jobtracking information can only be cleared from the collection when there are no jobsrunning on any of the printers in your printer pool.
Job information is only accumulated if job tracking is enabled for the session object. Jobtracking is off by default and is enabled through the TrackingOn property.
The Reset method should be called after calling WaitForCompletion to determine that allprint sessions have completed, or the WaitTimeout parameter can be used to specify atimeout period to wait for any running print jobs to finish. If the print jobs have notcompleted the method returns False and nothing is cleared.
Syntaxexpression.Reset(WaitTimeout)
Returns Boolean True if the job collection was cleared within the timeout period, andFalse if it did not.
Parameters
Integer WaitTimeoutThe amount of time, in milliseconds, to wait for the job information to be cleared.
Examples
Visual Basic
Dim dir_info As New System.IO.DirectoryInfo("C:\MyDocs\")Dim file_infos() As System.IO.FileInfoDim bReset, bCompleted As BooleanPublic Session As PNSession
...' allocate print sessionSession = New PNSession
' initialize the printer and the number OF printers IN the printer poolSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Turn on job trackingSession.TrackingOn = True
' Get the files.file_infos = dir_info.GetFiles("*.doc")
For Each file_info As System.IO.FileInfo In file_infos
' process each document, uses a separate print session ' FOR each document...
Next
' make sure all jobs from all print sessions are complete' LOOP and check every 2 SECONDS
87
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
bCompleted = FalseWhile bCompleted = False bCompleted = Session.WaitForCompletion(1000) LogMessage("Waiting for print sessions to complete...")End While
' Do something with tracked information such as check page count for each file' or go through job collection and process each created file.For Each Job As IPNJob In Session.Jobs
' do something here
Next
' Reset the job collection TO clear memory, LOOP every 1/2 secondbReset = FalseWhile bReset = False bReset = Session.Reset(500) LogMessage("Waiting for jobs collection to clear...")End While
C#
System.IO.DirectoryInfo searchDir = new System.IO.DirectoryInfo("C:\\MyDocs\\");System.IO.FileInfo[] infos = searchDir.GetFiles("*.doc");object myTrue = true, filename, optMissing = System.Type.Missing; Boolean bReset, bCompleted ;PNSession session = null;
//allocate print sessionsession = new PNSession();
// initialize the printer and the number of printers in the printer poolsession.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// Turn on job trackingsession.TrackingOn = True;
// loop through and convert each fileforeach (System.IO.FileInfo iFI in infos){
// process each document, uses a separate print session // for each document
}
// make sure all jobs from all print sessions are complete// loop and check every 2 secondsbCompleted = false;while (bCompleted == false){ bCompleted = session.WaitForCompletion(1000); LogMessage("Waiting for print sessions to complete...");}
// Do something with tracked information such as check page count for each file// or go through job collection and process each created file.foreach (IPNJob Job in session.Jobs){ // do something here}
// Reset the job collection to clear memory, loop every 1/2 secondbReset = False;while (bReset == False){
PNSrv10 COM Interface
88 PNSrv10 COM Interface Object ReferenceIPNSession
bReset = session.Reset(500); LogMessage("Waiting for jobs collection to clear...");}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: WaitForCompletion TrackingOn IPNJobs IPNJob
WaitForCompletion
Description
Waits for all print jobs in all printers in the printer pool to be completed. The methodreturns True as soon as all print jobs in all printers in the printer pool are completed, orFalse if the timeout period elapses before the jobs are complete.
If any of the IPNSession events, in particular OnCloseFile and OnEndJob, are being usedthen this function has to be called before releasing the session object in order to ensurethat all event notifications are received.
Syntaxexpression.WaitForCompletion(WaitTimeout)
Returns Boolean True if all print jobs were completed within the timeout period, andFalse if they did not.
Parameters
Integer WaitTimeoutThe amount of time, in milliseconds, to wait for all the jobs to be completed.
Examples
Visual Basic
Dim dir_info As New System.IO.DirectoryInfo("C:\MyDocs\")Dim file_infos() As System.IO.FileInfoDim bReset, bCompleted As BooleanPublic Session As PNSession
...' allocate print sessionSession = New PNSession
' initialize the printer and the number OF printers IN the printer poolSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Turn on job trackingSession.TrackingOn = True
' Get the files.file_infos = dir_info.GetFiles("*.doc")
For Each file_info As System.IO.FileInfo In file_infos
' process each document, uses a separate print session
89
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
' FOR each document...
Next
' make sure all jobs from all print sessions are complete' LOOP and check every 2 SECONDSbCompleted = FalseWhile bCompleted = False bCompleted = Session.WaitForCompletion(1000) LogMessage("Waiting for print sessions to complete...")End While
' Do something with tracked information such as check page count for each file' or go through job collection and process each created file.For Each Job As IPNJob In Session.Jobs
' do something here
Next
' Reset the job collection TO clear memory, LOOP every 1/2 secondbReset = FalseWhile bReset = False bReset = Session.Reset(500) LogMessage("Waiting for jobs collection to clear...")End While
C#
System.IO.DirectoryInfo searchDir = new System.IO.DirectoryInfo("C:\\MyDocs\\");System.IO.FileInfo[] infos = searchDir.GetFiles("*.doc");object myTrue = true, filename, optMissing = System.Type.Missing; Boolean bReset, bCompleted ;PNSession session = null;
//allocate print sessionsession = new PNSession();
// initialize the printer and the number of printers in the printer poolsession.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// Turn on job trackingsession.TrackingOn = True;
// loop through and convert each fileforeach (System.IO.FileInfo iFI in infos){
// process each document, uses a separate print session // for each document
}
// make sure all jobs from all print sessions are complete// loop and check every 2 secondsbCompleted = false;while (bCompleted == false){ bCompleted = session.WaitForCompletion(1000); LogMessage("Waiting for print sessions to complete...");}
// Do something with tracked information such as check page count for each file// or go through job collection and process each created file.foreach (IPNJob Job in session.Jobs){
PNSrv10 COM Interface
90 PNSrv10 COM Interface Object ReferenceIPNSession
// do something here}
// Reset the job collection to clear memory, loop every 1/2 secondbReset = False;while (bReset == False){ bReset = session.Reset(500); LogMessage("Waiting for jobs collection to clear...");}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: Reset TrackingOn IPNJobs IPNJob
91
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Property Methods
GetProperty
Description
Allows you to retrieve any properties, or options that you have set on the IPNSessionobject using the SetProperty method or any of the other set options methods likeSetSaveOptions that group the settings into a single call.
The properties are organized into sections and then by name within that section. Thesection and properties names are case sensitive. The section and property names, andvalues for each property are the same as the configuration file settings explained in the"Customizing Printer Defaults" section of the User Guide for the printer being used.
Not all properties are available to all printers, and some properties are specific to certainprinters. GetProperty uses the same arguments as SetProperty; see the individual setoption methods for a list of section and property names used for each.
Syntaxexpression.GetProperty(SectionName, PropertyName)
where expression is an IPNSession object.
Returns a VARIANT containing the property value, or VT_EMPTY if that property is notset.
Parameters
String SectionName
The section name for the property you are retrieving.
String PropertyName
The property name.
Examples
Visual Basic
Public WithEvents Session As PNSession
Dim basefilename As StringSession = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
bAppend = cbAppendTogether.Checked
' set name and save location, create multipage tiff and append all into a single fileSession.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, bAppend, _ pnColorReductionOptimal, pnDitheringHalftone, _ False, False, True, True, True, False)
' get the name we usedbasefilename = Session.GetProperty("Save", "Output filename")MsgBox(basefilename)
PNSrv10 COM Interface
92 PNSrv10 COM Interface Object ReferenceIPNSession
C#
PNSession session = null;
String basefilename;session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
bAppend = cbAppendTogether.Checked;
// set name and save location, create multipage tiff and append all into a single filesession.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", pnOutputFileFormatTIFFMultipaged, bAppend, pnColorReductionOptimal, pnDitheringHalftone False, False, True, True, True, False);
// get the name we usedbasefilename = (String)session.GetProperty("Save", "Output filename");MessageBox.Show(basefilename);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetProperty
SetProperty
Description
Allows you to individually set any properties, or options, on the IPNSession objectinstead of using other set options methods like SetSaveOptions that group the settingsinto a single call. The SetProperty method can also be used to clear a property bypassing an empty argument as the property value.
Note: The section and properties names are case sensitive and they and the values foreach property are the same as the configuration file settings explained in the"Customizing Driver Defaults" section of the User Guide for the printer you areusing. Not all properties are available to all printers, and some properties arespecific to certain printers.
The properties are organized into sections and then by name within thatsection. See the individual set property methods for a list of section andproperty names to use for each argument in the method.
Syntaxexpression.SetProperty(SectionName, PropertyName, varValue)
where expression is an IPNSession object.
Parameters
93
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
String SectionName
The section name for the property you are settings.
String PropertyName
The property name.
Variant varValueThe value of the property you are setting.
Examples
Visual Basic
Public WithEvents Session As PNSession
Dim basefilename As StringSession = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
bAppend = cbAppendTogether.Checked
' set name and save location, create multipage tiff and append all into a single fileSession.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, bAppend, _ pnColorReductionOptimal, pnDitheringHalftone, _ False, False, True, True, True, False)
' Clear the append property, use printer factory defaults.Session.SetProperty("Save", "Append", Nothing)
' set just the filename, change from TIFFReport set aboveSession.SetProperty("Save", "Output filename", "JanuaryReports")
' get the name we just changed to basefilename = Session.GetProperty("Save", "Output filename")MsgBox(basefilename)
C#
PNSession session = null;
String basefilename;session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
bAppend = cbAppendTogether.Checked;
// Set name and save location, create multipage tiff and append all into a single filesession.SetSaveOptions("C:\\TIFFOutput\\", "TIFFReport", pnOutputFileFormatTIFFMultipaged, bAppend, pnColorReductionOptimal, pnDitheringHalftone, False, False, True, True, True, False);
// Clear the append property, use printer factory defaults.Session.SetProperty("Save", "Append", null);
// set just the filename, change from TIFFReport set aboveSession.SetProperty("Save", "Output filename", "JanuaryReports");
// get the name we usedbasefilename = (String)printSession.GetProperty("Save", "Output filename");MessageBox.Show(basefilename);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF Image
PNSrv10 COM Interface
94 PNSrv10 COM Interface Object ReferenceIPNSession
Printer 10.0
See Also: GetProperty
EnableControlStrings
Description
Control strings can be used to manipulate printer settings dynamically during print jobs.Control strings embedded in your documents override settings set in the printer throughthe IPNSession object. See the User Guide for your printer for more information oncontrol strings.
Control string functionality can be set using the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.EnableControlStrings(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableA Boolean value, True to turn on control string processing, False to ignore anycontrol strings.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
bEnable SectionName: Advanced Features
PropertyName: Custom Paper Enable
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'allow control string processingSession.EnableControlStrings(True)
C#
PNSession session = null;
95
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// allow control string processingsession.EnableControlStrings(true);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetProperty
ForcePrinterColorMode
Description
Sets the color mode for the printer. When this option is not set through the IPNSessionobject, the default color option on the Paper/Quality tab in the PEERNET printer's PrintingPreferences dialog will be applied to the output file instead.
To remove the forced color mode, call this method with pnPrinterColorModeDefault asthe color. This will clear the setting.
The printer color option can also be set and cleared individually using the SetPropertycall with the appropriate arguments. See the Remarks below for the arguments needed.
Syntaxexpression.ForcePrinterColorMode(ColorMode)
where expression is an IPNSession object.
Parameters
pnPrinterColorMode ColorModeA pnPrinterColorMode constant for the color mode of the printer.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
ColorMode SectionName: Devmode settings
PropertyName: Color
varValue: VT_BOOL, True for Color, False forMonochrome
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession
PNSrv10 COM Interface
96 PNSrv10 COM Interface Object ReferenceIPNSession
Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.ForcePrinterColorMode(pnPrinterColorModeBW)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
session.ForcePrinterColorMode(pnPrinterColorModeBW);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ForcePrinterOrientation ForcePrinterPaperSize ForcePrinterResolutionSetDevModeSettings ClearDevmodeSettings SetProperty pnPrinterColorModepnPrinterOrientation pnPrinterResolution
ForcePrinterOrientation
Description
Sets the page orientation of the printer. When this option is not set through theIPNSession object, the default page orientation on the Layout tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To remove the forced page orientation, call this method with pnPrinterOrientationDefaultas the orientation. This will clear the setting.
The page orientation can also be set and cleared individually using the SetProperty callwith the appropriate arguments. See the Remarks below for the arguments needed.
Syntaxexpression.ForcePrinterOrientation(Orientation)
where expression is an IPNSession object.
Parameters
pnPrinterOrientation OrientationA pnPrinterOrientation constant for the page orientation of the printer.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Orientation SectionName: Devmode settings
PropertyName: Orientation
varValue: VT_BSTR, one of the following:
97
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
PortraitLandscape
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.ForcePrinterOrientation(pnPrinterOrientationPortrait)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
session.ForcePrinterOrientation(pnPrinterOrientationPortrait);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ForcePrinterColorMode ForcePrinterPaperSize ForcePrinterResolutionSetDevModeSettings ClearDevmodeSettings SetProperty pnPrinterColorModepnPrinterOrientation pnPrinterResolution
ForcePrinterPaperSize
Description
Sets the paper size used by the printer; some common paper sizes are Letter, Legal orA4. When this option is not set, the application that is printing will set the paper size orthe default paper size set through the PEERNET printer's Printing Preferences dialog willbe applied to the output file.
To remove the forced paper size, call this method with an empty string. This will clearthe setting.
The paper size can also be set and cleared individually using the SetProperty call withthe appropriate arguments. See the Remarks below for the arguments needed.
Syntaxexpression.ForcePrinterPaperSize(PaperSize)
where expression is an IPNSession object.
Parameters
String PaperSizeThe name of the paper size to use, such as Letter or Legal.
PNSrv10 COM Interface
98 PNSrv10 COM Interface Object ReferenceIPNSession
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
PaperSize SectionName: Devmode settings
PropertyName: Paper Size
varValue: VT_BSTR, name of the paper size."Letter", "A4", etc.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.ForcePrinterPaperSize("Legal")
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
session.ForcePrinterPaperSize("Legal");
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ForcePrinterColorMode ForcePrinterPaperSize ForcePrinterResolutionSetDevModeSettings ClearDevmodeSettings SetProperty pnPrinterColorModepnPrinterOrientation pnPrinterResolution
ForcePrinterResolution
Description
Sets the resolution, or dots per inch (DPI) of the printer. When this option is not setthrough the IPNSession object, the default resolution set in the PEERNET printer's Printing Preferences dialog will be applied to the output file instead.
To remove the forced resolution, call this method with pnPrinterResolutionDefault as theresolution. This will clear the setting.
The resolution can also be set and cleared individually using the SetProperty call with theappropriate arguments. See the Remarks below for the arguments needed.
Syntax
99
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
expression.ForcePrinterResolution(Resolution)
where expression is an IPNSession object.
Parameters
pnPrinterResolution ResolutionA pnPrinterResolution constant for the resolution of the printer.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Resolution SectionName: Devmode settings
PropertyName: Resolution
varValue: VT_I4, one of the following:1200720600400360300254240200150120100756050
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.ForcePrinterResolution(pnPrinterResolution200)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
session.ForcePrinterResolution(pnPrinterResolution200);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
PNSrv10 COM Interface
100 PNSrv10 COM Interface Object ReferenceIPNSession
See Also: ForcePrinterColorMode ForcePrinterPaperSize ForcePrinterResolutionSetDevModeSettings ClearDevmodeSettings SetProperty pnPrinterColorModepnPrinterOrientation pnPrinterResolution
SetCompressionOptions
Beginning with version 9.0 of the printer drivers, this method has been supersededby SetJPEGCompressionOptions, SetPDFCompressionOptions, andSetTIFFCompressionOptions. This method will still work when called using Enter value
but an error is thrown when used with Raster Image Printer and PDF Image Printer.
Description
Sets the color reduction, dithering method and compression options used to store theimage in the output file. The actual compression method used on each page will dependon the color reduction method chosen, if any. Other output options used, such as SetFaxImageOptions may supersede any settings chosen here.
To set only a single compression option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetCompressionOptions(ColorReduction, Dithering, Color, Indexed, Greyscale, BW)
where expression is a IPNSession object.
Parameters
pnColorReduction ColorReductionA pnColorReduction constant for any color reduction options to apply to the outputfile. There are four color reduction options available for reducing the number of colorsin true color images. In general, the fewer the colors in an image, the smaller the filesize.
pnDitheringMethod DitheringA pnDitheringMethod constant to determine the method used when reducing colorimages to black and white. Dithering is used to enhance the appearance of colorimages that have been reduced to black and white.
pnColorCompressionMethod ColorA pnColorCompressionMethod constant for the compression method to use for colorimages.
pnIndexedCompressionMethod IndexedA pnIndexedCompressionMethod constant for the compression method to use forindexed images. An indexed image is an image that has 256 colors or less.
pnGreyscaleCompressionMethod GreyscaleA pnGreyscaleCompressionMethod constant for the compression method to use forgreyscale images.
pnBWCompressionMethod BWA pnBWCompressionMethod constant for the compression method to use for black
101
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
and white images.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
ColorReduction SectionName: Compression
PropertyName: Color reduction
varValue: VT_BSTR, one of the following:NoneOptimalBWGrey
Dithering SectionName: Compression
PropertyName: Dithering method
varValue: VT_BSTR, one of the following:NoneFloydBurkesBayerHalftone
Color SectionName: Compression
PropertyName: Color compression
varValue: VT_BSTR, one of the following:NoneNone CMYKPackbitsPackbits CMYKJPEG HighJPEG MediumJPEG LowLZWLZW CMYK
Indexed SectionName: Compression
PropertyName: Indexed compression
varValue: VT_BSTR, one of the following:NonePackbitsJPEG HighJPEG MediumJPEG LowLZW
Greyscale SectionName: Compression
PropertyName: Greyscale compression
PNSrv10 COM Interface
102 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
varValue: VT_BSTR, one of the following:NonePackbitsJPEG HighJPEG MediumJPEG LowLZW
BW SectionName: Compression
PropertyName: BW compression
varValue: VT_BSTR, one of the following:NoneGroup4Group3-2DGroup3-1DMHLZW
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'set the compression options - reduce to black and white with Floyd-Steinburg' compress using CCITTG4Session.SetCompressionOptions(pnColorReduction.pnColorReductionBlackAndWhite, _ pnDitheringMethod.pnDitheringFloyd, _ pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
//set the compression options - reduce to black and white with Floyd-Steinburg// compress using CCITTG4session.SetCompressionOptions( pnColorReduction.pnColorReductionBlackAndWhite, pnDitheringMethod.pnDitheringFloyd, pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
Supported Printers: TIFF Image Printer 10.0
See Also: ClearCompressionOptions SetProperty pnColorReduction pnDitheringMethodpnColorColorCompressionMethod pnIndexedCompressionMethod
103
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
pnGreyscaleCompressionMethod pnBWCompressionMethod
ClearCompressionOptions
Beginning with version 9.0 of the printer drivers, this method has been supersededby ClearJPEGCompressionOptions, ClearPDFCompressionOptions, andClearTIFFCompressionOptions. This method will still work when called using Enter
value but an error is thrown when used with Raster Image Printer and PDF Image Printer.
Description
Clears the color reduction and dithering options as well as the compression options forcolor, indexed, grayscale and black and white output from the IPNSession object. Whenthe compression options are not set through the IPNSession object, the default optionsfor the Compression tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
To clear only a single compression option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetCompressionOptions for a list of values.
Syntaxexpression.ClearCompressionOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearCompressionOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0, 1, null, false);...
// reset session for new print session.ClearCompressionOptions();
Supported Printers: TIFF Image Printer 10.0
See Also: SetCompressionOptions SetProperty
PNSrv10 COM Interface
104 PNSrv10 COM Interface Object ReferenceIPNSession
SetCustomPaperOn
Description
Enables or disables any custom paper size settings. If custom paper is enabled and thereare no custom paper options set through the IPNSession object the default options forCustom Paper on the Advanced Features tab in the PEERNET printer's PrintingPreferences dialog will be applied to the output file instead.
Custom paper can also enabled or disabled using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetCustomPaperOn(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableA Boolean value, True to turn on custom paper size, False to disable custom papersize.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Advanced Features
PropertyName: Custom Paper Enable
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'set custom paper on, set page size to 24"x36" with margins of 0.250"Session.SetCustomPaperOn(True)Session.SetCustomPaperOptions(pnUnits.pnUnitsEnglish, 24.0, 36.0, _ 0.125, 0.125, 0.125, 0.125)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// set custom paper on, set page size to 24"x36" with margins of 0.250"session.SetCustomPaperOn(True);session.SetCustomPaperOptions(pnUnits.pnUnitsEnglish, 24.0, 36.0,
105
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
0.125, 0.125, 0.125, 0.125);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetCustomPaperOptions SetHardwareMargins ClearCustomPaperOptionsClearHardwareMargins SetProperty
SetCustomPaperOptions
Description
Sets a custom paper size for the output file. Custom paper size consists of the width andheight and top, left, right and bottom printer area margins for the new paper size. Youcan enter units with up to three digits of accuracy, or to an eighth of an inch (0.125in or0.318cm).
These settings are only applied when custom paper size is enabled. The combined Leftand Right printer area margins must be less than the Width of the custom paper. Thecombined Top and Bottom printer area margins must be less than the Height of thecustom paper.
If custom paper is enabled and there are no custom paper options set through the IPNSession object the default options for Custom Paper on the Advanced Features tab inthe PEERNET printer's Printing Preferences dialog will be applied to the output fileinstead.
Custom paper options can also be set using the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
For a more detailed explanation of the custom paper options, see the User Guide for the PEERNET printer being used.
Syntaxexpression.SetCustomPaperOn(Units, CustomPaperWidth, CustomPaperHeight, PrinterMarginLeft, PrinterMarginTop, PrinterMarginRight, PrinterMarginBottom)
where expression is an IPNSession object.
Parameters
pnUnits UnitsA pnUnits constant for the unit of measure used to enter any paper size options.
Double CustomPaperHeightThe height of the new paper size, in units to match Units.
Double CustomPaperWidthThe width of the new paper size, in units to match Units.
Double PrinterMarginLeftThe size of the left printer margin, in units to match Units
PNSrv10 COM Interface
106 PNSrv10 COM Interface Object ReferenceIPNSession
Double PrinterMarginTopThe size of the top printer margin, in units to match Units.
Double PrinterMarginRightThe size of the right printer margin, in units to match Units.
Double PrinterMarginBottomThe size of the bottom printer margin, in units to match Units.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Units SectionName: Advanced Features
PropertyName: Units
varValue: VT_BSTR, one of the following:.01 Inches1 Millimeters
Ignored if the units are specified in the stringsbelow
CustomPaperHeight SectionName: Advanced Features
PropertyName: Custom Paper Height
varValue: VT_BSTR, one of the following:25-8000000 (hundredths of an inch)64-20000000 (tenths of a millimeter)0.250in-80000in (inches)0.640cm-200000.000cm (centimeters)
CustomPaperWidth SectionName: Advanced Features
PropertyName: Custom Paper Width
varValue: VT_BSTR, one of the following:25-8000000 (hundredths of an inch)64-20000000 (tenths of a millimeter)0.250in-80000in (inches)0.640cm-200000.000cm (centimeters)
PrinterMarginLeft SectionName: Advanced Features
PropertyName: Printer Area Margin Left
varValue: VT_BSTR, one of the following:0-100 (hundredths of an inch)0 -254 (tenths of a millimeter)0in-1in (inches)0cm-2.540cm (centimeters)
PrinterMarginTop SectionName: Advanced Features
PropertyName: Printer Area Margin Top
varValue: VT_BSTR, one of the following:
107
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
0-100 (hundredths of an inch)0 -254 (tenths of a millimeter)0in-1in (inches)0cm-2.540cm (centimeters)
PrinterMarginRight SectionName: Advanced Features
PropertyName: Printer Area Margin Right
varValue: VT_BSTR, one of the following:0-100 (hundredths of an inch)0 -254 (tenths of a millimeter)0in-1in (inches)0cm-2.540cm (centimeters)
PrinterMarginBottom SectionName: Advanced Features
PropertyName: Printer Area Margin Bottom
varValue: VT_BSTR, one of the following:0-100 (hundredths of an inch)0 -254 (tenths of a millimeter)0in-1in (inches)0cm-2.540cm (centimeters)
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'set custom paper on, set page size to 24"x36" with margins of 0.250"Session.SetCustomPaperOn(True)Session.SetCustomPaperOptions(pnUnits.pnUnitsEnglish, 24.0, 36.0, _ 0.125, 0.125, 0.125, 0.125)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// set custom paper on, set page size to 24"x36" with margins of 0.250"session.SetCustomPaperOn(True);session.SetCustomPaperOptions(pnUnits.pnUnitsEnglish, 24.0, 36.0, 0.125, 0.125, 0.125, 0.125);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetCustomPaperOn SetHardwareMargins ClearCustomPaperOptionsClearHardwareMargins SetProperty pnUnits
PNSrv10 COM Interface
108 PNSrv10 COM Interface Object ReferenceIPNSession
ClearCustomPaperOptions
Description
Clears the current custom paper options from the IPNSession object. When the custompaper options are not set through the IPNSession object, the default options for the Advanced Features tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
To clear only a single custom paper option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetCustomPaperOn and SetCustomPaperOptions for a list ofvalues.
Syntaxexpression.ClearCustomPaperOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearCustomPaperOptions()
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print Session.ClearCustomPaperOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearHardwareMargins SetCustomPaperOptions SetCustomPaperOnSetHardwareMargins SetProperty
SetDevmodeSettings
This method has been superseded by the methods ForcePrinterColorMode,ForcePrinterOrientation, ForcePrinterPaperSize and ForcePrinterResolution. Thismethod will still work but it is better to set only the individual options required.
109
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Description
Forces the printer to use the color mode, resolution, paper orientation and paper sizeoptions specified. In most cases not all of the options need to be set, often only theprinter resolution or color mode may be needed.
When these options are not set through the IPNSession object, the default options forthe Layout and Paper/Quality tabs in the PEERNET printer's Printing Preferences dialogwill be applied to the output file instead.
The printer options can also be set individually using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetDevmodeSettings(Orientation, Resolution, ColorMode, PaperSize)
where expression is an IPNSession object.
Parameters
pnPrinterOrientation OrientationA pnPrinterOrientation constant for the orientation of the paper.
pnPrinterResolution ResolutionA pnPrinterResolution constant for the resolution of the output file.
Boolean ColorModeThe color mode of the output file. Enter True for color and False for black and white.
String PaperSizeThe name of the paper size of the output file. Any paper size listed through theprinter user interface can be used here.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Orientation SectionName: Devmode settings
PropertyName: Orientation
varValue: VT_BSTR, one of the following:PortraitLandscape
Resolution SectionName: Devmode settings
PropertyName: Resolution
varValue: VT_I4, one of the following:1200720600400360300
PNSrv10 COM Interface
110 PNSrv10 COM Interface Object ReferenceIPNSession
254240200150120100756050
ColorMode SectionName: Devmode settings
PropertyName: Color
varValue: VT_BOOL, True for Color, False forMonochrome
PaperSize SectionName: Devmode settings
PropertyName: Paper Size
varValue: VT_BSTR, name of the paper size such as"Letter" or "A4"
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.SetDevmodeSettings(pnPrinterOrientation.pnPrinterOrientationLandscape, pnPrinterResolution.pnPrinterResolution400, True, "Legal" )
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
session.SetDevmodeSettings(pnPrinterOrientation.pnPrinterOrientationLandscape, pnPrinterResolution.pnPrinterResolution400, true, "Legal" );
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearDevmodeSettings ForcePrinterColorMode ForcePrinterOrientationForcePrinterPaperSize ForcePrinterResolution SetProperty pnPrinterColorModepnPrinterOrientation pnPrinterResolution
ClearDevmodeSettings
Description
111
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Clears the current printer options for color mode, resolution, paper orientation and papersize from the IPNSession object. When these options are not set through the IPNSessionobject, the default options for the Layout and Paper/Quality tabs in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To clear only a single printer option use the SetProperty call with the appropriate sectionand name arguments and pass an empty argument as the property value. See the Remarks section in SetDevmodeSettings for a list of values.
Clearing the printer options using this method will also clear any print options set usingany of the ForcePrinterColorMode, ForcePrinterOrientation, ForcePrinterPaperSize andForcePrinterResolution methods.
Syntaxexpression.ClearDevmodeSettings()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearDevmodeSettings()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearDevmodeSettings();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetDevmodeSettings SetProperty
SetEmailMessageOptions
Description
Sets the current email message options from the IPNSession object. These settings areonly applied when the email options are enabled. The type of email service, MAPI. SMTPor Lotus Notes (VIM) must also be configured using the SetEmailService method.
PNSrv10 COM Interface
112 PNSrv10 COM Interface Object ReferenceIPNSession
When these options are not set through the IPNSession object, the default options forthe Email tab in the PEERNET printer's Printing Preferences dialog will be applied to theoutput file instead.
To set a single email option use the SetProperty call with the appropriate arguments.See the Remarks below for a list of arguments.
Syntaxexpression.SetEmailMessageOptions(TO, CC, BCC, Subject, Message, Attachments)
where expression is an IPNSession object.
Parameters
String TOThe recipient's email address. You can enter more than one person by separating theemail addresses with semi-colons (;).
String CCEnter email addresses here if you want to carbon-copy the email to any recipients.You can enter more than one person by separating the email addresses with semi-colons (;). Pass an empty string to ignore the argument.
String BCCEnter email addresses here if you want to blind carbon-copy the email to anyrecipients. You can enter more than one person by separating the email addresseswith semi-colons (;). Pass an empty string to ignore the argument.
String SubjectThis is the title, or subject line of the email message.
String MessageThis is the default message text, or body of the e-mail.
String AttachmentsA list of files that will also be attached to every email message. The output file beingcreated is automatically attached to the email message, you do not need to add ithere. Use the full path to each additional file and separate filenames with semi-colons (;).
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
To SectionName: Email
PropertyName: To
varValue: VT_BSTR, as above
CC SectionName: Email
PropertyName: Cc
varValue: VT_BSTR, as above
BCC SectionName: Email
113
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
PropertyName: Bcc
varValue: VT_BSTR, as above
Subject SectionName: Email
PropertyName: Subject
varValue: VT_BSTR, as above
Message SectionName: Email
PropertyName: Note text
varValue: VT_BSTR, as above
Attachments SectionName: Email
PropertyName: Attachments
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Email settingsSession.SetEmailOn(True)Session.SetEmailMessageOptions("[email protected]", "[email protected]", _ "", "Test COM Email", "Please review the attached files.", _ "C:\Outgoing\Memo.doc")
If ( bUseMAPI ) Then Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, _ pnEmailDialog.pnEmailDialogClient) Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, True)Else ' SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, _ pnEmailDialog.pnEmailDialogStandard) Session.SetSMTPEmailService("[email protected]", "SMTPServerName")End If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Email settingsSession.SetEmailOn(True);Session.SetEmailMessageOptions("[email protected]", "[email protected]", "", "Test COM Email", "Please review the attached files.", "C:\\Outgoing\\Memo.doc");
if ( bUseMAPI ){ Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, pnEmailDialog.pnEmailDialogClient); Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, true);}
PNSrv10 COM Interface
114 PNSrv10 COM Interface Object ReferenceIPNSession
else{ // SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, pnEmailDialog.pnEmailDialogStandard); Session.SetSMTPEmailService("[email protected]", "SMTPServerName");}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetEmailOn SetEmailService SetMAPIEmailService SetSMTPEmailServiceSetVIMEmailService ClearEmailMessageOptions ClearEmailService SetProperty
ClearEmailMessageOptions
Description
Clears the current email message options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the Email tabin the PEERNET printer's Printing Preferences dialog will be applied to the output fileinstead.
To clear only a single email option use the SetProperty call with the appropriate sectionand name arguments and pass an empty argument as the property value. See the Remarks section in SetEmailOn and SetEmailMessageOptions for a list of values.
Syntaxexpression.ClearEmailMessageOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)SetGlobalVariablesInSession(Session)
...
' reset session for new print Session.ClearEmailMessageOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print
115
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
session.ClearEmailMessageOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearEmailService SetEmailMessageOptions SetEmailOn SetEmailServiceSetMAPIEmailService SetSMTPEmailService SetVIMEmailService SetProperty
SetEmailOn
Description
Enables or disables the email features. If email is enabled and there are no email optionsset through the IPNSession object the default options for the Email tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
The email features can also enabled or disabled using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetEmailOn(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableA Boolean value, True to turn on the email features, False to disable them.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Email
PropertyName: Enable
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Email settingsSession.SetEmailOn(True)Session.SetEmailMessageOptions("[email protected]", "[email protected]", _ "", "Test COM Email", "Please review the attached files.", _ "C:\Outgoing\Memo.doc")
PNSrv10 COM Interface
116 PNSrv10 COM Interface Object ReferenceIPNSession
If ( bUseMAPI ) Then Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, _ pnEmailDialog.pnEmailDialogClient) Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, True)Else ' SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, _ pnEmailDialog.pnEmailDialogStandard) Session.SetSMTPEmailService("[email protected]", "SMTPServerName")End If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Email settingsSession.SetEmailOn(True);Session.SetEmailMessageOptions("[email protected]", "[email protected]", "", "Test COM Email", "Please review the attached files.", "C:\\Outgoing\\Memo.doc");
if ( bUseMAPI ){ Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, pnEmailDialog.pnEmailDialogClient); Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, true);}else{ // SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, pnEmailDialog.pnEmailDialogStandard); Session.SetSMTPEmailService("[email protected]", "SMTPServerName");}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetEmailMessageOptions SetEmailService SetMAPIEmailServiceSetSMTPEmailService SetVIMEmailService ClearEmailMessageOptions ClearEmailServiceSetProperty
SetEmailService
Description
Configures which email service will be used.There are three types of email serviceavailable:
MAPI which is most most email clients, including Outlook Express, Outlook,Netscape Messenger, and Eudora. MAPI is a component on your computer thatallows you to send e-mail from within another Windows application. MAPI emailservice also needs to be configured by calling the SetMAPIEmailService method.
SMTP stands for Simple Mail Transfer Protocol, which is a protocol for sending e-mail messages between servers.This option does not require an email client to be
117
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
installed but it does require an email address and the name of an SMTP server.SMTP email service also needs to be configured by calling the SetSMTPEmailService method.
VIM, or Lotus Notes/Domino email system. The Lotus Notes email service alsoneeded to be configured by calling the SetVIMEmailService method.
These settings are only applied when the email options are enabled. If the email optionsare enabled and there are no email service options set through the IPNSession object thedefault options for the Advanced Email Settings... button on the Email tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
The email service options can also be set using the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetEmailService(Service, Dialog)
where expression is an IPNSession object.
Parameters
pnEmailService ServiceA pnEmailService constant for the email service to use.
pnEmailDialog DialogA pnEmailDialog constant that controls which email message dialog, if any, is shownwhen sending the email. Not all dialog options are available for all email services.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Service SectionName: Email Advanced
PropertyName: Service
varValue: VT_BSTR, one of the following:MAPISMTPVIM
Dialog SectionName: Email Advanced
PropertyName: Compose dialog
varValue: VT_BSTR, one of the following:StandardClientLotusAutosend
Examples
PNSrv10 COM Interface
118 PNSrv10 COM Interface Object ReferenceIPNSession
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Email settingsSession.SetEmailOn(True)Session.SetEmailMessageOptions("[email protected]", "[email protected]", _ "", "Test COM Email", "Please review the attached files.", _ "C:\Outgoing\Memo.doc")
If ( bUseMAPI ) Then Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, _ pnEmailDialog.pnEmailDialogClient) Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, True)Else ' SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, _ pnEmailDialog.pnEmailDialogStandard) Session.SetSMTPEmailService("[email protected]", "SMTPServerName")End If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Email settingsSession.SetEmailOn(True);Session.SetEmailMessageOptions("[email protected]", "[email protected]", "", "Test COM Email", "Please review the attached files.", "C:\\Outgoing\\Memo.doc");
if ( bUseMAPI ){ Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, pnEmailDialog.pnEmailDialogClient); Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, true);}else{ // SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, pnEmailDialog.pnEmailDialogStandard); Session.SetSMTPEmailService("[email protected]", "SMTPServerName");}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetEmailOn SetEmailMessageOptions SetMAPIEmailServiceSetSMTPEmailService SetVIMEmailService ClearEmailService ClearEmailMessageOptionsSetProperty pnEmailService pnEmailDialog
119
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
ClearEmailService
Description
Clears the email service options from the IPNSession object. When these options are notset through the IPNSession object, the default options for the Advanced Email Options...button on the Email tab in the PEERNET printer's Printing Preferences dialog will be usedto try and email the output file instead.
To clear a only a single email service option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetEmailService, SetMAPIEmailService, SetSMTPEmailServiceand SetVIMEmailService for a list of values.
Syntaxexpression.ClearEmailService(Service)
where expression is an IPNSession object.
Parameters
pnEmailService ServiceA pnEmailService constant for the email service (MAPI, SMTP,VIM) to clear.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearEmailService(pnEmailService.pnEmailServiceSMTP)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);SetGlobalVariablesInSession(session);
...
// reset session for new print session.ClearEmailService(pnEmailService.pnEmailServiceSMTP);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearEmailMessageOptions SetEmailOn SetEmailMessageOptionsSetEmailService SetMAPIEmailService SetSMTPEmailService SetVIMEmailServiceSetProperty pnEmailService
PNSrv10 COM Interface
120 PNSrv10 COM Interface Object ReferenceIPNSession
SetErrorReporting
Description
Sets error logging and debug tracing options. Enabling the debug tracing options canslow down the printing process considerably.
When these options are not set through the IPNSession object, the default options forthe Error Reporting tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
The error reporting and debug tracing options can also be set individually using the SetProperty call with the appropriate arguments. See the Remarks below for a list ofarguments.
Syntaxexpression.SetErrorReporting(EnableLogging, LogFilePath, EnableTracing)
where expression is an IPNSession object.
Parameters
Boolean EnableLoggingSet to True to enable error logging or False to turn error logging off.
String LogFilePathPass the fully qualified path to an error logging file, or an empty string to create thelogging file in the Documents folder of the currently logged in user.
Boolean EnableTracingSet to True to create a detailed trace file in the Windows temporary folder for thecurrently logged in user. The name of the trace file is different for each PEERNETprinter. See the User Guide for the printer being used for more information abouterror logging and trace files.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
EnableLogging SectionName: Error Reporting
PropertyName: Enable
varValue: VT_BOOL
LogFilePath SectionName: Error Reporting
PropertyName: Log filepath
varValue: VT_BSTR, as above
EnableTracing SectionName: Error Reporting
PropertyName: Trace
varValue: VT_BOOL
121
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Log errors, but don't create detailed trace informationSession.SetErrorReporting(True, "C:\TIFFErrorLogs\MyErrors.log", "False")
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// Log errors, but don't create detailed trace informationsession.SetErrorReporting(True, "C:\\TIFFErrorLogs\\MyErrors.log", "False");
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetMessageBoxAlerts ClearErrorReporting ClearMessageBoxAlerts SetProperty
ClearErrorReporting
Description
Clears any error reporting and logging options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the ErrorReporting tab in the PEERNET printer's Printing Preferences dialog will be used instead.
To clear a only a single error reporting option use the SetProperty call with theappropriate section and name arguments and pass an empty argument as the propertyvalue. See the Remarks section in SetErrorReporting for a list of values.
Syntaxexpression.ClearErrorReporting()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearErrorReporting()
PNSrv10 COM Interface
122 PNSrv10 COM Interface Object ReferenceIPNSession
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);...
// reset session for new print session.ClearErrorReporting();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearMessageBoxAlerts SetErrorReporting SetMessageBoxAlerts SetProperty
SetFaxModeOn
Description
Enables or disables the fax mode options. If fax mode is enabled and there are no faxmode options set through the IPNSession object the default options for the Fax/TIFF orthe Fax tab in the PEERNET printer's Printing Preferences dialog will be applied to theoutput file instead.
Fax mode can also enabled or disabled using the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetFaxModeOn(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableSet True to enable fax mode options, False to disable the fax options.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Image Options
PropertyName: Fax
varValue: VT_BOOL
Examples
123
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'set fax modeSession.SetFaxModeOn(True)Session.SetFaxOptions(pnFaxProfile.pnFaxProfileF, _ pnFaxResolution.pnFaxResolution204x196, _ pnFaxPaperWidth.pnFaxPaperWidthLetter, _ pnFaxPaperHeight.pnFaxPaperHeightFixed, _ pnFaxPageScaling.pnFaxPageScalingFitToPage, _ pnFaxPageScalingHAlign.pnFaxPageScalingHAlignMiddle, _ pnFaxPageScalingVAlign.pnFaxPageScalingVAlignMiddle, _ True, _ True, _ True)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// set fax modesession.SetFaxModeOn(true);session.SetFaxOptions(pnFaxProfile.pnFaxProfileF, pnFaxResolution.pnFaxResolution204x196, pnFaxPaperWidth.pnFaxPaperWidthLetter, pnFaxPaperHeight.pnFaxPaperHeightFixed, pnFaxPageScaling.pnFaxPageScalingFitToPage, pnFaxPageScalingHAlign.pnFaxPageScalingHAlignMiddle, pnFaxPageScalingVAlign.pnFaxPageScalingVAlignMiddle, true, true, true);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetFaxOptions SetTIFFAdvancedOptions ClearFaxOptionsClearTIFFAdvancedOptions SetProperty
SetFaxOptions
Description
Sets fax options on the IPNSession object. When fax mode is enabled and there are nofax mode options set through the IPNSession object, the default options for the FaxMode section on the Fax/TIFF or the Fax tab in the PEERNET printer's PrintingPreferences dialog will be applied to the output file instead.
To set a single fax option use the SetProperty call with the appropriate arguments. Seethe Remarks below for a list of arguments.
Syntax
PNSrv10 COM Interface
124 PNSrv10 COM Interface Object ReferenceIPNSession
expression.SetFaxOptions(FaxProfile, FaxResolution, FaxPaperWidth, FaxPaperHeight, FaxPageScaling, FaxPageHAlign, FaxPageVAlign, FaxPageShrinkIfLarger, FaxPageAutoRotate,FaxPageMaintainAspect)
where expression is an IPNSession object.
Parameters
pnFaxProfile FaxPofileA pnFaxProfile constant for the fax format profile to to use.
pnFaxResolution FaxResolutionA pnFaxResolution constant for the fax resolution to create. The fax format profilebeing used determines what resolutions are valid. Not all resolutions are valid with allfax format profiles.
pnFaxPaperWidth FaxPaperWidthA pnFaxPaperWidth constant for the width of the fax paper to be used when creatingthe faxable image.
pnFaxPaperHeight FaxPaperHeightA pnFaxPaperHeight constant to set the height of the fax paper.
pnFaxPageScaling FaxPageScalingA pnFaxPageScaling constant to determine how the page is scaled to the size of thefax paper.
pnFaxPageScalingHAlign FaxPageHAlignA pnFaxPageScalingHAlign constant to determine how to horizontally align the pageon the fax paper.
pnFaxPageScalingVAlign FaxPageVAlignA pnFaxPageScalingVAlign constant to determine how to vertically align the page onthe fax paper.
Boolean FaxPageShrinkIfLargerSet to True to automatically shrink the page it it is larger than the fax paper size.
Boolean FaxPageAutoRotateSet as True to automatically rotate the page if it will fit on the fax paper withoutscaling.
Boolean FaxPageMaintainAspectSet as True to prevent distortion when scaling larger or smaller pages. When thisoption is on, the height and width of the page change in relation to one another.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
FaxProfile SectionName: Image Options
PropertyName: Fax Profile
varValue: VT_I4, one of the following:0 = Profile F1 = Profile S
125
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
2 = Profile C
FaxResolution SectionName: Image Options
PropertyName: Fax Resolution
varValue: VT_I4, one of the followingresolutions:
0 = 200 x 100, Profile S, F1 = 200 x 200, Profile S, F, C2 = 204 x 98, Profile S, F3 = 204 x 196, Profile S, F4 = 300 x 300, Profile F, C5 = 400 x 400, Profile F, C6 = 408 x 391, Profile F7 = 204 x 391, Profile F8 = 300 x 600, Profile F9 = 400 x 800, Profile F10 = 600 x 600, Profile F, C11 = 600 x 1200, Profile F12 = 1200 x 1200, Profile F, C13 = 100 x 100, Profile F, C
FaxPaperWidth SectionName: Image Options
PropertyName: Fax Paper Width
varValue: VT_I4, one of the following:0 = Letter1 = Legal2 = A4 (ISO)3 = B4 (ISO)4 = A3 (ISO)
FaxPaperHeight SectionName: Image Options
PropertyName: Fax Paper Height
varValue: VT_I4, one of the following:0 = Variable Height1 = Fixed Height
FaxPageScaling SectionName: Image Options
PropertyName: Fax Page Scaling
varValue: VT_I4, one of the following:0 = Fit to Page1 = Actual Size
FaxPageHAlign SectionName: Image Options
PropertyName: Fax Page Scaling H Align
varValue: VT_BSTR, one of the following:LeftMiddleRight
PNSrv10 COM Interface
126 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
FaxPageVAlign SectionName: Image Options
PropertyName: Fax Page Scaling V Align
varValue: VT_BSTR, one of the following:TopMiddleBottom
FaxPageShrinkIfLarger SectionName: Image Options
PropertyName: Fax Page Scaling Shrink Larger
varValue: VT_BOOL
FaxPageAutoRotate SectionName: Image Options
PropertyName: Fax Page Scaling Auto Rotate
varValue: VT_BOOL
FaxPageMaintainAspect SectionName: Image Options
PropertyName: Fax Page Scaling Lock Aspect Ratio
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'set fax modeSession.SetFaxModeOn(True)Session.SetFaxOptions(pnFaxProfile.pnFaxProfileF, pnFaxResolution.pnFaxResolution204x196, _ pnFaxPaperWidth.pnFaxPaperWidthLetter, _ pnFaxPaperHeight.pnFaxPaperHeightFixed, _ pnFaxPageScaling.pnFaxPageScalingFitToPage, _ pnFaxPageScalingHAlign.pnFaxPageScalingHAlignMiddle, _ pnFaxPageScalingVAlign.pnFaxPageScalingVAlignMiddle, _ True, True, True)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// set fax modesession.SetFaxModeOn(true);session.SetFaxOptions(pnFaxProfile.pnFaxProfileF, pnFaxResolution.pnFaxResolution204x196, pnFaxPaperWidth.pnFaxPaperWidthLetter, pnFaxPaperHeight.pnFaxPaperHeightFixed, pnFaxPageScaling.pnFaxPageScalingFitToPage, pnFaxPageScalingHAlign.pnFaxPageScalingHAlignMiddle, pnFaxPageScalingVAlign.pnFaxPageScalingVAlignMiddle, true, true, true);
127
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetFaxModeOn SetTIFFAdvancedOptions ClearFaxOptionsClearTIFFAdvancedOptions SetProperty pnFaxProfile pnFaxResolution pnFaxPaperWidthpnFaxPaperHeight pnFaxPageScaling pnFaxPageScalingHAlign pnFaxPageScalingVAlign
ClearFaxOptions
Description
Clears any fax options from the IPNSession object. When these options are not setthrough the IPNSession object, the default options for the Fax Mode section on the Fax/TIFF or the Fax tab in the PEERNET printer's Printing Preferences dialog will be applied tothe output file instead.
To clear a single fax option use the SetProperty call with the appropriate section andname arguments and pass an empty argument as the property value. See the Remarkssection in SetFaxModeOn and SetFaxOptions for a list of values.
Syntaxexpression.ClearFaxOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearFaxOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearFaxOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearTIFFAdvancedOptions SetFaxModeOn SetFaxOptionsSetTIFFAdvancedOptions SetProperty
PNSrv10 COM Interface
128 PNSrv10 COM Interface Object ReferenceIPNSession
SetFileNamingOptions
Beginning with version 9.0 of the printer drivers, this method has been supersededby SetSaveOptions. This method will still work when called using Enter value and PDFImage Printer but an error is thrown when used with Raster Image Printer.
Description
Sets file naming options on the IPNSession object. When these options are not setthrough the IPNSession object, the default options for the Save tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To set a single file naming option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
For a more detailed explanation of the file naming options, see the User Guide for the PEERNET printer being used.
Syntaxexpression.SetFileNamingOptions(Directory, BaseFilename, Multipage, Append, UseJobID, PromptForFileName, OverwriteAlways, RemoveExt, RemoveProdName,DeleteAtEnd)
where expression is an IPNSession object.
Parameters
String DirectoryPass the fully qualified path to the directory for storing the output your files. If thisstring is empty, the Documents folder of the currently logged in user is used to storethe files.
String BaseFilenameThis is the base filename for your output file. The base filename excludes anydirectory path and file extension. If you want your output files to always be savedunder the same filename, enter that name here.If this field is empty the print jobname the printing application uses when submitting the file to the printer is usedinstead.
Boolean MultipageSet this to True to create multi-paged output files, or False to create serializedoutput files. Not all output formats in all printers support multi-paged output.
Boolean AppendSet this to True to append, or concatenate, the pages to an existing output file or, ifyou are creating serialized files, an existing sequence of files.
Boolean UseJobIDA JobID is associated with every printer and is initially set to zero. It is automaticallyincremented by the printer at the start of every print job.The JobID is often used toensure that all files created have unique names. It is also used to determine whichnaming profile to use.
Boolean PromptForFileNameSet to True to show the printer's Save Image dialog prompt, or False to hide theprompt and use the Directroy and BaseFilename settings to create the filename.
129
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Boolean OverwriteAlwaysSet to True to overwrite existing files without prompting, or False to be prompted toconfirm the overwrite action or to provide a new filename.
Boolean bRemoveExtSet to True to automatically remove any file extension passed to the printer as partof the filename.
Boolean RemoveProdNameSet to True to automatically remove any product names that are added to theprinted filename by the printing application.Product names are any text that precedesthe following characters: a space, a dash and a space (" - ").
Boolean DeleteAtEndSet to True to automatically delete all output files at the end of the print job, afterany final Run command.This option is useful if you are want to send the output byemail without leaving any local copies.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Directory SectionName: Save
PropertyName: Output directory
varValue: VT_BSTR, as above
BaseFilename SectionName: Save
PropertyName: Output filename
varValue: VT_BSTR, as above
Multipage SectionName: Save
PropertyName: Output format
varValue: VT_BSTR, one of the following:Multipage, Serialized
Append SectionName: Save
PropertyName: Append
varValue: VT_BOOL
UseJobID SectionName: Save
PropertyName: Use JobID
varValue: VT_BOOL
PromptForFileName SectionName: Save
PropertyName: Prompt
varValue: VT_BOOL
OverwriteAlways SectionName: Save
PropertyName: Overwrite
PNSrv10 COM Interface
130 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
varValue: VT_BOOL
RemoveExt SectionName: Save
PropertyName: Remove filename extension
varValue: VT_BOOL
RemoveProdName SectionName: Save
PropertyName: Remove product name
varValue: VT_BOOL
DeleteAtEnd SectionName: Save
PropertyName: Delete files
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
bMultipage = cbDoMultipage.CheckedbAppend = cbAppendTogether.Checked
' set name and save location, create multipage tiff and append all into a single fileSession.SetFileNamingOptions("C:\TIFFOutput\", "TIFFReport", bMultipage, bAppend, _ False, False, True, True, True, False)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
bMultipage = cbDoMultipage.Checked;bAppend = cbAppendTogether.Checked;
// set name and save location, create multipage tiff and append all into a single filesession.SetFileNamingOptions("C:\\TIFFOutput\\","TIFFReport", bMultipage, bAppend, false, false, true, true, true, false);
Supported Printers: TIFF Image Printer 10.0, PDF Image Printer 10.0
See Also: SetSaveOptions SetNamingProfileFormat ClearSaveOptionsClearFileNamingOptions ClearNamingProfileFormat SetProperty
131
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
ClearFileNamingOptions
Beginning with version 9.0 of the printer drivers, this method has been supersededby ClearSaveOptions. This method will still work when called using Enter value andPDF Image Printer but an error is thrown when used with Raster Image Printer.
Description
Clears any file naming and formatting options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the the Savetab in the PEERNET printer's Printing Preferences dialog will be applied to the output fileinstead.
To clear a single file naming option use the SetProperty call with the appropriate sectionand name arguments and pass an empty argument as the property value.
Syntaxexpression.ClearFileNamingOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearFileNamingOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearFileNamingOptions();
Supported Printers: TIFF Image Printer 10.0, PDF Image Printer 10.0
See Also: ClearSaveOptions ClearNamingProfileFormat SetSaveOptionsSetFileNamingOptions SetNamingProfileFormat SetProperty
SetHardwareMargins
Description
Sets the hardware margin options from the IPNSession object. When these options are
PNSrv10 COM Interface
132 PNSrv10 COM Interface Object ReferenceIPNSession
not set through the IPNSession object, the default options for the hardware margins inthe Advanced Features tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
The hardware margins option allows you to customize the size of the printer-suppliededge on your outputted files. Hardware margins cannot be larger than 1.00in (2.54cm)on each side of the paper. You can enter units with up to three digits of accuracy, or toan eighth of an inch (0.125in or 0.318cm).
To clear a single hardware margin option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
For a more detailed explanation of hardware margins, see the User Guide for the PEERNET printer being used.
Syntaxexpression.SetHardwareMargins(Units, HardwareMarginLeftRight, HardwareMarginTopBottom)
where expression is an IPNSession object.
Parameters
pnUnits UnitsA pnUnits constant for the unit of measure used to enter any paper size options.
Double HardwareMarginLeftRightThe left and right hardwarre margin settings in units to match Units.
Double HardwareMarginTopBottomThe top and bottom hardware margin settings in units to match Units.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Units SectionName: Advanced Features
PropertyName: Units
varValue: VT_BSTR, one of the following:.01 Inches1 Millimeters
Ignored if the units are specified inthe strings below
HardwareMarginLeftRight SectionName: Advanced Features
PropertyName: Hardware Margin Left
varValue: VT_BSTR, one of the followingranges:
0-100 (hundredths of an inch)0-254 (tenths of a millimeter)0.0in-1.0in (inches)0.0cm-2.540cm (centimeters)
133
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
HardwareMarginTopBottom SectionName: Advanced Features
PropertyName: Hardware Margin Top
varValue: VT_BSTR, one of the followingranges:
0-100 (hundredths of an inch)0-254 (tenths of a millimeter)0.0in-1.0in (inches)0.0cm-2.540cm (centimeters)
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)SetGlobalVariablesInSession(Session)
Session.SetHardwareMargins(pnUnits.pnUnitsEnglish, 0.125, 0.125)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);SetGlobalVariablesInSession(session);
session.SetHardwareMargins(pnUnits.pnUnitsEnglish, 0.125, 0.125);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetCustomPaperOn SetCustomPaperOptions ClearHardwareMarginsClearCustomPaperOptions SetProperty pnUnits
ClearHardwareMargins
Description
Clears any hardware margin options from the IPNSession object. When these options arenot set through the IPNSession object, the default options for the hardware margins inthe Advanced Features tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
To clear a single hardware margin option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetHardwareMargins for a list of values.
Syntax
PNSrv10 COM Interface
134 PNSrv10 COM Interface Object ReferenceIPNSession
expression.ClearHardwareMargins()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearHardwareMargins()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearHardwareMargins();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearCustomPaperOptions SetHardwareMargins SetCustomPaperOnSetCustomPaperOptions SetProperty
SetImageCopyToOn
Description
Enables or disables the Copy To options. When these options are not set through the IPNSession object the default options for Copy To in the Image Processing tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
The Copy To option can also be enabled or disabled using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetImageCopyToOn(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableSet True to enable any Copy To options, False to disable them.
Remarks
135
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Processing
PropertyName: Copy
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'copy page to new paper size'Center letter page on legal 11x17 with 1/8' marginsSession.SetImageCopyToOn(True)Session.SetImageCopyToOptions(pnUnits.pnUnitsEnglish, _ 11.0, 17.0, _ 0.125, 0.125, 0.125, 0.125, _ pnImageCopyScaling.pnImageCopyScalingFitToPage, _ pnImageCopyScalingHAlign.pnImageCopyScalingHAlignMiddle, _ pnImageCopyScalingVAlign.pnImageCopyScalingVAlignMiddle, _ True, True)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// copy page to new paper size// Center letter page on legal 11x17 with 1/8" marginssession.SetImageCopyToOn(true);session.SetImageCopyToOptions(pnUnits.pnUnitsEnglish, 11.0, 17.0, 0.125, 0.125, 0.125, 0.125, pnImageCopyScaling.pnImageCopyScalingFitToPage, pnImageCopyScalingHAlign.pnImageCopyScalingHAlignMiddle, pnImageCopyScalingVAlign.pnImageCopyScalingVAlignMiddle, true, true) ;
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetImageCopyToOptions SetResamplingOn SetResamplingOptionsClearImageCopyToOptions ClearResamplingOptions SetProperty
SetImageCopyToOptions
Description
PNSrv10 COM Interface
136 PNSrv10 COM Interface Object ReferenceIPNSession
Sets the Copy To options on the IPNSession object. The concept of image copying issimilar to enlarging or shrinking a page using a photocopier, with the added ability toposition the page on the new image using the scaling and alignment options. You canenter units with up to three digits of accuracy, or to an eighth of an inch (0.125in or0.318cm).
These settings are only applied when the Copy To options is enabled. The combined Leftand Right image area margins must be less than the Width of the new page. Thecombined Top and Bottom image area margins must be less than the Height of the newpage.
If the Copy To option is enabled and there are no Copy To options set through the IPNSession object the default options for Copy To in the Image Processing tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
To set a single Copy To option use the SetProperty call with the appropriate arguments.See the Remarks below for a list of arguments.
For a more detailed explanation of the copy to feature, see the User Guide for the PEERNET printer being used.
Syntaxexpression.SetImageCopyToOn(Units, CopyToWidth, CopyToHeight, CopyToImageMarginLeft, CopyToImageMarginTop, CopyToImageMarginRight, CopyToImageMarginBottom, ImageCopyScaling, ImageCopyHAlign, ImageCopyVAlign, ImageCopyShrinkIfLarger, ImageCopyMaintainAspect)
where expression is an IPNSession object.
Parameters
pnUnits UnitsA pnUnits constant for the unit of measure used to enter any Copy To image sizeoptions.
Double CopyToWidthThe width of the new image in units to match Units.
Double CopyToHeight The height of the new image in units to match Units.
Double CopyToImageMarginLeftThe left margin in units to match Units.
Double CopyToImageMarginTopThe top margin in units to match Units.
Double CopyToImageMarginRight The right margin in units to match Units.
Double CopyToImageMarginBottomThe bottom matgin in units to match Units.
pnImageCopyScaling ImageCopyScalingA pnImageCopyScaling constant to determine how the page is scaled to fit the newimage size.
137
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
pnImageCopyScalingHAlign ImageCopyHAlignA pnImageCopyScalingHAlign constant for how to horizontally align the page in thenew image.
pnImageCopyScalingVAlign ImageCopyVAlignA pnImageCopyScalingVAlign constant for how to vertically align the page in the newimage.
Boolean ImageCopyShrinkIfLargerEnter True to shrink the page to fit inside the new image size if the original page sizeis larger.
Boolean ImageCopyMaintainAspectEnter True to prevent distortion when scaling larger or smaller image to differentimage sizes.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Units SectionName: Processing
PropertyName: Units
varValue: VT_BSTR, one of the following:.01 Inches1 Millimeters
Ignored if the units are specified inthe strings below
CopyToWidth SectionName: Processing
PropertyName: Copy to width
varValue: VT_BSTR, one of the followingranges:
0-8000000 (hundredths of aninch)0-20000000 (tenths of amillimeter)0in-80000in (inches)0cm-200000.000cm(centimeters)
CopyToHeight SectionName: Processing
PropertyName: Copy to height
varValue: VT_BSTR, one of the followingranges:
0-8000000 (hundredths of aninch)0-20000000 (tenths of amillimeter)0in-80000in (inches)
PNSrv10 COM Interface
138 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
0cm-200000.000cm(centimeters)
CopyToImageMarginLeft SectionName: Processing
PropertyName: Copy to IAM Left
varValue: VT_BSTR, one of the followingranges:
0-8000000 (hundredths of aninch)0-20000000 (tenths of amillimeter)0in-80000in (inches)0cm-200000.000cm(centimeters)
CopyToImageMarginTop SectionName: Processing
PropertyName: Copy to IAM Top
varValue: VT_BSTR, one of the followingranges:
0-8000000 (hundredths of aninch)0-20000000 (tenths of amillimeter)0in-80000in (inches)0cm-200000.000cm(centimeters)
CopyToImageMarginRight SectionName: Processing
PropertyName: Copy to IAM Right
varValue: VT_BSTR, one of the followingranges:
0-8000000 (hundredths of aninch)0-20000000 (tenths of amillimeter)0in-80000in (inches)0cm-200000.000cm(centimeters)
CopyToImageMarginBottom SectionName: Processing
PropertyName: Copy to IAM Bottom
varValue: VT_BSTR, one of the followingranges:
0-8000000 (hundredths of aninch)0-20000000 (tenths of amillimeter)0in-80000in (inches)
139
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
0cm-200000.000cm(centimeters)
ImageCopyScaling SectionName: Processing
PropertyName: Copy Page Scaling
varValue: VT_UI4, one of the following:0 = Fit to page1 = Actual Size
ImageCopyHAlign SectionName: Processing
PropertyName: Copy H Align
varValue: VT_BSTR, one of the following:LeftMiddleRight
ImageCopyVAlign SectionName: Processing
PropertyName: Copy V Align
varValue: VT_BSTR, one of the following:TopMiddleBottom
ImageCopyShrinkIfLarger SectionName: Processing
PropertyName: Copy Page Scaling Shrink Larger
varValue: VT_BOOL
ImageCopyMaintainAspect SectionName: Processing
PropertyName: Copy Page Lock Aspect Ratio
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'copy page to new paper size'Center letter page on legal 11x17 with 1/8' marginsSession.SetImageCopyToOn(True)Session.SetImageCopyToOptions(pnUnits.pnUnitsEnglish, _ 11.0, 17.0, _ 0.125, 0.125, 0.125, 0.125, _ pnImageCopyScaling.pnImageCopyScalingFitToPage, _ pnImageCopyScalingHAlign.pnImageCopyScalingHAlignMiddle, _ pnImageCopyScalingVAlign.pnImageCopyScalingVAlignMiddle, _ True, True)
PNSrv10 COM Interface
140 PNSrv10 COM Interface Object ReferenceIPNSession
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// copy page to new paper size// Center letter page on legal 11x17 with 1/8" marginssession.SetImageCopyToOn(true);session.SetImageCopyToOptions(pnUnits.pnUnitsEnglish, 11.0, 17.0, 0.125, 0.125, 0.125, 0.125, pnImageCopyScaling.pnImageCopyScalingFitToPage, pnImageCopyScalingHAlign.pnImageCopyScalingHAlignMiddle, pnImageCopyScalingVAlign.pnImageCopyScalingVAlignMiddle, true, true) ;
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetImageCopyOn SetResamplingOn SetResamplingOptionsClearImageCopyToOptions ClearResamplingOptions SetProperty pnUnitspnImageCopyScaling pnImageCopyScalingHAlign pnImageCopyScalingVAlign
ClearImageCopyToOptions
Description
Clears any Copy To options from the IPNSession object. When these options are not setthrough the IPNSession object, the default options for the Copy To options in the ImageProcessing tab in the PEERNET printer's Printing Preferences dialog will be applied to theoutput file instead.
To clear a single Copy To option use the SetProperty call with the appropriate sectionand name arguments and pass an empty argument as the property value. See the Remarks section in SetImageCopyToOn and SetImageCopyToOptions for a list ofvalues.
Syntaxexpression.ClearCopyToOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearCopyToOptions()
141
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearCopyToOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearResamplingOptions SetImageCopyToOn SetImageCopyToOptionsSetResamplingOn SetResamplingOptions SetProperty
SetJPEGCompressionOptions
Description
Sets the compression methods to use when storing color or greyscale JPEG images. Theactual compression method used on each page will depend on any color reductionmethod chosen through the SetSaveOptions method. Other output options used, suchas SetFaxImageOptions may override any settings chosen here.
To set only a single compression option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetJPEGCompressionOptions(Color, Greyscale)
where expression is a IPNSession object.
Parameters
pnColorCompressionMethod ColorA pnColorCompressionMethod constant for the compression method to use for colorimages. Not all of the constants are valid for this method, only pnColorCompressionJPEGHighQuality, pnColorCompressionJPEGMediumQuality, andpnColorCompressionJPEGLowQuality apply. If an invalid constant is passed thedefault compression of pnColorCompressionJPEGMediumQuality is used.
pnGreyscaleCompressionMethod GreyscaleA pnGreyscaleCompressionMethod constant for the compression method to use forgreyscale images. Not all of the constants are valid for this method, only pnGreyscaleCompressionJPEGHighQuality,pnGreyscaleCompressionJPEGMediumQuality, andpnGreyscaleCompressionJPEGLowQuality apply. If an invalid constant is passed thedefault compression of pnGreyscaleCompressionJPEGMediumQuality is used.
Remarks
PNSrv10 COM Interface
142 PNSrv10 COM Interface Object ReferenceIPNSession
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Color SectionName: JPEG File Format
PropertyName: Color compression
varValue: VT_BSTR, one of the following:High QualityMedium QualityLow Quality
Greyscale SectionName: JPEG File Format
PropertyName: Greyscale compression
varValue: VT_BSTR, one of the following:High QualityMedium QualityLow Quality
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Set the file output options' Reduce to greyscale, dithering has no effectSession.SetSaveOptions("C:\JPEGOutput\", "JPEGReport", _ pnOutputFileFormatJPEG, False, _ pnColorReductionGreyscale, pnDitheringHalftone, _ False, False, True, True, True, False)
'set JPEG compression options - medium for color and high for greyscaleSession.SetJPEGCompressionOptions(pnColorCompressionMethod.pnColorCompressionJPEGMediumQuality, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionJPEGHighQuality)
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Reduce to greyscale, dithering has no effectsession.SetSaveOptions("C:\\JPEGOutput\\", "JPEGReport", pnOutputFileFormatJPEG, false, pnColorReductionGreyscale, pnDitheringHalftone, false, false, true, true, true, false)
// set JPEG compression options - medium for color and high for greyscalesession.SetJPEGCompressionOptions(pnColorCompressionMethod.pnColorCompressionJPEGMediumQuality, pnGreyscaleCompressionMethod.pnGreyscaleCompressionJPEGHighQuality);
Supported Printers: Raster Image Printer 10.0
See Also: ClearJPEGCompressionOptions SetProperty pnColorColorCompressionMethod
143
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
pnGreyscaleCompressionMethod
ClearJPEGCompressionOptions
Description
Clears the compression options for color and grayscale JPEG images from the IPNSessionobject. When the JPEG compression options are not set through the IPNSession object,the default options for JPEG compression from the Compression tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To clear only a single compression option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetJPEGCompressionOptions for a list of values.
Syntaxexpression.ClearJPEGCompressionOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearJPEGCompressionOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearJPEGCompressionOptions();
Supported Printers: Raster Image Printer 10.0
See Also: SetJPEGCompressionOptions SetProperty
SetLandscapeWatermarkOptions
Description
Sets any landscape watermark options in the IPNSession object. If watermarking is
PNSrv10 COM Interface
144 PNSrv10 COM Interface Object ReferenceIPNSession
enabled and these options are not set through the IPNSession object, the default optionsfor landscape watermark images on the Watermark tab in the PEERNET printer's PrintingPreferences dialog will be applied to the output file instead.
Watermark images can be color, greyscale or black and white, but the image will beconverted to greyscale before being placed on the page. If your watermark image hasalready been lightened set LandscapeBrightness to 0. If you are starting with a black andwhite or color image you can use the LandscapeBrightness setting to adjust thebrightness of the watermark image.
To clear a single watermark option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetLandscapeWatermarkOptions(LandscapePathtoImage, LandscapePosition, LandscapeBrightness)
where expression is an IPNSession object.
Parameters
String LandscapePathtoImage
The full path to the image file to be used as the watermark on landscape pages. Validfile types are *.bmp, *.jpg. *.png, and *.tif.
pnWatermarkPosition LandscapePositionA pnWatermarkPosition constant to determine how the watermark image is placed onthe page.
Integer LandscapeBrightnessAn integer between -100 and - 100 that determines the brightness level of thewatermark image.
Range Action
-100 to -1 Darkens the image, with -100 being black.
0 No change
1 to 100 Lightens the image, with 100 being white.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
LandscapePathtoImage SectionName: Watermark
PropertyName: Landscape image
varValue: VT_BSTR, as above
LandscapePosition SectionName: Watermark
PropertyName: Landscape position
varValue: VT_BTR, one of the following:Stretch, Tile, Center
LandscapeBrightness SectionName: Watermark
145
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
PropertyName: Landscape brightness
varValue: VT_I4Range: -100 to 100
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
If bWatermarkEnabled Then
' apply landscape and portrait watermark centered on all pages ' image is lightened 25% Session.SetWatermarkOptionsOn(True, False) Session.SetPortraitWatermarkOptions("C:\TIFFSource\PortraitWatermark.png", _ pnWatermarkPosition.pnWatermarkCenter, 25) Session.SetLandscapeWatermarkOptions("C:\TIFFSource\LandWatermark.png", _ pnWatermarkPosition.pnWatermarkCenter, 25)End If
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
if (bWatermarkEnabled){ // apply landscape and portrait watermark centered on all pages // image lightened 25% session.SetWatermarkOptionsOn(true, false); session.SetPortraitWatermarkOptions("C:\\TIFFSource\\PortraitWatermark.png", pnWatermarkPosition.pnWatermarkCenter, 25); session.SetLandscapeWatermarkOptions("C:\\TIFFSource\\LandWatermark.png", pnWatermarkPosition.pnWatermarkCenter, 25);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetWatermarkOptionsOn SetPortraitWatermarkOptions ClearWatermarkOptionsSetProperty pnWatermarkPosition
SetPortraitWatermarkOptions
Description
Sets any portrait watermark options in the IPNSession object. If watermarking is enabledand these options are not set through the IPNSession object, the default options forportrait watermark images on the Watermark tab in the PEERNET printer's PrintingPreferences dialog will be applied to the output file instead.
PNSrv10 COM Interface
146 PNSrv10 COM Interface Object ReferenceIPNSession
Watermark images can be color, greyscale or black and white, but the image will beconverted to greyscale before being placed on the page. If your watermark image hasalready been lightened set PortraitBrightness to 0. If you are starting with a black andwhite or color image you can use the PortraitBrightness setting to adjust the brightnessof the watermark image.
To clear a single watermark option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetPortraitWatermarkOptions(PortraitPathtoImage, PortraitPosition, PortraitBrightness)
where expression is an IPNSession object.
Parameters
String PortraitPathtoImageThe full path to the image file to be used as the watermark on landscape pages. Validfile types are *.bmp, *.jpg. *.png, and *.tif.
pnWatermarkPosition PortraitPositionA pnWatermarkPosition constant to determine how the watermark image is placed onthe page.
Integer PortraitBrightnessA value between -100 and - 100 that determines the brightness level of thewatermark image.
Range Action
-100 to -1 Darkens the image, with -100 being black.
0 No change
1 to 100 Lightens the image, with 100 being white.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
PortraitPathtoImage SectionName: Watermark
PropertyName: Portrait image
varValue: VT_BSTR, as above
PortraitPosition SectionName: Watermark
PropertyName: Portrait position
varValue: VT_BTR, one of the following:Stretch, Tile, Center
PortraitBrightness SectionName: Watermark
PropertyName: Portrait brightness
varValue: VT_I4Range: -100 to 100
147
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
If bWatermarkEnabled Then
' apply landscape and portrait watermark centered on all pages ' image is lightened 25% Session.SetWatermarkOptionsOn(True, False) Session.SetPortraitWatermarkOptions("C:\TIFFSource\PortraitWatermark.png", _ pnWatermarkPosition.pnWatermarkCenter, 25) Session.SetLandscapeWatermarkOptions("C:\TIFFSource\LandWatermark.png", _ pnWatermarkPosition.pnWatermarkCenter, 25)End If
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
if (bWatermarkEnabled){ // apply landscape and portrait watermark centered on all pages // image lightened 25% session.SetWatermarkOptionsOn(true, false); session.SetPortraitWatermarkOptions("C:\\TIFFSource\\PortraitWatermark.png", pnWatermarkPosition.pnWatermarkCenter, 25); session.SetLandscapeWatermarkOptions("C:\\TIFFSource\\LandWatermark.png", pnWatermarkPosition.pnWatermarkCenter, 25);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetWatermarkOptionsOn SetLandscapeWatermarkOptionsClearWatermarkOptions SetProperty pnWatermarkPosition
ClearWatermarkOptions
Description
Clears any watermark options, both Portrait and Landscape, from the IPNSession object.When these options are not set through the IPNSession object, the default options forwatermark images on the Watermark tab in the PEERNET printer's Printing Preferencesdialog will be applied to the output file instead.
To clear a single watermark option use the SetProperty call with the appropriate sectionand name arguments and pass an empty argument as the property value. See the Remarks section in SetWatermarkOptionsOn, SetLandscapeWatermarkOptions and
PNSrv10 COM Interface
148 PNSrv10 COM Interface Object ReferenceIPNSession
SetPortraitWatermarkOptions for a list of values.
Syntaxexpression.ClearWatermarkOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearWatermarkOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearWatermarkOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetWatermarkOptionsOn SetPortraitWatermarkOptionsSetLandscapeWatermarkOptions SetProperty
SetMAPIEmailService
Description
Configures the MAPI email service options. These options will only take effect if the SetEmailService method has been set to use MAPI.
These settings are only applied when the email options are enabled. If the email optionsare enabled and there are no email service options set through the IPNSession object thedefault options for the Advanced Email Settings... button on the Email tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
The MAPI email service options can also be set using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Note:
149
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Starting with version 9.0.011 of the printer drivers, there is an extra MAPI emailservice option, Extended MAPI Save Sent Messages, that can only be set by using theSetProperty call. This property is only applied when theSetEmailService methodparameter pnEmailDialog set to pnEmailDialogStandard or pnEmailDialogAutosend. Anexample of using this property is shown in the sample code below.
Syntaxexpression.SetMAPIEmailService(Logon, UseExtendedMAPI)
where expression is an IPNSession object.
Parameters
pnMAPIEmailLogon LogonA pnMAPIEmailLogon constant for how to logon to the MAPI email service.
Boolean UseExtendedMAPISet this to True to use the extended MAPI settings. Using the extended settings tobypass many of the security warnings shown by Outlook.2000 SR-2 and laterversions.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Logon SectionName: Email Advanced
PropertyName: Shared logon
varValue: VT_BOOL, TRUE to perform manual logon.
UseExtendedMAPI SectionName: Email Advanced
PropertyName: Extended MAPI
varValue: VT_BOOL, TRUE to use extended MAPI
N/A SectionName: Email Advanced
PropertyName: Extended MAPI Save Sent Messages
varValue: VT_BOOL, TRUE to save messages in theSent Items folder.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Email settingsSession.SetEmailOn(True)Session.SetEmailMessageOptions("[email protected]", "[email protected]", _
PNSrv10 COM Interface
150 PNSrv10 COM Interface Object ReferenceIPNSession
"", "Test COM Email", "Please review the attached files.", _ "C:\Outgoing\Memo.doc")
If ( bUseMAPI ) Then Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, _ pnEmailDialog.pnEmailDialogAutosend) Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, True) ' Saves all messages in the sent folder Session.SetProperty("Email Advanced", "Extended MAPI Save Sent Messages", True)Else ' SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, _ pnEmailDialog.pnEmailDialogStandard) Session.SetSMTPEmailService("[email protected]", "SMTPServerName")End If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
...
// Email settingsSession.SetEmailOn(true);Session.SetEmailMessageOptions("[email protected]", "[email protected]", "", "Test COM Email", "Please review the attached files.", "C:\\Outgoing\Memo.doc");
if ( bUseMAPI ){ Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, pnEmailDialog.pnEmailDialogAutosend); Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, true); //Saves all messages in the sent folder session.SetProperty("Email Advanced", "Extended MAPI Save Sent Messages", true);
}else{ // SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, pnEmailDialog.pnEmailDialogStandard); Session.SetSMTPEmailService("[email protected]", "SMTPServerName");}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetEmailOn SetEmailMessageOptions SetEmailService SetMAPIEmailServiceSetVIMEmailService ClearEmailMessageOptions ClearEmailService SetPropertypnEmailService pnEmailDialog
SetMessageBoxAlerts
Description
Sets the message box display options in the IPNSession object. When these options arenot set through the IPNSession object, the default options for the Error Display in the
151
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Error Reporting tab in the PEERNET printer's Printing Preferences dialog will be applied tothe output file instead.
You can also set the error message box style by calling SetProperty with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetMessageBoxAlerts(MessageBoxStyle)
where expression is an IPNSession object.
Parameters
pnErrorMessageBoxStyle MessageBoxStyleA pnErrorMessageBoxStyle constant for the error message box styles.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
MessageBoxStyle SectionName: Error Reporting
PropertyName: MessageBox style
varValue: VT_BSTR, one of the following:None, Timed, Standard
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' don't show error messageSession.SetMessageBoxAlerts( pnErrorMessageBoxStyle.pnErrorMessageBoxStyleNone)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// show timed (auto-dismiss) message boxessession.SetMessageBoxAlerts(pnErrorMessageBoxStyle.pnErrorMessageBoxStyleTimed);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetErrorReporting ClearErrorReporting ClearMessageBoxAlerts SetPropertypnErrorMessageBoxStyle
PNSrv10 COM Interface
152 PNSrv10 COM Interface Object ReferenceIPNSession
ClearMessageBoxAlerts
Description
Clears the message box display options from the IPNSession object. When these optionsare not set through the IPNSession object, the default options for the Error Display inthe Error Reporting tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
You can also clear the error message box style by calling SetProperty with theappropriate section and name arguments and pass an empty argument as the propertyvalue. See the Remarks section in SetMessageBoxAlerts for a list of values.
Syntaxexpression.ClearMessageBoxAlerts()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearMessageBoxAlerts()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearMessageBoxAlerts();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetMessageBoxAlerts SetErrorReporting ClearErrorReporting SetProperty
SetNamingProfileFormat
Description
Sets any naming profile formatting for the desired file naming profile from the IPNSession object. There are four different naming profiles to customize:
Multipaged
153
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Multipaged with JobID
Serialized
Serialized with JobID
Which naming profile is used depends on your current settings for the SetSaveOptionsmethod. It is the combination of the output file type (one of pnOutputFileFormat)together with the UseJobID setting passed to the SetSaveOptions method thatdetermines which naming profile is used to build the filename.
For example:
Creating multipaged TIFF images (pnOutputFileFormatTIFFMultipaged) withUseJobID set to FALSE will use the Multipaged naming profile.
Creating serialized PDF files (pnOutputFileFormatAdobePDFSerialized) withUseJobID set to TRUE will use the Serialized with JobID naming profile.
Creating JPEG images (pnOutputFileFormatJPEG) with UseJobID set to FALSE willuse the Serialized naming profile.
Each naming profile has it's own settings that allow you to customize how the outputfiles are named. See the Advanced File Naming section in the User Guide for the printeryou are using for more information on using and customizing the naming profiles.
When these options are not set through the IPNSession object, the default options forthe Advanced File Naming... button on the Save tab in the PEERNET printer's PrintingPreferences dialog will be used to configure the naming of the output file instead.
To set a single file naming format option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
For a more detailed explanation of the naming profiles and how to customize them, seethe User Guide for the PEERNET printer being used.
Syntaxexpression.SetNamingProfileFormat(NamingProfile, FormatString, Variables, UseDefaultExt)
where expression is an IPNSession object.
Parameters
pnNamingProfile NamingProfileA pnNamingProfile constant for the file naming profile for which to set the formattingoptions.
String FormatStringA specially formatted string that combines with the Variables string to build thefilename. It is built using regular text and place holders for string (%s) and numeric(%d) variables supplied by the printer. To pad numeric values with zeroes, place anumber between the % and the "d" (%4d).
String VariablesComma-delimited list of variables that correspond to the placeholders (%s, %d) in FormatString. See Remarks below for a list of variables.
Boolean UseDefaultExt
PNSrv10 COM Interface
154 PNSrv10 COM Interface Object ReferenceIPNSession
Pass True if you want to save the the output files using the default extension for thatfile type. This will be different depending on which PEERNET printer you are using. If False, no extension will be present unless you specify one as part of the formatstring.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
NamingProfile Each naming profile format is set individually. There is adifferent set of property names for each naming profile.
M = pnNamingProfileMultipageMJ = pnNamingProfileMultipageWithJobIDS = pnNamingProfileSerializedSJ = pnNamingProfileSerializedWithJobID
FormatString SectionName: Advanced File Naming
PropertyName: Format string SFormat string SJFormat string MFormat string MJ
varValue: VT_BSTR, as above
Variables SectionName: Advanced File Naming
PropertyName: Variables SVariables SJVariables MVariables MJ
varValue: VT_BSTR, as above
UseDefaultEcxt SectionName: Advanced File Naming
PropertyName: Use default extension SUse default extension SJUse default extension MUse default extension MJ
varValue: VT_BOOL, as above
The following variables can be used to build custom filenames:
Variable TypeFormat StringPlace Holder
$(Day) Numeric %d
$(DocumentPageNumber) Numeric %d
$(FileExtension) String %s
$(FileNumber) Numeric %d
$(FilePageNumber) Numeric %d
$(Hour) Numeric %d
$(JobID) Numeric %d
$(JobStatus) Numeric %d
$(MachineName) String %s
155
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Variable TypeFormat StringPlace Holder
$(Minute) Numeric %d
$(Month) Numeric %d
$(OutputFileName) String %s
$(Second) Numeric %d
$(UserName) String %s
$(Year) Numeric %d
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
If bMultipage Then If bUseJobID Then Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileMultipageWithJobID, _ "%5d_%s", _ "$(JobID);$(OutputFileName)", _ True) Else Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileMultipage, _ "%s_(%d_%d)", _ "$(OutputFileName);$(Month);$(Year)", _ True) End IfElse If bUseJobID Then Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileSerializedWithJobID, _ "%5d_%s%d", _ "$(JobID);$(OutputFileName);$(FileNumber)", _ True) Else Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileSerialized, "%s%d(%d%d)", _ "$(OutputFileName);$(FileNumber)$(Month);$(Year)", _ True) End IfEnd If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
if (bMultipage){ if (bUseJobID) { Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileMultipageWithJobID, "%5d_%s", "$(JobID);$(OutputFileName)", True); } else { Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileMultipage,
PNSrv10 COM Interface
156 PNSrv10 COM Interface Object ReferenceIPNSession
"%s_(%d_%d)", "$(OutputFileName);$(Month);$(Year)", True); }}Else{ if (bUseJobID) { Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileSerializedWithJobID, "%5d_%s%d", "$(JobID);$(OutputFileName);$(FileNumber)", True); } else { Session.SetNamingProfileFormat(pnNamingProfile.pnNamingProfileSerialized, "%s%d(%d%d)", "$(OutputFileName);$(FileNumber)$(Month);$(Year)", True); }}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetSaveOptions ClearNamingProfileFormat ClearSaveOptions SetPropertypnNamingProfile pnOutputFileFormat
ClearNamingProfileFormat
Description
Clears any naming profile formatting for the desired file naming profile from the IPNSession object. When these options are not set through the IPNSession object, thedefault options for the Advanced File Naming... button on the Save tab in the PEERNETprinter's Printing Preferences dialog will be used to configure the naming of the outputfile instead.
To clear a single file naming format option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetNamingProfileFormat for a list of values.
Syntaxexpression.ClearNamingProfileFormat(NamingProfile)
where expression is an IPNSession object.
Parameters
pnNamingProfile NamingProfileA pnNamingProfile constant for file naming profile to clear.
Examples
157
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearNamingProfileFormat(pnNamingProfile.pnNamingProfileMultipage)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearNamingProfileFormat(pnNamingProfile.pnNamingProfileSerializedWithJobID);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearFileNamingOptions SetNamingProfileFormat SetFileNamingOptionsSetProperty pnNamingProfile
SetPageBrightness
Description
Sets the page brightness options in the IPNSession object. When these options are notset through the IPNSession object, the default options for the Brightness Adjustmentslider control on the Page Processing tab in the PEERNET printer's Printing Preferencesdialog will be applied to the output file instead.
You can also set the page brightness adjustment by calling SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
For a more detailed explanation of the page brightness adjustment feature, see the UserGuide for the PEERNET printer being used.
Syntaxexpression.SetPageBrightness(Brightness)
where expression is an IPNSession object.
Parameters
Integer BrightnessA value between -100 and - 100 that determines the brightness level of the page.
Range Action
-100 to -1 Darkens the image, with -100 being black.
PNSrv10 COM Interface
158 PNSrv10 COM Interface Object ReferenceIPNSession
Range Action
0 No change
1 to 100 Lightens the image, with 100 being white.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Brightness SectionName: Processing
PropertyName: Brightness Adjust
varValue: VT_I4, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' lighten the imageSession.SetPageBrightness(25)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// darken the imagesession.SetPageBrightness(-20);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageCropOn SetPageCropAreaOptions SetPageCropMarginOptionsSetPageRotationOptions SetPageTrimOptions ClearPageCropAreaOptionsClearPageCropMarginOptions ClearPageRotationOptions ClearPageTrimOptions SetProperty
ClearPageBrightness
Description
Clears any page brightness adjustment options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the BrightnessAdjustment slider control on the Page Processing tab in the PEERNET printer's PrintingPreferences dialog will be applied to the output file instead.
You can also clear the page brightness adjustment by calling SetProperty with theappropriate section and name arguments and pass an empty argument as the property
159
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
value. See the Remarks section in SetPageBrightness for a list of values.
Syntaxexpression.ClearPageBrightness()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearPageBrightness()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearPageBrightness();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearPageCropAreaOptions ClearPageCropMarginOptionsClearPageRotationOptions ClearPageTrimOptions SetPageBrightness SetPageCropOnSetPageCropAreaOptions SetPageCropMarginOptions SetPageRotationOptionsSetPageTrimOptions SetProperty
SetPageCropAreaOptions
Description
Sets any page area cropping options in the IPNSession object. The concept of pagecropping is analogous to scissors that cut away sections of paper. In this case portions ofthe page are removed and the remaining image area is smaller than the original page.
If cropping is enabled and these options are not set through the IPNSession object, thedefault options for the Crop section on the Page Processing tab in the PEERNET printer'sPrinting Preferences dialog will be applied to the output file instead. If all four fields,CropLeft, CropTop, CropWidth and CropHeight, are 0.00in then no cropping is performed.
To set a only a single page area cropping option use the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
PNSrv10 COM Interface
160 PNSrv10 COM Interface Object ReferenceIPNSession
For a more detailed explanation of the page cropping features, see the User Guide forthe PEERNET printer being used.
Syntaxexpression.SetPageCropAreaOptions(Units, CropLeft, CropTop, CropWidth, CropHeight)
where expression is an IPNSession object.
Parameters
pnUnits UnitsA pnUnits constant for the unit of measure used to enter the cropping measurements.
Double CropLeftThis is the leftmost starting point for the cropped area, in pnUnits from the left sideof the page.
Double CropTopThis is the topmost starting point for the cropped area, in pnUnits from the top of thepage.
Double CropWidthThe width of the area you want to crop from the original page in pnUnits. This areastarts at CropLeft.
Double CropHeightThe width of the area you want to crop from the original page in pnUnits. This areastarts at CropTop.
Remarks
Only one of SetPageCropAreaOptions or SetPageCropMarginOptions can be set at anyone time. Whichever method is last called determines whether margins or a page area iscropped.
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Units SectionName: Processing
PropertyName: Units
varValue: VT_BSTR, one of the following:.01 Inches1 Millimeters
Ignored if the units are specified in thestrings below
CropLeft SectionName: Processing
PropertyName: Crop left
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)
161
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
0cm-200000.000cm (centimeters)
CropTop SectionName: Processing
PropertyName: Crop top
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)0cm-200000.000cm (centimeters)
CropWidth SectionName: Processing
PropertyName: Crop width
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)0cm-200000.000cm (centimeters)
CropHeight SectionName: Processing
PropertyName: Crop Height
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)0cm-200000.000cm (centimeters)
There is noparameter for thisoption, it isautomatically set.
SectionName: Processing
PropertyName: Crop Option
varValue: VT_I4, must be 0 to crop by area or region
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.SetPageCropOn(True)If bCropMargins Then ' crop 0.75' margins Session.SetPageCropMarginOptions(pnUnits.pnUnitsEnglish, 0.75, 0.75, 0.75, 0.75)Else ' crop a 5'x7' area start 2' from both top and left Session.SetPageCropAreaOptions(pnUnits.pnUnitsEnglish, 2.00, 2.00, 5.00, 7.00)End If
C#
PNSession session = null;
PNSrv10 COM Interface
162 PNSrv10 COM Interface Object ReferenceIPNSession
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
session.SetPageCropOn(true);if (bCropMargins){ // crop 0.75" margins session.SetPageCropMarginOptions(pnUnits.pnUnitsEnglish, 0.75, 0.75, 0.75, 0.75);}else{ // crop a 5"x7" area start 2" from both top and left session.SetPageCropAreaOptions(pnUnits.pnUnitsEnglish, 2.00, 2.00, 5.00, 7.00);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageBrightness SetPageCropOn SetPageCropMarginOptionsSetPageRotationOptions SetPageTrimOptions ClearPageBrightnessClearPageCropMarginOptions ClearPageCropAreaMargins ClearPageRotationOptionsClearPageTrimOptions SetProperty pnUnits
ClearPageCropAreaOptions
Description
Clears any page area cropping options from the IPNSession object. When these optionsare not set through the IPNSession object, the default options for the Crop section onthe Page Processing tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
To clear a only a single page area cropping option use the SetProperty call with theappropriate section and name arguments and pass an empty argument as the propertyvalue. See the Remarks section in SetPageCropOn and SetPageCropAreaOptions for alist of values.
Syntaxexpression.CleaPageCropAreaOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.CleaPageCropAreaOptions()
163
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.CleaPageCropAreaOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearPageBrightness ClearPageCropMarginOptions ClearPageRotationOptionsClearPageTrimOptions SetPageBrightness SetPageCropOn SetPageCropAreaOptionsSetPageCropMarginOptions SetPageRotationOptions SetPageTrimOptions SetProperty
SetPageCropMarginOptions
Description
Sets the page margin cropping options in the IPNSession object. The concept of pagecropping is analogous to scissors that cut away sections of paper. In this case the top,left, right and bottom edges of the page are removed and the remaining image area issmaller than the original page.
If cropping is enabled and these options are not set through the IPNSession object, thedefault options for the Crop section on the Page Processing tab in the PEERNET printer'sPrinting Preferences dialog will be applied to the output file instead.
To set a single page margin cropping option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
For a more detailed explanation of the page cropping features, see the User Guide forthe PEERNET printer being used.
Syntaxexpression.SetPageCropAreaOptions(Units, CropLeft, CropTop, CropRight, CropBottom)
where expression is an IPNSession object.
Parameters
pnUnits UnitsA pnUnits constant for the unit of measure used to enter the cropping measurements.
Double CropLeftThe desired width of the left margin to crop in pnUnits from the left-hand side of thepage.
Double CropTopThe desired height of the top margin to crop in pnUnits from the top of the page.
Double CropRight
PNSrv10 COM Interface
164 PNSrv10 COM Interface Object ReferenceIPNSession
The desired width of the right margin to crop in pnUnits from the right-hand side ofthe page.
Double CropBottomThe desired height of the bottom margin to crop in pnUnits from the bottom of thepage.
Remarks
Only one of SetPageCropAreaOptions or SetPageCropMarginOptions can be set at anyone time. Whichever method is last called determines whether margins or a page area iscropped.
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Units SectionName: Processing
PropertyName: Units
varValue: VT_BSTR, one of the following:.01 Inches1 Millimeters
Ignored if the units are specified in thestrings below
CropLeft SectionName: Processing
PropertyName: Crop margin left
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)0cm-200000.000cm (centimeters)
CropTop SectionName: Processing
PropertyName: Crop margin top
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)0cm-200000.000cm (centimeters)
CropRight SectionName: Processing
PropertyName: Crop margin right
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)0cm-200000.000cm (centimeters)
CropBottom SectionName: Processing
PropertyName: Crop margin bottom
165
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
varValue: VT_BSTR, one of the following ranges:0-8000000 (hundredths of an inch)0-20000000 (tenths of a millimeter)0in-80000in (inches)0cm-200000.000cm (centimeters)
There is noparameter for thisoption, it isautomatically set.
SectionName: Processing
PropertyName: Crop Option
varValue: VT_I4, must be 1 to crop margins
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.SetPageCropOn(True)If bCropMargins Then ' crop 0.75' margins Session.SetPageCropMarginOptions(pnUnits.pnUnitsEnglish, 0.75, 0.75, 0.75, 0.75)Else ' crop a 5'x7' area start 2' from both top and left Session.SetPageCropAreaOptions(pnUnits.pnUnitsEnglish, 2.00, 2.00, 5.00, 7.00)End If
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
session.SetPageCropOn(true);if (bCropMargins){ // crop 0.75" margins session.SetPageCropMarginOptions(pnUnits.pnUnitsEnglish, 0.75, 0.75, 0.75, 0.75);}else{ // crop a 5"x7" area start 2" from both top and left session.SetPageCropAreaOptions(pnUnits.pnUnitsEnglish, 2.00, 2.00, 5.00, 7.00);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageBrightness SetPageCropOn SetPageCropAreaOptionsSetPageRotationOptions SetPageTrimOptions ClearPageBrightnessClearPageCropAreaOptions ClearPageCropMarginOptions ClearPageRotationOptionsClearPageTrimOptions SetProperty pnUnits
PNSrv10 COM Interface
166 PNSrv10 COM Interface Object ReferenceIPNSession
ClearPageCropMarginOptions
Description
Clears any page margin cropping options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the Cropsection on the Page Processing tab in the PEERNET printer's Printing Preferences dialogwill be applied to the output file instead.
To clear a only a single page margin cropping option use the SetProperty call with theappropriate section and name arguments and pass an empty argument as the propertyvalue. See the Remarks section in SetPageCropOn and SetPageCropMarginOptions for alist of values.
Syntaxexpression.CleaPageCropMarginOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.CleaPageCropMarginOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.CleaPageCropMarginOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearPageBrightness ClearPageCropAreaOptions ClearPageRotationOptionsClearPageTrimOptions SetPageBrightness SetPageCropOn SetPageCropAreaOptionsSetPageCropMarginOptions SetPageRotationOptions SetPageTrimOptions SetProperty
SetPageCropOn
Description
Enables or disables the Crop options. When these options are not set through the
167
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
IPNSession object the default options for Crop in the Page Processing tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
Cropping can also be enabled or disabled using the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetPageCropOn(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableSet True to enable any Cropping options, False to disable them.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Processing
PropertyName: Crop
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.SetPageCropOn(True)If bCropMargins Then ' crop 0.75' margins Session.SetPageCropMarginOptions(pnUnits.pnUnitsEnglish, 0.75, 0.75, 0.75, 0.75)Else ' crop a 5'x7' area start 2' from both top and left Session.SetPageCropAreaOptions(pnUnits.pnUnitsEnglish, 2.00, 2.00, 5.00, 7.00)End If
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
session.SetPageCropOn(true);if (bCropMargins){ // crop 0.75" margins session.SetPageCropMarginOptions(pnUnits.pnUnitsEnglish, 0.75, 0.75, 0.75, 0.75);}else{ // crop a 5"x7" area start 2" from both top and left
PNSrv10 COM Interface
168 PNSrv10 COM Interface Object ReferenceIPNSession
session.SetPageCropAreaOptions(pnUnits.pnUnitsEnglish, 2.00, 2.00, 5.00, 7.00);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageBrightness SetPageCropAreaOptions SetPageCropMarginOptionsSetPageRotationOptions SetPageTrimOptions ClearPageBrightnessClearPageCropAreaOptions ClearPageCropMarginOptions ClearPageRotationOptionsClearPageTrimOptions SetProperty
SetPageRotationOptions
Description
Sets any page rotation options in the IPNSession object. When these options are not setthrough the IPNSession object, the default options for the Rotation section on the PageProcessing tab in the PEERNET printer's Printing Preferences dialog will be applied to theoutput file instead.
To set a single page rotation option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetPageRotationOptions(Portrait, Landscape)
where expression is an IPNSession object.
Parameters
pnRotation PortraitA pnRotation constant for the degree of counter-clockwise rotation for portrait pages.
pnRotation LandscapeA pnRotation constant for the degree of counter-clockwise rotation for landscapepages.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Portrait SectionName: Image Options
PropertyName: Rotate portrait
varValue: VT_I4, one of:090180270
Landscape SectionName: Image Options
169
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
PropertyName: Rotate landscape
varValue: VT_I4, one of:090180270
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' rotate all landscape pages 90 degrees, leave portrait pagesSession.SetPageRotationOptions(pnRotation.pnRotationNone, pnRotation.pnRotation90)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// rotate all landscape pages 90 degrees, leave portrait pagessession.SetPageRotationOptions(pnRotation.pnRotationNone, pnRotation.pnRotation90)
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageBrightness SetPageCropOn SetPageCropAreaOptionsSetPageCropMarginOptions SetPageTrimOptions ClearPageBrightnessClearPageCropAreaOptions ClearPageCropMarginOptions ClearPageRotationOptionsClearPageTrimOptions SetProperty pnRotation
ClearPageRotationOptions
Description
Clears any page rotation options from the IPNSession object. When these options are notset through the IPNSession object, the default options for the Rotation section on thePage Processing tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead.
To clear a only a single page rotation option use the SetProperty call with theappropriate section and name arguments and pass an empty argument as the propertyvalue. See the Remarks section in SetPageRotationOptions for a list of values.
Syntaxexpression.CleaPageRotationOptions()
PNSrv10 COM Interface
170 PNSrv10 COM Interface Object ReferenceIPNSession
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.CleaPageRotationOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.CleaPageRotationOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearPageBrightness ClearPageCropAreaOptions ClearPageCropMarginOptionsClearPageTrimOptions SetPageBrightness SetPageCropOn SetPageCropAreaOptionsSetPageCropMarginOptions SetPageRotationOptions SetPageTrimOptions SetProperty
SetPageTrimOptions
Description
Sets any page trimming options in the IPNSession object. Trimming is similar tocropping except that all areas on the chosen sides (Left, Right, Top or Bottom) of thepage that fall at or below the chosen intensity level will be automatically removed.
When these options are not set through the IPNSession object, the default options forthe Trim section on the Page Processing tab in the PEERNET printer's Printing Preferencesdialog will be applied to the output file instead.
To set a single trimming option use the SetProperty call with the appropriate arguments.See the Remarks below for a list of arguments.
For a more detailed explanation of the trim feature, see the User Guide for the PEERNETprinter being used.
Syntaxexpression.SetPageTrimOptions(TrimLeft, TrimTop, TrimRight, TrimBottom, TrimLevel)
where expression is an IPNSession object.
171
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Parameters
Boolean TrimLeftPass as True to trim the left side of the page, False to ignore.
Boolean TrimTopPass as True to trim the top of the page, False to ignore.
Boolean TrimRightPass as True to trim the right side of the page, False to ignore.
Boolean TrimBottomPass as True to trim the bottom of the page, False to ignore.
Integer TrimLevelThis must be a value between 0 - 100. When the intensity is set all the way to theleft on White(0), only pure white pixels will be removed. The higher the intensitylevel, the more colors will removed. If the intensity is set to Black(100), the entirepage will in effect be "trimmed", and the trimming operation is abandoned.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
TrimLeft SectionName: Processing
PropertyName: Trim left
varValue: VT_BOOL
TrimTop SectionName: Processing
PropertyName: Trim top
varValue: VT_BOOL
TrimRight SectionName: Processing
PropertyName: Trim right
varValue: VT_BOOL
TrimBottom SectionName: Processing
PropertyName: Trim bottom
varValue: VT_BOOL
TrimLevel SectionName: Processing
PropertyName: Trim Threshold
varValue: VT_I4Range of 1-100
Examples
Visual Basic
Public WithEvents Session As PNSession
PNSrv10 COM Interface
172 PNSrv10 COM Interface Object ReferenceIPNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' trim all pure white edges of the documentSession.SetPageTrimOptions(True, True, True, True, 0)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// trim all pure white edges of the documentsession.SetPageTrimOptions(True, True, True, True, 0);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageBrightness SetPageRotationOptions SetPageCropOnSetPageCropAreaOptions SetPageCropMarginOptions ClearPageBrightnessClearPageTrimOptions ClearPageCropAreaOptions ClearPageCropMarginOptionsClearPageRotationOptions SetProperty
ClearPageTrimOptions
Description
Clears any page trimming options from the IPNSession object. When these options arenot set through the IPNSession object, the default options for the Trim section on thePage Processing tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead.
To clear a only a single trimming option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetPageTrimOptions for a list of values.
Syntaxexpression.ClearPageTrimOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearPageTrimOptions()
173
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearPageTrimOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearPageBrightness ClearPageCropAreaOptions ClearPageCropMarginOptionsClearPageRotationOptions SetPageBrightness SetPageCropOn SetPageCropAreaOptionsSetPageCropMarginOptions SetPageRotationOptions SetPageTrimOptions SetProperty
SetPDFCompressionOptions
Description
Sets the PDF file format image and content compression methods used to store theimage in the output file. The actual compression method used on each page will dependon the color reduction method chosen through the SetSaveOptions method. Other outputoptions used, such as SetFaxImageOptions may override any settings chosen here.
To set only a single compression option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Note: Starting with version 9.0.011 of the printer drivers, there is an extra PDF compressionoption, PDF Standard, that can only be set by using the SetProperty call. This optioncan be used to enforce the creation of PDF/A-1b compliant PDF files. An example ofusing this property is shown in the sample code below.
Syntaxexpression.SetPDFCompressionOptions(UseCompression, UseASCIICompression, ContentEncoding Color, Indexed, Greyscale, BW)
where expression is a IPNSession object.
Parameters
Boolean UseCompressionSet True to create a compressed PDF file, False to create an uncompresseddocument. Uncompressed PDF files can be very large.
Boolean UseASCIICompressionSet True to store the PDF document in ASCII format.
PNSrv10 COM Interface
174 PNSrv10 COM Interface Object ReferenceIPNSession
pnPDFContentEncodingMethod ContentEncodingA pnPDFContentEncodingMethod constant for the compression method to use tocompress any text and line art in the PDF document.
pnColorCompressionMethod ColorA pnColorCompressionMethod constant for the compression method to use for colorimages.
pnIndexedCompressionMethod IndexedA pnIndexedCompressionMethod constant for the compression method to use forindexed images. An indexed image is an image that has 256 colors or less.
pnGreyscaleCompressionMethod GreyscaleA pnGreyscaleCompressionMethod constant for the compression method to use forgreyscale images.
pnBWCompressionMethod BWA pnBWCompressionMethod constant for the compression method to use for blackand white images.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
UseCompression SectionName: PDF File Format
PropertyName: Use compression
varValue: VT_BOOL
UseASCIICompression SectionName: PDF File Format
PropertyName: Use ASCII
varValue: VT_BOOL
ContentEncoding SectionName: PDF File Format
PropertyName: Content Encoding
varValue: VT_BSTR, one of the following:NoneZIPRLELZW
Color SectionName: PDF File Format
PropertyName: Color compression
varValue: VT_BSTR, one of the following:NoneZIPRLEJPEG HighJPEG MediumJPEG LowLZW
175
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
Indexed SectionName: PDF File Format
PropertyName: Indexed compression
varValue: VT_BSTR, one of the following:NoneZIPRLEJPEG HighJPEG MediumJPEG LowLZW
Greyscale SectionName: PDF File Format
PropertyName: Greyscale compression
varValue: VT_BSTR, one of the following:NoneZIPRLEJPEG HighJPEG MediumJPEG LowLZW
BW SectionName: PDF File Format
PropertyName: BW compression
varValue: VT_BSTR, one of the following:NoneGroup4Group3-2DGroup3-1D
N/A SectionName: PDF File Format
PropertyName: PDF Standard
varValue: VT_BSTR, one of the following:NonePDF/A-1b
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)
' Set the file output options' Reduce to black and white with Floyd-Steinburg ditheringSession.SetSaveOptions("C:\PDFOutput\", "PDFReport", _ pnOutputFileFormatPDFMultipaged, False, _ pnColorReductionBlackAndWhite, pnDitheringFloyd, _ False, False, True, True, True, False)
PNSrv10 COM Interface
176 PNSrv10 COM Interface Object ReferenceIPNSession
' Compress using CCITTG4Session.SetPDFFileCompressionOptions(True, False, pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, _ pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
' Create PDF/A-1b compliant PDF filesSession.SetProperty("PDF File Format", "PDF Standard", "PDF/A-1b")
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);
// Set the file output options// Reduce to black and white with Floyd-Steinburg ditheringsession.SetSaveOptions("C:\\PDFOutput\\", "PDFReport", pnOutputFileFormatPDFMultipaged, false, pnColorReductionBlackAndWhite, pnDitheringFloyd, false, false, true, true, true, false);
' Compress using CCITTG4session.SetPDFFileCompressionOptions(true, false, pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
// Create PDF/A-1b compliant PDF filesSession.SetProperty("PDF File Format", "PDF Standard", "PDF/A-1b");
Supported Printers: PDF Image Printer 10.0, %SUPDRV_RASTER%>
See Also: SetPDFPassword SetPDFSecurity ClearPDFCompressionOptions ClearPDFSecurity ClearPDFPassword SetProperty pnColorReduction pnDitheringMethodpnPDFContentEncodingMethod pnColorColorCompressionMethodpnIndexedCompressionMethod pnGreyscaleCompressionMethod pnBWCompressionMethod
ClearPDFCompressionOptions
Description
Clears the PDF file format compression options from the IPNSession object. This includesthe compression options for color, indexed, grayscale and black and white output, andthe boolean flags for compressing the PDF and creating an ASCII format compressedPDF. When the PDF file format options are not set through the IPNSession object, thedefault options for the PDF File Format tab in the PDF Image Printer 10.0 printer'sPrinting Preferences dialog will be applied to the output file instead.
To clear only a single compression option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetPDFCompressionOptions for a list of values.
177
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Syntaxexpression.ClearPDFFileFormatOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)
' Set the file output options' Reduce to black and white with Floyd-Steinburg ditheringSession.SetSaveOptions("C:\PDFOutput\", "PDFReport", _ pnOutputFileFormatPDFMultipaged, False, _ pnColorReductionBlackAndWhite, pnDitheringFloyd, _ False, False, True, True, True, False)
' Compress using CCITTG4Session.SetPDFFileCompressionOptions(True, False, pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, _ pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)...' reset session for new print Session.ClearPDFFileFormatOptions()
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);
// Set the file output options// Reduce to black and white with Floyd-Steinburg ditheringsession.SetSaveOptions("C:\\PDFOutput\\", "PDFReport", pnOutputFileFormatPDFMultipaged, false, pnColorReductionBlackAndWhite, pnDitheringFloyd, false, false, true, true, true, false);
' Compress using CCITTG4session.SetPDFFileCompressionOptions(true, false, pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);...// reset session for new print session.ClearPDFFileFormatOptions();
Supported Printers: PDF Image Printer 10.0, %SUPDRV_RASTER%>
See Also: SetPDFCompressionOptions SetPDFPassword SetPDFSecurity ClearPDFSecurityClearPDFPassword SetProperty
PNSrv10 COM Interface
178 PNSrv10 COM Interface Object ReferenceIPNSession
SetPDFFileFormatOptions
Beginning with version 9.0 of PDF Image Printer and Raster Image Printer thismethod has been superseded by SetSaveOptions and SetPDFCompressionOptions.This method will still work when called but it its recommended that all new code use
the updated methods.
Description
Sets the PDF file format options including color reduction, dithering methods and imageand content compression methods used to store the image in the output file. The actualcompression method used on each page will depend on the color reduction methodchosen, if any.
To set only a single compression option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetPDFFileFormatOptions(UseCompression, UseASCIICompression ColorReduction, Dithering, ContentEncoding Color, Indexed, Greyscale, BW)
where expression is a IPNSession object.
Parameters
Boolean UseCompressionSet True to create a compressed PDF file, False to create an uncompresseddocument. Uncompressed PDF files can be very large.
Boolean UseASCIICompressionSet True to store the PDF document in ASCII format.
pnColorReduction ColorReductionA pnColorReduction constant for any color reduction options to apply to the outputfile. There are four color reduction options available for reducing the number of colorsin true color images. In general, the fewer the colors in an image, the smaller the filesize.
pnDitheringMethod DitheringA pnDitheringMethod constant to determine the method used when reducing colorimages to black and white. Dithering is used to enhance the appearance of colorimages that have been reduced to black and white.
pnPDFContentEncodingMethod ContentEncodingA pnPDFContentEncodingMethod constant for the compression method to use tocompress any text and line art in the PDF document.
pnColorCompressionMethod ColorA pnColorCompressionMethod constant for the compression method to use for colorimages.
pnIndexedCompressionMethod IndexedA pnIndexedCompressionMethod constant for the compression method to use forindexed images. An indexed image is an image that has 256 colors or less.
pnGreyscaleCompressionMethod Greyscale
179
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
A pnGreyscaleCompressionMethod constant for the compression method to use forgreyscale images.
pnBWCompressionMethod BWA pnBWCompressionMethod constant for the compression method to use for blackand white images.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
UseCompression SectionName: PDF File Format
PropertyName: Use compression
varValue: VT_BOOL
UseASCIICompression
SectionName: PDF File Format
PropertyName: Use ASCII
varValue: VT_BOOL
ColorReduction SectionName: PDF File Format
PropertyName: Color reduction
varValue: VT_BSTR, one of the following:None, Optimal, BW, Grey
Dithering SectionName: PDF File Format
PropertyName: Dithering method
varValue: VT_BSTR, one of the following:None, Floyd, Burkes, Bayer, Halftone
ContentEncoding SectionName: PDF File Format
PropertyName: Content Encoding
varValue: VT_BSTR, one of the following:None, ZIP, RLE, LZW
Color SectionName: PDF File Format
PropertyName: Color compression
varValue: VT_BSTR, one of the following:None, ZIP, RLE, JPEG High, JPEG Medium,JPEG Low, LZW
Indexed SectionName: PDF File Format
PropertyName: Indexed compression
varValue: VT_BSTR, one of the following:None, ZIP, RLE, JPEG High, JPEG Medium,JPEG Low, LZW
Greyscale SectionName: PDF File Format
PropertyName: Greyscale compression
PNSrv10 COM Interface
180 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
varValue: VT_BSTR, one of the following:None, ZIP, RLE, JPEG High, JPEG Medium,JPEG Low, LZW
BW SectionName: PDF File Format
PropertyName: BW compression
varValue: VT_BSTR, one of the following:None, Group4, Group3-2D, Group3-1D
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)
'set the compression options - reduce to black and white with Floyd-Steinburg' compress using CCITTG4Session.SetPDFFileFormatOptions(True, False, pnColorReduction.pnColorReductionBlackAndWhite, _ pnDitheringMethod.pnDitheringFloyd, _ pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, _ pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);
//set the compression options - reduce to black and white with Floyd-Steinburg// compress using CCITTG4session.SetCompressionOptions(true, false, pnColorReduction.pnColorReductionBlackAndWhite, pnDitheringMethod.pnDitheringFloyd, pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
Supported Printers: PDF Image Printer 10.0, %SUPDRV_RASTER%>
See Also: SetSaveOptions SetPDFCompressionOptions SetPDFPassword SetPDFSecurityClearSaveOptions ClearPDFCompressionOptions ClearPDFFileFormatOptionsClearPDFPassword ClearPDFSecurity SetProperty pnColorReduction pnDitheringMethodpnPDFContentEncodingMethod pnColorColorCompressionMethodpnIndexedCompressionMethod pnGreyscaleCompressionMethod pnBWCompressionMethod
181
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
ClearPDFFileFormatOptions
Beginning with version 9 of PDF Image Printer and Raster Image Printer this methodhas been superseded by SetSaveOptions and SetPDFCompressionOptions. Thismethod will still work when called using PDF Image Printer and Raster Image Printer
but we recommend that all new code use the updated methods.
Description
Clears the PDF file format options from the IPNSession object. This includes the colorreduction and dithering options as well as the compression options for color, indexed,grayscale and black and white output, and the boolean flags for compressing the PDF,and for creating an ASCII format compressed PDF. When the PDF file format options arenot set through the IPNSession object, the default options for the PDF File Format tab inthe PDF Image Printer 10.0 printer's Printing Preferences dialog will be applied to theoutput file instead.
To clear only a single compression option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetPDFFileFormatOptions for a list of values.
Syntaxexpression.ClearPDFFileFormatOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)...'set the compression options - reduce to black and white with Floyd-Steinburg' compress using CCITTG4Session.SetPDFFileFormatOptions(True, False, pnColorReduction.pnColorReductionBlackAndWhite, _ pnDitheringMethod.pnDitheringFloyd, _ pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, _ pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)...' reset session for new print Session.ClearPDFFileFormatOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);...//set the compression options - reduce to black and white with Floyd-Steinburg// compress using CCITTG4session.SetCompressionOptions(true, false, pnColorReduction.pnColorReductionBlackAndWhite,
PNSrv10 COM Interface
182 PNSrv10 COM Interface Object ReferenceIPNSession
pnDitheringMethod.pnDitheringFloyd, pnPDFContentEncodingMethod.pnPDFContentEncodingLZW, pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);...// reset session for new print session.ClearPDFFileFormatOptions();
Supported Printers: PDF Image Printer 10.0, %SUPDRV_RASTER%>
See Also: SetPDFFileFormatOptions SetSaveOptions SetPDFCompressionOptionsSetPDFPassword SetPDFSecurity ClearSaveOptions ClearPDFCompressionOptionsClearPDFPassword ClearPDFSecurity SetProperty
SetPDFPassword
Description
There are two levels of password protection that can be set for PDF files – one foropening the PDF file (also known as the document open password), and one for makingchanges or modifying the PDF file (also called the permissions, or change, password).
This method allows you to specify these passwords. PDF password protection is onlyapplies if PDF security is enabled. This is done through the PDFSetSecurity method.
To set only a single security option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetPDFPassword(EnableOpenPassword, OpenPassword, EnableChangePassword, ChangePassword)
where expression is a IPNSession object.
Parameters
Boolean EnableOpenPasswordSet True to require anyone opening this PDF file to type in the password you specify.
String OpenPasswordThe password you want to use to allow the PDF file to be opened.
Boolean EnableChangePasswordSet True to require anyone making changes to this PDF file to type in the passwordyou specify. When set, this password is required to change the security settings or tomodify permissions on the document.
String ChangePasswordThe password you want to use to allow changes to the PDF file.
Remarks
Use the following to set these options using SetProperty:
183
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
EnableOpenPassword SectionName: PDF Security
PropertyName: User Pswd On
varValue: VT_BOOL
OpenPassword SectionName: PDF Security
PropertyName: User Pswd
varValue: VT_BSTR
EnableChangePassword SectionName: PDF Security
PropertyName: Owner Pswd On
varValue: VT_BOOL
ChangePassword SectionName: PDF Security
PropertyName: Owner Pswd
varValue: VT_BSTR
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)
'set pdf security for 128-bit, allow printing and copying but not changing the PDFSession.SetPDFSecurity(True, pnPDFEncryption.pnPDFEncryption128, _ True, True,False, False)'set pdf password for opening documentSession.SetPDFPassword(True, "SalesTeam01", False, Nothing)
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);
// set pdf security for 128-bit, allow printing and copying but not changing the PDFsession.SetPDFSecurity(true, pnPDFEncryption.pnPDFEncryption128, true, true, false, false);// set pdf password for opening documentsession.SetPDFPassword(True, "SalesTeam01", false, null);
Supported Printers: PDF Image Printer 10.0, Raster Image Printer 10.0
See Also: SetPDFSecurity SetPDFFileFormatOptions ClearPDFPassword ClearPDFSecurityClearPDFFileFormatOptions SetProperty
PNSrv10 COM Interface
184 PNSrv10 COM Interface Object ReferenceIPNSession
ClearPDFPassword
Description
Clears the PDF password options from the IPNSession object. When the PDF passwordoptions are not set through the IPNSession object, the default options for the PDFSecurity tab in the PDF Image Printer 10.0 printer's Printing Preferences dialog will beapplied to the output file instead.
To clear only a single compression option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section for SetPDFPassword for a list of values.
Syntaxexpression.ClearPDFPassword()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)...'set pdf security for 128-bit, allow printing and copying but not changing the PDFSession.SetPDFSecurity(True, pnPDFEncryption.pnPDFEncryption128, _ True, True,False, False)'set pdf password for opening documentSession.SetPDFPassword(True, "SalesTeam01", False, Nothing)...
' reset session for new print Session.ClearPDFSecurity()Session.ClearPDFPassword()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);...
// set pdf security for 128-bit, allow printing and copying but not changing the PDFsession.SetPDFSecurity(True, pnPDFEncryption.pnPDFEncryption128, true, true, false, false);// set pdf password for opening documentsession.SetPDFPassword(True, "SalesTeam01", false, null);
// reset session for new print session.ClearPDFSecurity();session.ClearPDFPassword();
Supported Printers: PDF Image Printer 10.0, %SUPDRV_RASTER%>
See Also: SetPDFPassword SetPDFSecurity SetPDFFileFormatOptions ClearPDFSecurityClearPDFFileFormatOptions SetProperty
185
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
SetPDFSecurity
Description
PDF files can be created with or without security. Creating a secure PDF allows you torestrict what can be done with the contents of the file. For instance, you can allow peopleto read and print the file but not be able to copy any of the text or images out of the file.Supported security options consist of two different levels of encryption and the ability tocontrol what the viewer can do with PDF file. You can also set up to two levels ofpassword protection using the SetPDFPassword method.
To set only a single security option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetPDFSecurity(UseSecurity, Encryption, AllowCopyText, AllowPrinting, AllowDocumentChange, AllowCommentsAndFormFields)
where expression is a IPNSession object.
Parameters
Boolean UseSecuritySet True to create a secure PDF file, False to create an unsecured document.
pnPDFEncryption EncryptionA pnPDFEncryption constant for the encryption level of the PDF. The encryptionoption chosen determines what version of Acrobat is needed to open and view thefile
Boolean AllowCopyTextSet True to allow text and images in the PDF file to be selected and copied to theclipboard for use in other documents, False to disallow.
Boolean AllowPrintingSet True to allow the PDF file to be printed, False to disallow.
Boolean AllowDocumentChangeSet True to allow pages in the PDF file to be inserted, removed and modified, Falseto disallow. This also allows document signing as well as adding or editing formfields.
Boolean AllowCommentsAndFormFieldsSet True to allow only form fields and comments to added, edited or removed; Falseto disallow.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
UseSecurity SectionName: PDF Security
PropertyName: Use Security
varValue: VT_BOOL
PNSrv10 COM Interface
186 PNSrv10 COM Interface Object ReferenceIPNSession
Encryption SectionName: PDF Security
PropertyName: Encrypt Level
varValue: VT_I40 = 40-bit encryption1 = 128-bit encryption
AllowCopyText SectionName: PDF Security
PropertyName: Can Copy
varValue: VT_BOOL
AllowPrinting SectionName: PDF Security
PropertyName: Can Print
varValue: VT_BOOL
AllowDocumentChange SectionName: PDF Security
PropertyName: Can Change Doc
varValue: VT_BOOL
AllowCommentsAndFormFields SectionName: PDF Security
PropertyName: Can ChangeOther
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)
'set pdf security for 128-bit, allow printing and copying but not changing the PDFSession.SetPDFSecurity(True, pnPDFEncryption.pnPDFEncryption128, _ True, True,False, False)
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);
// set pdf security for 128-bit, allow printing and copying but not changing the PDFsession.SetPDFSecurity(True, pnPDFEncryption.pnPDFEncryption128, true, true, false, false);
Supported Printers: PDF Image Printer 10.0, %SUPDRV_RASTER%>
See Also: SetPDFPassword SetPDFFileFormatOptions ClearPDFSecurity ClearPDFPassword,ClearPDFFileFormatOptions SetProperty pnPDFEncryption
187
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
ClearPDFSecurity
Description
Clears the PDF file permission security options from the IPNSession object. This includesenabling security, the encryption settings, as well as the PDF file permissions for copyingtext and graphics, printing the document, changing the document by adding contentsuch as pages, comments and form fields. When the PDF security options are not setthrough the IPNSession object, the default options for the PDF Security tab in the PDFImage Printer 10.0 printer's Printing Preferences dialog will be applied to the output fileinstead.
To clear only a single compression option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section for SetPDFSecurity for a list of values.
Syntaxexpression.ClearPDFFileFormatOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("PDF Image Printer 10.0", 2, Nothing, False)
'set pdf security for 128-bit, allow printing and copying but not changing the PDFSession.SetPDFSecurity(True, pnPDFEncryption.pnPDFEncryption128, _ True, True,False, False)...
' reset session for new print Session.ClearPDFSecurity()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("PDF Image Printer 10.0", 1, null, false);
// set pdf security for 128-bit, allow printing and copying but not changing the PDFsession.SetPDFSecurity(True, pnPDFEncryption.pnPDFEncryption128, true, true, false, false);...
// reset session for new print session.ClearPDFSecurity();
Supported Printers: PDF Image Printer 10.0, %SUPDRV_RASTER%>
See Also: SetPDFSecurity SetPDFPassword SetPDFFileFormatOptions ClearPDFPassword,ClearPDFFileFormatOptions SetProperty pnPDFEncryption
PNSrv10 COM Interface
188 PNSrv10 COM Interface Object ReferenceIPNSession
SetResamplingOn
Description
Enables or disables the resampling options. When these options are not set through the IPNSession object the default options for Resampling in the Page Processing tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
Resampling can also be enabled or disabled using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetResamplingOn(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableSet True to enable any resampling options, False to disable them.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Processing
PropertyName: Resample
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.SetResampleOn(True)If bPixels Then Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsPixels, 500, 0, True)ElseIf bPercentage Then Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsPercentage, 150, 0, True)Else Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsDPI, 204, 198, False)End If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
Session.SetPageCropOn(true);if (bCropMargins)
189
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
{ // crop 0.75" margins Session.SetPageCropMarginOptions(pnUnits.pnUnitsEnglish, 0.75, 0.75, 0.75, 0.75);}else{ // crop a 5"x7" area start 2" from both top and left Session.SetPageCropAreaOptions(pnUnits.pnUnitsEnglish, 2.00, 2.00, 5.00, 7.00);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageBrightness SetPageCropAreaOptions SetPageCropMarginOptionsSetPageRotationOptions SetPageTrimOptions ClearPageBrightnessClearPageCropAreaOptions ClearPageCropMarginOptions ClearPageRotationOptionsClearPageTrimOptions SetProperty
SetResamplingOptions
Description
Sets any Resamping options in the IPNSession object. The Resample feature allows youto scale the output image to:
a particular width and height in pixels
a percentage of the original size, ranging from 1% - 500%
a new image resolution (DPI), ranging from 50 DPI - 3600 DPI
If resampling is enabled and these options are not set through the IPNSession object,the default options for the Resample options in the Image Processing tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To set a single resampling option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
For a more detailed explanation of the resampling features, see the User Guide for the PEERNET printer being used.
Syntaxexpression.SetResamplingOptions(Resample, ResampleWidthOrXResolution, ResampleHeightOrYResolution, ResampleLockAspectRatio)
where expression is an IPNSession object.
Parameters
pnResampleUnits ResampleA pnResampleUnits constant for resampling using pixels, percentage or resolution.
Integer ResampleWidthOrXResolutionEnter in the new image width in pixels, as a percentage of the original page size, orthe new x resolution (dots per inch).
PNSrv10 COM Interface
190 PNSrv10 COM Interface Object ReferenceIPNSession
Integer ResampleHeightOrYResolutionEnter in the new image width in pixels, as a percentage of the original page size, orthe new x resolution (dots per inch). If ResampleLockAspectRatio is True, you canpass 0 for the height and it will be calculated automatically to prevent distortion.
Boolean ResampleLockAspectRatioPass True to constrain the image height and width so the image does not getdistorted when resampling.
Remarks
Use the following to set options using SetProperty when Resample ispnResampleUnitsPixels:
Method Parameter SetProperty Parameters
Resample SectionName: Processing
PropertyName: Resample Units
varValue: VT_I4, must be 0
ResampleWidthOrXResolution SectionName: Processing
PropertyName: Resample Pixels Width
varValue: VT_I4Range between 0 - 4294967295
ResampleHeightOrYResolution SectionName: Processing
PropertyName: Resample Pixels Height
varValue: VT_I4Range between 0 - 4294967295
ResampleLockAspectRatio SectionName: Processing
PropertyName: Resample Lock Aspect Ratio
varValue: VT_BOOL
Use the following to set options using SetProperty when Resample ispnResampleUnitsPercentage:
Method Parameter SetProperty Parameters
Resample SectionName: Processing
PropertyName: Resample Units
varValue: VT_UI4, must be 1
ResampleWidthOrXResolution SectionName: Processing
PropertyName: Resample Width Percentage
varValue: VT_UI4Range between 1 - 500
ResampleHeightOrYResolution SectionName: Processing
191
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
PropertyName: Resample Height Percentage
varValue: VT_UI4Range between 1 - 500
ResampleLockAspectRatio SectionName: Processing
PropertyName: Resample Lock Aspect Ratio
varValue: VT_BOOL
Use the following to set options using SetProperty when Resample ispnResampleUnitsDPI:
Method Parameter SetProperty Parameters
Resample SectionName: Processing
PropertyName: Resample Units
varValue: VT_UI4, must be 2
ResampleWidthOrXResolution SectionName: Processing
PropertyName: Resample X DPI
varValue: VT_UI4Range between 50 - 3600
ResampleHeightOrYResolution SectionName: Processing
PropertyName: Resample Y DPI
varValue: VT_UI4Range between 50 - 3600
ResampleLockAspectRatio SectionName: Processing
PropertyName: Resample Lock Aspect Ratio
varValue:
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
Session.SetResamplingOn(True)If bPixels Then Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsPixels, 500, 0, True)ElseIf bPercentage Then Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsPercentage, 150, 0, True)Else Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsDPI, 204, 198, False)End If
PNSrv10 COM Interface
192 PNSrv10 COM Interface Object ReferenceIPNSession
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
Session.SetResamplingOn(true);if (bPixels){ Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsPixels, 500, 0, True);}else if (bPercentage){ Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsPercentage, 150, 0, True);}else{ Session.SetResamplingOptions(pnResamplUnits.pnResamplUnitsDPI, 204, 198, False);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetResamplingOn SetImageCopyToOn SetImageCopyToOptionsClearImageCopyToOptions ClearResamplingOptions SetProperty pnResamplUnits
ClearResamplingOptions
Description
Clears any Resamping options from the IPNSession object. When these options are notset through the IPNSession object, the default options for the Resample options in the Image Processing tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead.
To clear a single resampling option use the SetProperty call with the appropriate sectionand name arguments and pass an empty argument as the property value. See the Remarks section in SetResamplingOn and SetResamplingOptions for a list of values.
Syntaxexpression.ClearResamplingOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
193
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
' reset session for new print Session.ClearResamplingOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearResamplingOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearImageCopyToOptions SetResamplingOn SetResamplingOptionsSetImageCopyToOn SetImageCopyToOptions SetProperty
SetRunAtEndCommand
Description
The Run commands are included for backwards compatibility with previous applicationsusing this method, but new applications should use the IPNSession events to performcustom actions at the appropriate stage. The End of Job run command is replaced withOnEndJob event. The IPNPrintSession's WaitForJobsCompleted can also be used to waitfor the file to be created before moving on to the next file.
Sets any Run at End of Job command options in the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the End of Joboption in the Run tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead. See the User Guide for the printer for full details about the Runcommand capabilities.
To set a single Run at End of Job command option use the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetRunAtEndCommand(Enable, PathToEXE, ExeParameters, WorkingDir, ActivateWnd, WndState, WaitMode, Prompt)
where expression is an IPNSession object.
Parameters
Boolean EnablePass True to enable the Run at End of Job command.
String PathToEXEThe full path to the command you want to launch. A command is limited to 128characters in length, and can be an executable, a file or a DLL.
String ExeParameters
PNSrv10 COM Interface
194 PNSrv10 COM Interface Object ReferenceIPNSession
Any parameters you need to send to your application. A list of parameters is limitedto 255 characters.
String WorkingDirThe default working directory for your application.
Boolean ActivateWndPass True to activate the window in which your application runs.
pnRunCommandWindowState WndStateA pnRunCommandWindowState constant for the window state of the application youare running.
pnRunCommandsWaitMode WaitModeA pnRunCommandsWaitMode constant for the wait mode on the command.
String PromptA string to prompt if the WaitMode is pnRunCommandsWaitModePromptToContinue.Pass an empty string for the other wait modes.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Run
PropertyName: RunAtEnd enable
varValue: VT_BOOL
PathToEXE SectionName: Run
PropertyName: RunAtEnd command
varValue: VT_BSTR, as above
ExeParameters SectionName: Run
PropertyName: RunAtEnd parameters
varValue: VT_BSTR, as above
WorkingDir SectionName: Run
PropertyName: RunAtEnd directory
varValue: VT_BSTR, as above
ActivateWnd SectionName: Run
PropertyName: RunAEnd window active
varValue: VT_BOOL
WndState SectionName: Run
PropertyName: RunAtEnd window
varValue: VT_BSTR, one of the following:NormalMinimizedMaximized
195
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
Hidden
WaitMode = pnRunCommandsWaitModeCompletion
SectionName: Run
PropertyName: RunAtEnd wait
varValue: VT_I4, must be 0
WaitMode = pnRunCommandsWaitModeWaitWithExit
SectionName: Run
PropertyName: RunAtEnd wait
varValue: VT_I4, must be 1
WaitMode = pnRunCommandsWaitModeDoNotWait
SectionName: Run
PropertyName: RunAtEnd wait
varValue: VT_I4, must be 2
WaitMode = pnRunCommandsWaitModePromptToContinue
SectionName: Run
PropertyName: RunAtEnd wait
varValue: VT_I4, must be 3
Prompt SectionName: Run
PropertyName: RunAtEnd prompt
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' call custom ftp upload program with new file to upload, do not wait for itSession.SetRunAtEndCommand(True, "C:\TIFFSender\FTPUploadFile.exe", _ "$(OutputFilename)", "", False, _ pnRunCommandWindowState.pnRunCommandWindowStateHidden, _ pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "")
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// call custom ftp upload program with new file to upload, do not wait for itsession.SetRunAtEndCommand(True, "C:\\TIFFSender\\FTPUploadFile.exe", "$(OutputFilename)", "", False,
PNSrv10 COM Interface
196 PNSrv10 COM Interface Object ReferenceIPNSession
pnRunCommandWindowState.pnRunCommandWindowStateHidden, pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "");
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: OnEndJob SetRunAtStartCommand SetRunAtPageCommandSetRunAtFileCloseCommand ClearRunAtStartCommand ClearRunAtPageCommandClearRunAtFileCloseCommand ClearRunAtEndCommand SetPropertypnRunCommandWindowState pnRunCommandsWaitMode
ClearRunAtEndCommand
Description
Clears any RunAtEnd command options from the IPNSession object. When these optionsare not set through the IPNSession object, the default options for the End of Job optionin the Run tab in the PEERNET printer's Printing Preferences dialog will be applied to theoutput file instead.
To clear a single RunAtEnd command option use the SetProperty call with theappropriate section and name arguments and pass an empty argument as the propertyvalue. See the Remarks section in SetRunAtEndCommand for a list of values.
Syntaxexpression.ClearRunAtEndCommand()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearRunAtEndCommand()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearRunAtEndCommand();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF Image
197
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Printer 10.0
See Also: ClearRunAtStartCommand ClearRunAtPageCommandClearRunAtFileCloseCommand SetRunAtStartCommand SetRunAtPageCommandSetRunAtFileCloseCommand SetRunAtEndCommand SetProperty
SetRunAtFileCloseCommand
Description
The Run commands are included for backwards compatibility with previous applicationsusing this method, but new applications should use the IPNSession events to performcustom actions at the appropriate stage. The File Close run command is replaced withthe OnCloseFile event.
Sets any Run at File Close command options in the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the File Closeoption in the Run tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead. See the User Guide for the printer for full details about the Runcommand capabilities.
To set a single Run at File Close command option use the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetRunAtFileCloseCommand(Enable, PathToEXE, ExeParameters, WorkingDir, ActivateWnd, WndState, WaitMode, Prompt)
where expression is an IPNSession object.
Parameters
Boolean EnablePass True to enable the Run at File Close command.
String PathToEXEThe full path to the command you want to launch. A command is limited to 128characters in length, and can be an executable, a file or a DLL.
String ExeParametersAny parameters you need to send to your application. A list of parameters is limitedto 255 characters.
String WorkingDirThe default working directory for your application.
Boolean ActivateWndPass True to activate the window in which your application runs.
pnRunCommandWindowState WndStateA pnRunCommandWindowState constant for the window state of the application youare running.
pnRunCommandsWaitMode WaitMode
PNSrv10 COM Interface
198 PNSrv10 COM Interface Object ReferenceIPNSession
A pnRunCommandsWaitMode constant for the wait mode on the command.
String PromptA string to prompt if the WaitMode is pnRunCommandsWaitModePromptToContinue.Pass an empty string for the other wait modes.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Run
PropertyName: RunAtFile enable
varValue: VT_BOOL
PathToEXE SectionName: Run
PropertyName: RunAtFile command
varValue: VT_BSTR, as above
ExeParameters SectionName: Run
PropertyName: RunAtFile parameters
varValue: VT_BSTR, as above
WorkingDir SectionName: Run
PropertyName: RunAtFile directory
varValue: VT_BSTR, as above
ActivateWnd SectionName: Run
PropertyName: RunAtFile window active
varValue: VT_BOOL
WndState SectionName: Run
PropertyName: RunAtFile window
varValue: VT_BSTR, one of the following:NormalMinimizedMaximizedHidden
WaitMode = pnRunCommandsWaitModeCompletion
SectionName: Run
PropertyName: RunAtFile wait
varValue: VT_I4, must be 0
WaitMode = pnRunCommandsWaitModeWaitWithExit
SectionName: Run
PropertyName: RunAtFile wait
varValue: VT_I4, must be 1
199
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
WaitMode = pnRunCommandsWaitModeDoNotWait
SectionName: Run
PropertyName: RunAtFile wait
varValue: VT_I4, must be 2
WaitMode = pnRunCommandsWaitModePromptToContinue
SectionName: Run
PropertyName: RunAtFile wait
varValue: VT_I4, must be 3
Prompt SectionName: Run
PropertyName: RunAtFile prompt
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' call custom ftp upload program with new file to upload, do not wait for it' called once when doing multipage output, or on each page for serialized outputSession.SetRunAtFileCloseCommand(True, "C:\TIFFSender\FTPUploadFile.exe", _ "$(OutputFilename)", "", False, _ pnRunCommandWindowState.pnRunCommandWindowStateHidden, _ pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "")
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// call custom ftp upload program with new file to upload, do not wait for it// called once when doing multipage output, or on each page for serialized outputsession.SetRunAtFileCloseCommand(True, "C:\\TIFFSender\\FTPUploadFile.exe", "$(OutputFilename)", "", False, pnRunCommandWindowState.pnRunCommandWindowStateHidden, pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "");
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: OnCloseFile SetRunAtStartCommand SetRunAtPageCommandSetRunAtEndCommand ClearRunAtStartCommand ClearRunAtPageCommand ClearRunAtFileCloseCommand ClearRunAtEndCommand SetPropertypnRunCommandWindowState pnRunCommandsWaitMode
PNSrv10 COM Interface
200 PNSrv10 COM Interface Object ReferenceIPNSession
ClearRunAtFileCloseCommand
Description
Clears any run at file close command options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the File closeoption in the Run tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead.
To clear a single file close command option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetRunAtFileCloseCommand for a list of values.
Syntaxexpression.ClearRunAtFileCloseCommand()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearRunAtFileCloseCommand()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearRunAtFileCloseCommand();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearRunAtStartCommand ClearRunAtPageCommand ClearRunAtEndCommandSetRunAtStartCommand SetRunAtPageCommand SetRunAtFileCloseCommandSetRunAtEndCommand SetProperty
SetRunAtPageCommand
Description
The Run commands are included for backwards compatibility with previous applicationsusing this method, but new applications should use the IPNSession events to perform
201
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
custom actions at the appropriate stage. The Each Page run command is replaced withthe OnStartPage and OnEndPage events.
Sets any Run at Each Page command options in the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the Each Pageoption in the Run tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead. See the User Guide for the printer for full details about the Runcommand capabilities.
To set a single Run at Each Page command option use the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetRunAtFileCloseCommand(Enable, PathToEXE, ExeParameters, WorkingDir, ActivateWnd, WndState, WaitMode, Prompt)
where expression is an IPNSession object.
Parameters
Boolean EnablePass True to enable the Run at Each Page command.
String PathToEXEThe full path to the command you want to launch. A command is limited to 128characters in length, and can be an executable, a file or a DLL.
String ExeParametersAny parameters you need to send to your application. A list of parameters is limitedto 255 characters.
String WorkingDirThe default working directory for your application.
Boolean ActivateWndPass True to activate the window in which your application runs.
pnRunCommandWindowState WndStateA pnRunCommandWindowState constant for the window state of the application youare running.
pnRunCommandsWaitMode WaitModeA pnRunCommandsWaitMode constant for the wait mode on the command.
String PromptA string to prompt if the WaitMode is pnRunCommandsWaitModePromptToContinue.Pass an empty string for the other wait modes.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Run
PropertyName: RunAtPage enable
PNSrv10 COM Interface
202 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
varValue: VT_BOOL
PathToEXE SectionName: Run
PropertyName: RunAtPage command
varValue: VT_BSTR, as above
ExeParameters SectionName: Run
PropertyName: RunAtPage parameters
varValue: VT_BSTR, as above
WorkingDir SectionName: Run
PropertyName: RunAtPage directory
varValue: VT_BSTR, as above
ActivateWnd SectionName: Run
PropertyName: RunAtPage window active
varValue: VT_BOOL
WndState SectionName: Run
PropertyName: RunAtPage window
varValue: VT_BSTR, one of the following:NormalMinimizedMaximizedHidden
WaitMode = pnRunCommandsWaitModeCompletion
SectionName: Run
PropertyName: RunAtPage wait
varValue: VT_I4, must be 0
WaitMode = pnRunCommandsWaitModeWaitWithExit
SectionName: Run
PropertyName: RunAtPage wait
varValue: VT_I4, must be 1
WaitMode = pnRunCommandsWaitModeDoNotWait
SectionName: Run
PropertyName: RunAtPage wait
varValue: VT_I4, must be 2
WaitMode = pnRunCommandsWaitModePromptToContinue
SectionName: Run
PropertyName: RunAtPage wait
varValue: VT_I4, must be 3
203
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
Prompt SectionName: Run
PropertyName: RunAtPage prompt
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' echo the current page number out to a text file using a ' MS_Dos batch fileSession.SetRunAtPageCommand(True, "C:\Utils\EchoPage.bat", _ "$(FilePageNumber)", "", False, _ pnRunCommandWindowState.pnRunCommandWindowStateHidden, _ pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "")
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
' echo the current page number out to a text file using a ' MS_Dos batch filesession.SetRunAtPageCommand(true, "C:\\Utils\\EchoPage.bat", "$(FilePageNumber)", "", False, pnRunCommandWindowState.pnRunCommandWindowStateHidden, pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "");
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: OnStartPage OnEndPage SetRunAtStartCommand SetRunAtFileCloseCommandSetRunAtEndCommand ClearRunAtStartCommand ClearRunAtPageCommandClearRunAtFileCloseCommand ClearRunAtEndCommand SetPropertypnRunCommandWindowState pnRunCommandsWaitMode
ClearRunAtPageCommand
Description
Clears any run at page command options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the Each pageoption in the Run tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead.
To clear a single run at page command option use the SetProperty call with theappropriate section and name arguments and pass an empty argument as the property
PNSrv10 COM Interface
204 PNSrv10 COM Interface Object ReferenceIPNSession
value. See the Remarks section in SetRunAtPageCommand for a list of values.
Syntaxexpression.ClearRunAtPageCommand()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearRunAtPageCommand()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearRunAtPageCommand();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearRunAtStartCommand ClearRunAtFileCloseCommandClearRunAtEndCommand SetRunAtStartCommand SetRunAtPageCommandSetRunAtFileCloseCommand SetRunAtEndCommand SetProperty
SetRunAtStartCommand
Description
The Run commands are included for backwards compatibility with previous applicationsusing this method, but new applications should use the IPNSession events to performcustom actions at the appropriate stage. The Start of Job run command is replaced withthe OnStartJob event.
Sets any Run at Start of Job command options in the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the Start of Joboption in the Run tab in the PEERNET printer's Printing Preferences dialog will be appliedto the output file instead. See the User Guide for the printer for full details about the Runcommand capabilities.
To set a single Run at Start of Job command option use the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
205
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Syntaxexpression.SetRunAtStartCommand(Enable, PathToEXE, ExeParameters, WorkingDir, ActivateWnd, WndState, WaitMode, Prompt)
where expression is an IPNSession object.
Parameters
Boolean EnablePass True to enable the Run at Start of Job command.
String PathToEXEThe full path to the command you want to launch. A command is limited to 128characters in length, and can be an executable, a file or a DLL.
String ExeParametersAny parameters you need to send to your application. A list of parameters is limitedto 255 characters.
String WorkingDirThe default working directory for your application.
Boolean ActivateWndPass True to activate the window in which your application runs.
pnRunCommandWindowState WndStateA pnRunCommandWindowState constant for the window state of the application youare running.
pnRunCommandsWaitMode WaitModeA pnRunCommandsWaitMode constant for the wait mode on the command.
String PromptA string to prompt if the WaitMode is pnRunCommandsWaitModePromptToContinue.Pass an empty string for the other wait modes.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Run
PropertyName: RunAtStart enable
varValue: VT_BOOL
PathToEXE SectionName: Run
PropertyName: RunAtStart command
varValue: VT_BSTR, as above
ExeParameters SectionName: Run
PropertyName: RunAtStart parameters
varValue: VT_BSTR, as above
WorkingDir SectionName: Run
PNSrv10 COM Interface
206 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
PropertyName: RunAtStart directory
varValue: VT_BSTR, as above
ActivateWnd SectionName: Run
PropertyName: RunAtStart window active
varValue: VT_BOOL
WndState SectionName: Run
PropertyName: RunAtStart window
varValue: VT_BSTR, one of the following:NormalMinimizedMaximizedHidden
WaitMode = pnRunCommandsWaitModeCompletion
SectionName: Run
PropertyName: RunAtStart wait
varValue: VT_I4, must be 0
WaitMode = pnRunCommandsWaitModeWaitWithExit
SectionName: Run
PropertyName: RunAtStart wait
varValue: VT_I4, must be 1
WaitMode = pnRunCommandsWaitModeDoNotWait
SectionName: Run
PropertyName: RunAtStart wait
varValue: VT_I4, must be 2
WaitMode = pnRunCommandsWaitModePromptToContinue
SectionName: Run
PropertyName: RunAtStart wait
varValue: VT_I4, must be 3
Prompt SectionName: Run
PropertyName: RunAtStart prompt
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
207
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
' Run the cleanup program before starting the next fileSession.SetRunAtPageCommand(True, "C:\Utils\CleanFolders.exe", _ "$(OutputDir)", "", False, _ pnRunCommandWindowState.pnRunCommandWindowStateHidden, _ pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "")
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Run the cleanup program before starting the next filesession.SetRunAtPageCommand(True, "C:\\Utils\\CleanFolders.exe", "$(OutputDir)", "", False, pnRunCommandWindowState.pnRunCommandWindowStateHidden, pnRunCommandsWaitMode.pnRunCommandsWaitModeDoNotWait, "");
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: OnStartJob SetRunAtPageCommand SetRunAtFileCloseCommandSetRunAtEndCommand ClearRunAtStartCommand ClearRunAtPageCommandClearRunAtFileCloseCommand ClearRunAtEndCommand SetPropertypnRunCommandWindowState pnRunCommandsWaitMode
ClearRunAtStartCommand
Description
Clears any run at start command options from the IPNSession object. When theseoptions are not set through the IPNSession object, the default options for the Start ofjob option in the Run tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
To clear a single run at start command option use the SetProperty call with theappropriate section and name arguments and pass an empty argument as the propertyvalue. See the Remarks section in SetRunAtStartCommand for a list of values.
Syntaxexpression.ClearRunAtStartCommand()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
PNSrv10 COM Interface
208 PNSrv10 COM Interface Object ReferenceIPNSession
' reset session for new print Session.ClearRunAtStartCommand()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearRunAtStartCommand();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ClearRunAtPageCommand ClearRunAtFileCloseCommandClearRunAtEndCommand SetRunAtStartCommand SetRunAtPageCommandSetRunAtFileCloseCommand SetRunAtEndCommand SetProperty
SetSaveOptions
Description
Sets the file save options on the IPNSession object. When these options are not setthrough the IPNSession object, the default options for the Save tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To set a single save option use the SetProperty call with the appropriate arguments. Seethe Remarks below for a list of arguments.
For a more detailed explanation of the file naming options, see the User Guide for the PEERNET printer being used.
Syntaxexpression.SetFileNamingOptions(Directory, BaseFilename, OutputFileFormat, Append, ColorReduction, Dithering, UseJobID, PromptForFileName, OverwriteAlways, RemoveExt, RemoveProdName,DeleteAtEnd)
where expression is an IPNSession object.
Parameters
String DirectoryPass the fully qualified path to the directory for storing the output your files. If thisstring is empty, the Documents folder of the currently logged in user is used to storethe files.
String BaseFilenameThis is the base filename for your output file. The base filename excludes anydirectory path and file extension. If you want your output files to always be savedunder the same filename, enter that name here.If this field is empty the print job
209
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
name the printing application uses when submitting the file to the printer is usedinstead.
pnOutputFileFormat OutputFileFormatA pnOutputFileFormat constant for the possible types of files that can be created withany of the supported printer drivers. Not all file formats are valid for all drivers.
Boolean AppendSet this to True to append, or concatenate, the pages to an existing output file or, ifyou are creating serialized files, an existing sequence of files.
pnColorReduction ColorReductionA pnColorReduction constant for any color reduction options to apply to the outputfile. There are eight color reduction options available for reducing the number ofcolors in true color images. In general, the fewer the colors in an image, the smallerthe file size.
pnDitheringMethod DitheringA pnDitheringMethod constant to determine the method used when reducing colorimages to black and white. Dithering is used to enhance the appearance of colorimages that have been reduced to black and white.
Boolean UseJobIDA JobID is associated with every printer and is initially set to zero. It is automaticallyincremented by the printer at the start of every print job.The JobID is often used toensure that all files created have unique names. It is also used to determine whichnaming profile to use.
Boolean PromptForFileNameSet to True to show the printer's Save Image dialog prompt, or False to hide theprompt and use the Directroy and BaseFilename settings to create the filename.
Boolean OverwriteAlwaysSet to True to overwrite existing files without prompting, or False to be prompted toconfirm the overwrite action or to provide a new filename.
Boolean bRemoveExtSet to True to automatically remove any file extension passed to the printer as partof the filename.
Boolean RemoveProdNameSet to True to automatically remove any product names that are added to theprinted filename by the printing application.Product names are any text that precedesthe following characters: a space, a dash and a space (" - ").
Boolean DeleteAtEndSet to True to automatically delete all output files at the end of the print job, afterany final Run command.This option is useful if you are want to send the output byemail without leaving any local copies.
Remarks
Use the following to set these options using SetProperty:
PNSrv10 COM Interface
210 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
Directory SectionName: Save
PropertyName: Output directory
varValue: VT_BSTR, as above
BaseFilename SectionName: Save
PropertyName: Output filename
varValue: VT_BSTR, as above
OutputFileFormat SectionName: Save
PropertyName: Output File Format
varValue: VT_BSTR, one of the following driver-dependant values:
JPEGTIFF MultipagedTIFF SerializedAdobe PDF MultipagedAdobe PDF SerializedCompuServe GIFCompuServe PNGWindows BMPTARGAAdobe Photoshop 3.0ZSoft PCXZSoft DCX
Append SectionName: Save
PropertyName: Append
varValue: VT_BOOL
ColorReduction SectionName: Save
PropertyName: Color reduction
varValue: VT_BSTR, one of the following:noneOptimalBWgrey256Colors16ColorsoptimalMax256ColorsoptimalMax16Colors
Dithering SectionName: Save
PropertyName: Dithering Method
varValue: VT_BSTR, one of the following:NoneFloydBurkes
211
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
BayerHalftone
UseJobID SectionName: Save
PropertyName: Use JobID
varValue: VT_BOOL
PromptForFileName SectionName: Save
PropertyName: Prompt
varValue: VT_BOOL
OverwriteAlways SectionName: Save
PropertyName: Overwrite
varValue: VT_BOOL
RemoveExt SectionName: Save
PropertyName: Remove filename extension
varValue: VT_BOOL
RemoveProdName SectionName: Save
PropertyName: Remove product name
varValue: VT_BOOL
DeleteAtEnd SectionName: Save
PropertyName: Delete files
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
bAppend = cbAppendTogether.Checked
' set name and save location, create multipage tiff and append all into a single fileSession.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, bAppend, _ pnColorReductionOptimal, pnDitheringHalftone, _ False, False, True, True, True, False)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
bAppend = cbAppendTogether.Checked;
PNSrv10 COM Interface
212 PNSrv10 COM Interface Object ReferenceIPNSession
// set name and save location, create multipage tiff and append all into a single filesession.SetFileNamingOptions("C:\\TIFFOutput\\","TIFFReport", pnOutputFileFormatTIFFMultipaged, bAppend, pnColorReductionOptimal, pnDitheringHalftone false, false, true, true, true, false);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetNamingProfileFormat ClearSaveOptions ClearNamingProfileFormatSetProperty
ClearSaveOptions
Description
Clears any file save options from the IPNSession object. When these options are not setthrough the IPNSession object, the default options for the the Save tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To clear a single file save option use the SetProperty call with the appropriate sectionand name arguments as shown in SetSaveOptions and pass an empty argument as theproperty value.
Syntaxexpression.ClearFileNamingOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearSaveOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);...
// reset session for new print session.ClearSaveOptions();
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
213
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
See Also: ClearNamingProfileFormat SetSaveOptions SetNamingProfileFormat SetProperty
SetSMTPEmailService
Description
Configures the SMTP email service options. These options will only take effect if the SetEmailService method has been set to use SMTP. This option does not require an emailclient to be installed, but it does require an SMTP-capable server and e-mail address.
These settings are only applied when the email options are enabled. If the email optionsare enabled and there are no email service options set through the IPNSession object thedefault options for the Advanced Email Settings... button on the Email tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
The SMTP email options can also be set using the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetSMTPEmailService(Email, Server)
where expression is an IPNSession object.
Parameters
String EmailThe SMTP capable email address provided by your administrator.
String ServerThe name of the SMTP server provided by your administrator.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Email SectionName: Email Advanced
PropertyName: SMTP address
varValue: VT_BSTR, as above
Server SectionName: Email Advanced
PropertyName: SMTP server
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession
PNSrv10 COM Interface
214 PNSrv10 COM Interface Object ReferenceIPNSession
Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Email settingsSession.SetEmailOn(True)Session.SetEmailMessageOptions("[email protected]", _ "[email protected]", _ "", "Test COM Email", _ "Please review the attached files.", _ "C:\Outgoing\Memo.doc")
If ( bUseMAPI ) Then Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, _ pnEmailDialog.pnEmailDialogClient) Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, _ True)Else ' SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, _ pnEmailDialog.pnEmailDialogStandard) Session.SetSMTPEmailService("[email protected]", _ "SMTPServerName")End If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
...
// Email settingsSession.SetEmailOn(True);Session.SetEmailMessageOptions("[email protected]", "[email protected]", "", "Test COM Email", "Please review the attached files.", "C:\Outgoing\Memo.doc");
if ( bUseMAPI ){ Session.SetEmailService(pnEmailService.pnEmailServiceMAPI, pnEmailDialog.pnEmailDialogClient); Session.SetMAPIEmailService(pnMAPIEmailLogon.pnMAPIEmailLogonWhenNeeded, True);}else{ // SMTP Session.SetEmailService(pnEmailService.pnEmailServiceSMTP, pnEmailDialog.pnEmailDialogStandard); Session.SetSMTPEmailService("[email protected]", "SMTPServerName");}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetEmailOn SetEmailMessageOptions SetEmailService SetMAPIEmailServiceSetVIMEmailService ClearEmailMessageOptions ClearEmailService SetProperty
215
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
SetTextExtractionOn
Description
Enables or disables the text extraction options.Text extraction creates a separate text filecontaining all of the textual elements of your printed documents.
When these options are not set through the IPNSession object the default options forText Extraction in the Text Extraction tab in the PEERNET printer's Printing Preferencesdialog will be applied to the output file instead.
Text extraction can also be enabled or disabled using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetTextExtractionOn(Enable)
where expression is an IPNSession object.
Parameters
Boolean EnableSet True to enable any text extraction options, False to disable them.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Advanced Features
PropertyName: Extract Text
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' create text extraction file, stored in same location ' and with same base name as output fileSession.SetTextExtractionOn(True)Session.SetTextExtractionOptions("", pnTextLayout.pnTextLayoutPhysical, _ pnTextEncoding.pnTextEncodingUTF16, _ pnTextEOL.pnTextEOLWindows, True)
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// create text extraction file, stored in same location
PNSrv10 COM Interface
216 PNSrv10 COM Interface Object ReferenceIPNSession
// and with same base name as output fileSession.SetTextExtractionOn(True)lSession.SetTextExtractionOptions("", pnTextLayout.pnTextLayoutPhysical, pnTextEncoding.pnTextEncodingUTF16, pnTextEOL.pnTextEOLWindows, True);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetTextExtractionOptions ClearTextExtractionOptions SetProperty
SetTextExtractionOptions
Description
Sets the text extraction options.Text extraction creates a separate text file containing allof the textual elements of your printed documents. The text extraction feature was notdesigned to be Optical Character Recognition (OCR) software. Only straight text will beextracted and formatting of the text file may not be exact.
If text extraction is enabled and these options are not set through the IPNSession objectthe default options for Text Extraction in the Text Extraction tab in the PEERNETprinter's Printing Preferences dialog will be applied to the output file instead.
To set a single text extraction options use the SetProperty call with the appropriatearguments.
Syntaxexpression.SetTextExtractionOptions(TextFilePath, TextLayout, TextEncoding, TextEOL, EmitPageBreaks)
where expression is an IPNSession object.
Parameters
String TextFilePathThe full path to the text extraction file. If an empty string is passed the textextraction files will be matched with the name of the output files, with a .txtextension.
pnTextLayout TextLayoutA pnTextLayout constant to determine how the text in your text extraction file isformatted.
pnTextEncoding TextEncodingA pnTextEncoding constant to determine the encoding for your text file.
pnTextEOL TextEOLA pnTextEOL constant to determine the end of line (EOL) encoding for your text file.This differs between Windows, Unix and Macintosh systems.
Boolean EmitPageBreaksPass True to emit page breaks (or form feeds) for every page in your document.
217
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Remarks
See the Remarks below for a list of arguments.
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
TextFilePath SectionName: Advanced Features
PropertyName: Extract Text Filepath
varValue: VT_BSTR, as above
TextLayout SectionName: Advanced Features
PropertyName: Extract Text Layout
varValue: VT_BSTR, one of the following:Physical, Raw, None
TextEncoding SectionName: Advanced Features
PropertyName: Extract Text Encoding
varValue: VT_BSTR, one of the following:ANSI, UTF-8, UTF-16
TextEOL SectionName: Advanced Features
PropertyName: Extract Text EOL
varValue: VT_BSTR, one of the following:Windows, Mac, Unix
EmitPageBreaks SectionName: Advanced Features
PropertyName: Extract Text Emit Page Breaks
varValue: VT_BOOL, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' create text extraction file, stored in same location ' and with same base name as output fileSession.SetTextExtractionOn(True)Session.SetTextExtractionOptions("", pnTextLayout.pnTextLayoutPhysical, _ pnTextEncoding.pnTextEncodingUTF16, _ pnTextEOL.pnTextEOLWindows, True)
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
PNSrv10 COM Interface
218 PNSrv10 COM Interface Object ReferenceIPNSession
// create text extraction file, stored in same location// and with same base name as output filesession.SetTextExtractionOn(True)lsession.SetTextExtractionOptions("", pnTextLayout.pnTextLayoutPhysical, pnTextEncoding.pnTextEncodingUTF16, pnTextEOL.pnTextEOLWindows, True);
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetTextExtractionOn ClearTextExtractionOptions SetProperty pnTextLayoutpnTextEncoding pnTextEOL
ClearTextExtractionOptions
Description
Clears any text extraction options from the IPNSession object. When these options arenot set through the IPNSession object, the default options for the Text Extraction sectionon the Text Extraction tab in the PEERNET printer's Printing Preferences dialog will beapplied to the output file instead.
To clear a only a text extraction option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetTextExtractionOn and SetTextExtractionOptions for a list ofvalues.
Syntaxexpression.ClearTextExtractionOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearTextExtractionOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearTextExtractionOptions();
219
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetTextExtractionOn SetTextExtractionOptions SetProperty
SetTIFFAdvancedOptions
Description
Sets the advanced TIFF options on the IPNSession object. These options include bothmonochrome-specific options sometimes needed by older fax printers and some generalTIFF options that apply to all TIFF output.
When these options are not set through the IPNSession object, the default options forthe TIFF Monochrome Options and the TIFF General Options on the Fax/TIFF or Fax tabin the PEERNET printer's Printing Preferences dialog will be applied to the output fileinstead.
To set a single TIFF advanced option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetTIFFAdvancedOptions(ReverseBits, EOLByteAlign, InvertPhotometric, IncludeDateTime, MotorolaFormat)
where expression is an IPNSession object.
Parameters
Boolean ReverseBitsAlso known as fill order, pass True to store the image data in least significant bit tomost significant bit (LSB to MSB) order, or False to store the bits in most significantbit to least significant bit (MSB to LSB) order.
Boolean EOLByteAlignPass True to align rows of CCITT Group 3 1D and 2D image data on wordboundaries.
Boolean InvertPhotometric The photometric interpretation option determines the order of the black and whitepalette entries for a monochrome TIFF file. Pass True to invert the palette entries(MINISBLACK, the palette entry for 0 is black) and create a TIFF with white text on ablack background. Pass False (MINISWHITE, the palette entry for 0 is white) tocreate a TIFF with black text on a white background.
Boolean IncludeDateTimePass True to have the creation time and date added to your outputted TIFF file.
Boolean MotorolaFormatPass True to create TIFF images using Motorola (big-endian) byte order. The defaultformat is Intel (little-endian) byte order.
Remarks
PNSrv10 COM Interface
220 PNSrv10 COM Interface Object ReferenceIPNSession
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
ReverseBits SectionName: Image Options
PropertyName: Fill order
varValue: VT_BSTR, one of the followingLSB2MSB, MSB2LSB
EOLByteAlign SectionName: Image Options
PropertyName: EOLs Byte Aligned
varValue: VT_BOOL
InvertPhotometric SectionName: Image Options
PropertyName: Photometric
varValue: VT_BSTR, one of the following:MINISWHITE, MINISBLACK
IncludeDateTime SectionName: Image Options
PropertyName: Include DateTime
varValue: VT_BOOL
MotorolaFormat SectionName: Image Options
PropertyName: Motorola Format
varValue: VT_BOOL
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
'set fax mode
Session.SetFaxModeOn(True)Session.SetTIFFAdvancedOptions(False, True, False, True, False)Session.SetFaxOptions(pnFaxProfile.pnFaxProfileF, pnFaxResolution.pnFaxResolution204x196, _ pnFaxPaperWidth.pnFaxPaperWidthLetter, _ pnFaxPaperHeight.pnFaxPaperHeightFixed, _ pnFaxPageScaling.pnFaxPageScalingFitToPage, _ pnFaxPageScalingHAlign.pnFaxPageScalingHAlignMiddle, _ pnFaxPageScalingVAlign.pnFaxPageScalingVAlignMiddle, _ True, True, True)
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// set fax modeSession.SetFaxModeOn(true);
221
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Session.SetTIFFAdvancedOptions(False, True, False, True, False);Session.SetFaxOptions(pnFaxProfile.pnFaxProfileF, pnFaxResolution.pnFaxResolution204x196, pnFaxPaperWidth.pnFaxPaperWidthLetter, pnFaxPaperHeight.pnFaxPaperHeightFixed, pnFaxPageScaling.pnFaxPageScalingFitToPage, pnFaxPageScalingHAlign.pnFaxPageScalingHAlignMiddle, pnFaxPageScalingVAlign.pnFaxPageScalingVAlignMiddle, true, true, true);
Supported Printers: TIFF Image Printer 10.0, Raster Image Printer 10.0
See Also: SetFaxModeOn SetFaxOptions SetTIFFCompressionOptionsClearTIFFAdvancedOptions ClearFaxOptions ClearTIFFAdvancedOptions SetProperty
ClearTIFFAdvancedOptions
Description
Clears any advanced TIFF options from the IPNSession object. When these options arenot set through the IPNSession object, the default options for TIFF Monochorome Optionsand the TIFF General Options on the Fax/TIFF or Fax tab in the PEERNET printer'sPrinting Preferences dialog will be applied to the output file instead.
To clear a single TIFF output option use the SetProperty call with the appropriate sectionand name arguments and pass an empty argument as the property value. See the Remarks section in SetTIFFAdvancedOptions for a list of values.
Syntaxexpression.ClearTIFFAdvancedOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearTIFFAdvancedOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearTIFFAdvancedOptions();
PNSrv10 COM Interface
222 PNSrv10 COM Interface Object ReferenceIPNSession
Supported Printers: TIFF Image Printer 10.0, Raster Image Printer 10.0
See Also: ClearFaxOptions ClearTIFFCompressionOptions SetTIFFAdvancedOptionsSetTIFFCompressionOptions SetFaxModeOn SetFaxOptions SetProperty
SetTIFFCompressionOptions
Description
Sets the TIFF compression options used to store the image in the output file. The actualcompression method used on each page will depend on the color reduction methodchosen through the SetSaveOptions method. Other output options used, such asSetFaxImageOptions may also override any settings chosen here.
To set only a single compression option use the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetTIFFCompressionOptions(Color, Indexed, Greyscale, BW)
where expression is a IPNSession object.
Parameters
pnColorCompressionMethod ColorA pnColorCompressionMethod constant for the compression method to use for colorimages.
pnIndexedCompressionMethod IndexedA pnIndexedCompressionMethod constant for the compression method to use forindexed images. An indexed image is an image that has 256 colors or less.
pnGreyscaleCompressionMethod GreyscaleA pnGreyscaleCompressionMethod constant for the compression method to use forgreyscale images.
pnBWCompressionMethod BWA pnBWCompressionMethod constant for the compression method to use for blackand white images.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
Color SectionName: TIFF File Format
PropertyName: Color compression
varValue: VT_BSTR, one of the following:Uncompressed RGBUncompressed CMYKPackbits RGB
223
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
Packbits CMYKHigh quality JPEGMedium quality JPEGLow quality JPEGLZW RGBLZW CMYK
Indexed SectionName: TIFF File Format
PropertyName: Indexed compression
varValue: VT_BSTR, one of the following:UncompressedPackbitsHigh quality JPEGMedium quality JPEGLow quality JPEGLZW
Greyscale SectionName: TIFF File Format
PropertyName: Greyscale compression
varValue: VT_BSTR, one of the following:UncompressedPackbitsHigh quality JPEGMedium quality JPEGLow quality JPEGLZW
BW SectionName: TIFF File Format
PropertyName: BW compression
varValue: VT_BSTR, one of the following:NoneGroup4Group3-2DGroup3-1DMHLZWPackbits
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession ' allocate a sessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Set the file output options' Reduce to optimal 256, dithering set to Floyd, use LZW compression Session.SetSaveOptions("C:\TIFFOutput\", "TIFFReport", _ pnOutputFileFormatTIFFMultipaged, False, _
PNSrv10 COM Interface
224 PNSrv10 COM Interface Object ReferenceIPNSession
pnColorReductionOptimalMax256Colors, pnDitheringFloyd, _ False, False, True, True, True, False)
Session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, _ pnIndexedCompressionMethod.pnIndexedCompressionLZW, _ pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, _ pnBWCompressionMethod.pnBWCompressionGroup4)
C#
PNSession session = null;
session = new PNSession();// allocate a sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// Set the file output options// Reduce to optimal 256, dithering set to Floyd, use LZW compression session.SetSaveOptions("C:\\TIFFOutput\\", "TIFFReport", pnOutputFileFormatTIFFMultipaged, false, pnColorReductionOptimalMax256Colors, pnDitheringFloyd, false, false, true, true, true, false)
session.SetTIFFCompressionOptions(pnColorCompressionMethod.pnColorCompressionLZW, pnIndexedCompressionMethod.pnIndexedCompressionLZW, pnGreyscaleCompressionMethod.pnGreyscaleCompressionLZW, pnBWCompressionMethod.pnBWCompressionGroup4);
Supported Printers: TIFF Image Printer 10.0, Raster Image Printer 10.0
See Also: ClearTIFFCompressionOptions SetProperty pnColorColorCompressionMethodpnIndexedCompressionMethod pnGreyscaleCompressionMethod pnBWCompressionMethod
ClearTIFFCompressionOptions
Description
Clears the TIFF image compression options for color, indexed, grayscale and black andwhite output from the IPNSession object. When the compression options are not setthrough the IPNSession object, the default options for the Compression tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
To clear only a single compression option use the SetProperty call with the appropriatesection and name arguments and pass an empty argument as the property value. Seethe Remarks section in SetCompressionOptions for a list of values.
Syntaxexpression.ClearCompressionOptions()
where expression is an IPNSession object.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSession
225
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print Session.ClearCompressionOptions()
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new print session.ClearCompressionOptions();
Supported Printers: TIFF Image Printer 10.0, Raster Image Printer 10.0
See Also: SetTIFFCompressionOptions SetProperty
SetUserExit32
Description
Sets a user exit callback for a 32-bit application. A user exit calls a function contained ina dynamic link library (DLL) that you have created. The function is invoked when anapplication starts to print and gives you an opportunity to augment the information orgather additional information that needs to be part of this conversion process.
The user exits are are included for backwards compatibility with previous applicationsusing this method, but new applications should use the IPNSession events to performcustom actions at the appropriate stage. The OnStartJob event replaces the user exitcallback. See the User Guide for the printer for full details about the User Exitscommands.
User exits can also be set using the SetProperty call with the appropriate arguments. Seethe Remarks below for a list of arguments.
Syntaxexpression.SetUserExit32(PathtoDll, FunctionName, UseExtendedInfo)
where expression is an IPNSession object.
Parameters
String PathtoDllPath to the DLL
String FunctionNameThe name of the function in the DLL to call.
Boolean UseExtendedInfoPass True if you are using the extended user exit function prototype, or False if youare not.
PNSrv10 COM Interface
226 PNSrv10 COM Interface Object ReferenceIPNSession
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
PathtoDLL SectionName: User Exit 1
PropertyName: Path
varValue: VT_BSTR, as above
UseExtendedInfo True
SectionName: User Exit 1
PropertyName: FunctionEx
varValue: VT_BSTR, as above
UseExtendedInfo False
SectionName: User Exit 1
PropertyName: Function
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
If b32Bit Then Session.SetUserExit32("C:\TIFFUtils\GetData.dll", "PromptForData", True)Else Session.SetUserExit64("C:\TIFFUtils\GetData64.dll", "PromptForData", True)End If
C#
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
if (b32Bit) { Session.SetUserExit32("C:\\TIFFUtils\\GetData.dll", "PromptForData", TRUE)}else { Session.SetUserExit64("C:\\TIFFUtils\\GetData64.dll", "PromptForData", TRUE)}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetUserExit64 ClearUserExits SetProperty
227
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
SetUserExit64
Description
Sets a user exit callback for a 64-bit application. A user exit calls a function contained ina dynamic link library (DLL) that you have created. The function is invoked when anapplication starts to print and gives you an opportunity to augment the information orgather additional information that needs to be part of this conversion process.
The user exits are are included for backwards compatibility with previous applicationsusing this method, but new applications should use the IPNSession events to performcustom actions at the appropriate stage. The OnStartJob event replaces the user exitcallback. See the User Guide for the printer for full details about the User Exitscommands.
User exits can also be set using the SetProperty call with the appropriate arguments. Seethe Remarks below for a list of arguments.
Syntaxexpression.SetUserExit64(PathtoDll, FunctionName, UseExtendedInfo)
where expression is an IPNSession object.
Parameters
String PathtoDllPath to the DLL
String FunctionNameThe name of the function in the DLL to call.
Boolean UseExtendedInfoPass True if you are using the extended user exit function prototype, or False if youare not.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
PathtoDLL SectionName: User Exit 1.x64
PropertyName: Path
varValue: VT_BSTR, as above
UseExtendedInfo True
SectionName: User Exit 1.x64
PropertyName: FunctionEx
varValue: VT_BSTR, as above
UseExtendedInfo False
SectionName: User Exit 1.x64
PropertyName: Function
PNSrv10 COM Interface
228 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
If b32Bit Then Session.SetUserExit32("C:\TIFFUtils\GetData.dll", "PromptForData", True)Else Session.SetUserExit64("C:\TIFFUtils\GetData64.dll", "PromptForData", True)End If
C#
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
if (b32Bit) { Session.SetUserExit32("C:\\TIFFUtils\\GetData.dll", "PromptForData", TRUE)}else { Session.SetUserExit64("C:\\TIFFUtils\\GetData64.dll", "PromptForData", TRUE)}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetUserExit32 ClearUserExits SetProperty
ClearUserExits
Description
Clears any user exit options from the IPNSession object. There are separate user exitoptions for 32-bit operating systems and for 64-bit operating systems.
User exit options can also be cleared using the SetProperty call with the appropriatesection and name arguments and passing an empty argument as the property value. Seethe Remarks section in SetUserExit32 and SetUserExit64 for a list of values.
Syntaxexpression.ClearUserExits(Clear64Bit)
where expression is an IPNSession object.
Parameters
229
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Boolean Clear64BitA Boolean value, True to clear the 64-bit operating system user exit options, Falseto clear the 32-bit operating system user exit options.
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)...
' reset session for new print If bOSIs64 Then Session.ClearUserExits(True)Else Session.ClearUserExits(False)End If
C#
PNSession session = null;
session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);...
// reset session for new printif (bOSIs64){ session.ClearUserExits(true);}else{ session.ClearUserExits(false);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetUserExit32 SetUserExit64 SetProperty
SetUserVariable
Description
User variables can be used to pass custom information down to the IPNSession events.The user variables are stored as strings and can be retrieved inside the following eventsusing the GetVariableByKeyword method.
They can also be used to build filenames when used as macros $(Var0),$(Var1), ...$(Var9) in the file naming profile format.
User variables can be set using the SetProperty call with the appropriate arguments. Seethe Remarks below for a list of arguments.
PNSrv10 COM Interface
230 PNSrv10 COM Interface Object ReferenceIPNSession
To remove any custom user variable set, call this method with an empty string. This willclear the setting for that user variable.
Syntaxexpression.SetUserVariable(UserVariable)
where expression is an IPNSession object.
Parameters
pnUserVariable UserVariableThe user variable to set. There are ten in total available to use.
String CustomValueThe string representing the custom information.
Remarks
Use the following to set these options using SetProperty:
Method Parameter SetProperty Parameters
UserVariable SectionName: User variables
PropertyName: Var0, Var1, ... Var9
varValue: VT_BSTR, as above
Examples
Visual Basic
Public WithEvents Session As PNSessionPublic LockObject As Object
...
Private Sub Session_OnGetNextFileName(ByVal pJob As IPNJob)
Dim outputFolder, subFolder As String
' synchronize access from multiple threads SyncLock LockObject
'Change the output directory based on the user variable subFolder = pJob.GetVariableByKeyword(pnJobVariable.pnJobVariableUser0) outputFolder = m_OutputDir + "\" + subFolder + "\" pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputDir, outputFolder)
End SyncLockEnd Sub
Private Function ConvertFiles(ByVal bw As System.ComponentModel.BackgroundWorker, _ ByVal e As System.ComponentModel.DoWorkEventArgs) As Integer
Dim Session As PNSession
Session = New PNSession Session.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' add event handlers AddHandler Session.OnGetNextFileName, AddressOf Session_OnGetNextFileName
...
231
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
If (bBlackAndWhite) Then Session.SetUserVariable(pnUserVariable.pnUserVariable0, "BW") Else Session.SetUserVariable(pnUserVariable.pnUserVariable0, "Color") End If
...
End Sub
C#
private Object FolderLock = new Object();
void session_OnGetNextFileName(IPNJob pJob){ string outputFolder = "", subFolder = "";
lock (FolderLock) { // Change the output directory based on the user variable subFolder = pJob.GetVariableByKeyword(pnJobVariable.pnJobVariableUser0); outputFolder = m_OutputDir + "\" + subFolder + "\"; pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputDir, outputFolder); }}
private void ConvertFiles(object sender, DoWorkEventArgs e){ PNSession session = null;
// allocate print session session = new PNSession();
session.SetSessionPrinter("TIFF Image Printer 10.0", 2, null, false);
// Attach file naming event handler, set options as needed. session.OnGetNextFileName += new _IPNSessionEvents_OnGetNextFileNameEventHandler(session_OnGetNextFileName);
If (bBlackAndWhite) { session.SetUserVariable(pnUserVariable.pnUserVariable0, "BW") } else { session.SetUserVariable(pnUserVariable.pnUserVariable0, "Color") }
...
}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: INPSession Events SetProperty SetVariableByKeyword
SetVIMEmailService
Description
PNSrv10 COM Interface
232 PNSrv10 COM Interface Object ReferenceIPNSession
Configures the Lotus Notes\Domino email service options. These options will only takeeffect if the SetEmailService method has been set to use VIM.
These settings are only applied when the email options are enabled. If the email optionsare enabled and there are no email service options set through the IPNSession object thedefault options for the Advanced Email Settings... button on the Email tab in thePEERNET printer's Printing Preferences dialog will be applied to the output file instead.
The VIM email options can also be set using the SetProperty call with the appropriatearguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetSMTPEmailService(Password)
where expression is an IPNSession object.
Parameters
String PasswordThe Lotus Notes / Domino password. While not required, filling this in will reduce thenumber of logon screens presented to the user.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Password SectionName: Email Advanced
PropertyName: VIM password
varValue: VT_BSTR
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' Email settingsSession.SetEmailOn(True)Session.SetEmailMessageOptions("[email protected]", "[email protected]", _ "", "Test COM Email", "Please review the attached files.", _ "C:\Outgoing\Memo.doc")If ( bUseLotus ) Then Session.SetEmailService(pnEmailService.pnEmailServiceVIM, _ pnEmailDialog.pnEmailDialogStandard) Session.SetVIMEmailService("userpassword")End If
C#
PNSession Session = null;
Session = new PNSession();Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
233
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
...// Email settingsSession.SetEmailOn(True);Session.SetEmailMessageOptions("[email protected]", "[email protected]", "", "Test COM Email", "Please review the attached files.", "C:\Outgoing\Memo.doc");if ( bUseLotus ){ Session.SetEmailService(pnEmailService.pnEmailServiceVIM, pnEmailDialog.pnEmailDialogStandard) Session.SetVIMEmailService("userpassword")}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetEmailOn SetEmailMessageOptions SetEmailService SetMAPIEmailServiceSetSMTPEmailService ClearEmailMessageOptions ClearEmailService SetProperty
SetWatermarkOptionsOn
Description
Enables or disables the Watermark options. When these options are not set through the IPNSession object the default options for portrait and landscape watermarks in theWatermark tab in the PEERNET printer's Printing Preferences dialog will be applied to theoutput file instead.
Watermarking can also be enabled or disabled using the SetProperty call with theappropriate arguments. See the Remarks below for a list of arguments.
Syntaxexpression.SetPageCropOn(Enable, FirstPageOnly)
where expression is an IPNSession object.
Parameters
Boolean EnableSet True to enable any watermarking options, False to disable them.
Boolean FirstPageOnlySet True to only place the watermark on the first page, False to place thewatermark on every page.
Remarks
Use the following to set this option using SetProperty:
Method Parameter SetProperty Parameters
Enable SectionName: Watermark
PropertyName: Enable
varValue: VT_BOOL, as above
PNSrv10 COM Interface
234 PNSrv10 COM Interface Object ReferenceIPNSession
Method Parameter SetProperty Parameters
FirstPageOnly SectionName: Watermark
PropertyName: First page only
varValue: VT_BOOL, as above
Examples
Visual Basic
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
If bWatermarkEnabled Then
' apply landscape and portrait watermark centered on all pages Session.SetWatermarkOptionsOn(True, False) Session.SetPortraitWatermarkOptions("C:\TIFFSource\PortraitWatermark.png", _ pnWatermarkPosition.pnWatermarkCenter, 0) Session.SetLandscapeWatermarkOptions("C:\TIFFSource\LandWatermark.png", _ pnWatermarkPosition.pnWatermarkCenter, 0)End If
C#
Public WithEvents Session As PNSession
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
if (bWatermarkEnabled){ // apply landscape and portrait watermark centered on all pages Session.SetWatermarkOptionsOn(True, False); Session.SetPortraitWatermarkOptions("C:\TIFFSource\PortraitWatermark.png", pnWatermarkPosition.pnWatermarkCenter, 0); Session.SetLandscapeWatermarkOptions("C:\TIFFSource\LandWatermark.png", pnWatermarkPosition.pnWatermarkCenter, 0);}
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPortraitWatermarkOptions SetLandscapeWatermarkOptionsClearWatermarkOptions SetProperty pnWatermarkPosition
235
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Properties
Jobs
Description
Returns an IPNJobs collection of IPNJob objects. If job tracking is enabled through theTrackingOn property a new IPNJob object is added to this collection each time a file isprinted to one of the printers in the printer pool for this session. If nothing has beenprinted, the collection will be empty. The collection can be cleared using the Resetmethod.
Job tracking is off for each session by default.
Read-only.
Syntaxexpression.Jobs
where expression is an IPNSession object.
Returns an IPNJobs collection.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
' enable job trackingSession.TrackingOn = True
' process a document...
' get the jobs collection
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs
Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Document: " + Job.Document)
jobNode.Nodes.Add("Job ID:" + Job.JobID.ToString())
Next
C#
IPNJobs jobs;
// enable job trackingsession.TrackingOn = true;
// process a document
PNSrv10 COM Interface
236 PNSrv10 COM Interface Object ReferenceIPNSession
...
// get the jobs collectionjobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");m_TVSessionRoot.ImageIndex = 0;
// fill in job node in tree viewforeach (PNSrv10Lib.IPNJob Job in jobs){
TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.ImageIndex = 0; jobNode.Nodes.Add("Document: " + Job.Document); jobNode.Nodes.Add("Job ID:" + Job.JobID.ToString());
}
See Also: IPNJobs IPNJob TrackingOn Reset
TrackingOn
Description
Enable or disable job tracking through this property. When job tracking is enabled a newIPNJob object is added to the Jobs collection for each print job printed by one of theprinters in the printer pool for this session.
When job tracking is enabled, the jobs collection will continue to grow until the either thesession object is released or Reset is called to clear the jobs collection. When trackingjob information for a large number of files per session, you can use the Reset method tokeep the collection from getting too large.
Read/write.
Syntaxexpression.TrackingOn
where expression is an IPNSession object.
Returns or sets a Boolean.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
' enable job trackingSession.TrackingOn = True
' process a document...
' get the jobs collection
237
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs
Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Document: " + Job.Document)
jobNode.Nodes.Add("Job ID:" + Job.JobID.ToString())
Next
C#
IPNJobs jobs;
// enable job trackingsession.TrackingOn = true;
// process a document...
// get the jobs collectionjobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");m_TVSessionRoot.ImageIndex = 0;
// fill in job node in tree viewforeach (PNSrv10Lib.IPNJob Job in jobs){
TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.ImageIndex = 0; jobNode.Nodes.Add("Document: " + Job.Document); jobNode.Nodes.Add("Job ID:" + Job.JobID.ToString());
}
See Also: IPNJobs IPNJob Jobs Reset
PNSrv10 COM Interface
238 PNSrv10 COM Interface Object ReferenceIPNSession
Events
OnCloseFile
Description
The OnCloseFile event occurs each time a file is closed. By attaching to this event youcan perform custom actions with the newly created file. File information, including pagecount and file location can be retrieved from the IPNFile object passed to the eventhandler.
SyntaxobjectName_OnCloseFile(pFile)
where the IPNSession object is declared with events.
Parameters
IPNFile pFileAn IPNFile object representing the file currently printing.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnCloseFile(ByVal pFile As IPNFile) Handles Session.OnCloseFile
SetLogData("OnCloseFile: " + pFile.Filename) ' release file object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFile)
End Sub
C#
printSession.OnCloseFile += new _IPNSessionEvents_OnCloseFileEventHandler(printSession_OnCloseFile);
void printSession_OnCloseFile(IPNFile pFile){ this.SetLogData("OnCloseFile: " + pFile.Filename);
// release file object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFile);}
See Also: OnEndImage OnEndJob OnEndPage OnGetNextFileName OnOpenFileOnReportError OnStartImage OnStartJob OnStartPage IPNFile
OnEndImage
Description
239
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
The OnEndImage event occurs each time a new image for a page is completed. Currentlyonly one image is created per page.
SyntaxobjectName_OnEndImage(pImage)
where the IPNSession object is declared with events.
Parameters
IPNImage pImageAn IPNImage object representing the file currently printing.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnEndImage(ByVal pImage As IPNImage) Handles Session.OnEndImage
SetLogData("OnEndImage: Image on page " + pImage.PageNumber.ToString())
' release image object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pImage)
End Sub
C#
printSession.OnEndImage += new _IPNSessionEvents_OnEndImageEventHandler(printSession_OnEndImage);
void printSession_OnEndImage(IPNImage pImage){ this.SetLogData("OnEndImage: Image on page " + pImage.PageNumber.ToString());
// release image object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pImage);}
See Also: OnCloseFile OnEndJob OnEndPage OnGetNextFileName OnOpenFileOnReportError OnStartImage OnStartJob OnStartPage IPNImage
OnEndJob
Description
The OnEndJob event occurs each time a file has completed printing.This event, alongwith OnStartJob, is useful for tracking the files printed.
SyntaxobjectName_OnEndJob(pJob)
where the IPNSession object is declared with events.
PNSrv10 COM Interface
240 PNSrv10 COM Interface Object ReferenceIPNSession
Parameters
IPNJob pJobAn IPNJob object representing the print job for the file.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnEndJob(ByVal pJob As IPNJob) Handles Session.OnEndJob
SetLogData("OnEndJob: " + pJob.JobGUID + " for document: " + pJob.Document)
' release job object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob)
End Sub
C#
printSession.OnEndJob += new _IPNSessionEvents_OnEndJobEventHandler(printSession_OnEndJob);
void printSession_OnEndJob(IPNJob pJob){ this.SetLogData("OnEndJob: " + pJob.JobGUID + " for document: " + pJob.Document);
// release image object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob);}
See Also: OnCloseFile OnEndImage OnEndPage OnGetNextFileName OnOpenFileOnReportError OnStartImage OnStartJob OnStartPage IPNJob
OnEndPage
Description
The OnEndPage event occurs each time a new page in an output file is completed.
SyntaxobjectName_OnEndPage(pPage)
where the IPNSession object is declared with events.
Parameters
IPNPage pPageAn IPNPage object representing the current page of the file currently printing.
Examples
241
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnEndPage(ByVal pPage As IPNPage) Handles Session.OnEndPage
SetLogData("OnEndPage: Page " + pPage.PageNumber.ToString())
' release page object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pPage)
End Sub
C#
printSession.OnEndPage += new _IPNSessionEvents_OnEndPageEventHandler(printSession_OnEndPage);
void printSession_OnEndPage(IPNPage pPage){ this.SetLogData("OnEndPage: Page " + pPage.PageNumber.ToString()); // release page object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pPage);}
See Also: OnCloseFile OnEndImage OnEndJob OnGetNextFileName OnOpenFileOnReportError OnStartImage OnStartJob OnStartPage IPNPage
OnGetNextFileName
Description
The OnGetNextFileName event occurs each time a filename needs to be created.Depending on the PEERNET printer being used and the output file settings, this canhappen once for each file if the output is multi-paged or once for every page that isprinted if the output is serialized
The most common use of this event is to customize the file name of the output file. Jobsettings can be customized using the SetVariableByKeyword or the SetVariable methodon the pJob object passed to the event handler.
SyntaxobjectName_OnGetNextFileName(pJob)
where the IPNSession object is declared with events.
Parameters
IPNJob pJobAn IPNJob object representing the file currently printing.
Examples
The following samples demonstrate how to use the OnGetNextFileName event tocustomize the name of the output file.
PNSrv10 COM Interface
242 PNSrv10 COM Interface Object ReferenceIPNSession
Visual Basic
Public WithEvents Session As PNSessionPublic m_currentFileNumber As IntegerPublic m_BaseName As String
Private Sub Session_OnGetNextFileName(ByVal pJob As IPNJob) Handles Session.OnGetNextFileName
Dim strCombinedBaseName As String
' synchronize access to the global page number counter SyncLock LockObject
strCombinedBaseName = "SampleFileName_" + _ String.Format("{0:000000}", _ m_currentFileNumber pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, _ strCombinedBaseName)
' increment file counter m_currentFileNumber = m_currentFileNumber + 1 End SyncLock
' release job object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob)
End Sub
C#
printSession.OnGetNextFileName += new _IPNSessionEvents_OnGetNextFileNameEventHandler(printSession_OnGetNextFileName);
void printSession_OnGetNextFileName(IPNJob pJob){ string strCombinedBaseName;
lock (LockObject) { strCombinedBaseName = "SampleFileName_" + String.Format("{0:000000}", m_currentFileNumber); m_currentFileNumber++; }
// sets the new output file name into the job pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, filename);
// release job object pointer Marshal.FinalReleaseComObject(pJob);}
See Also: OnCloseFile OnEndImage OnEndJob OnEndPage OnOpenFile OnReportErrorOnStartImage OnStartJob OnStartPage IPNJob
OnLogMessage
This feature is reserved for future use and is not implemented in the current product.
243
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
OnOpenFile
Description
The OnOpenFile event occurs each time a new output file is opened or created.
SyntaxobjectName_OnOpenFile(pFile)
where the IPNSession object is declared with events.
Parameters
IPNFile pFileAn IPNFile object representing the file currently printing.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnOpenFile(ByVal pFile As IPNFile) Handles Session.OnOpenFile
SetLogData("OnOpenFile: " + pFile.Filename)
' release file object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFile)
End Sub
C#
printSession.OnOpenFile += new _IPNSessionEvents_OnOpenFileEventHandler(printSession_OnOpenFile);
void printSession_OnOpenFile(IPNFile pFile){ this.SetLogData("OnOpenFile: " + pFile.Filename);
// release file object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pFile)}
See Also: OnCloseFile OnEndImage OnEndJob OnEndPage OnGetNextFileNameOnReportError OnStartImage OnStartJob OnStartPage IPNFile
OnReportError
Description
The OnReportError event is fired when the print driver reports an error, such as nothaving permissions to create the files is the output folder.
SyntaxobjectName_OnReportError(pJob, Error)
PNSrv10 COM Interface
244 PNSrv10 COM Interface Object ReferenceIPNSession
where the IPNSession object is declared with events.
Parameters
IPNJob pJobAn IPNJob object representing the print job for the file.
String ErrorThe error message reported by the driver.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnReportError(ByVal pJob As IPNJob, _ ByVal errorString As String) _ Handles Session.OnReportError
System.Diagnostics.Trace.WriteLine("**") System.Diagnostics.Trace.WriteLine("** OnReportError: [" + _ pJob.PrintSessionGUID + "] - " + errorString) System.Diagnostics.Trace.WriteLine("** OnReportError: " + pJob.Document) System.Diagnostics.Trace.WriteLine("** OnReportError: " + pJob.PrintSessionGUID) System.Diagnostics.Trace.WriteLine("**")#");
' release job object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob)
End Sub
C#
session.OnReportError += new _IPNSessionEvents_OnReportErrorEventHandler(session_OnReportError);
void session_OnReportError(IPNJob pJob, string Error){ System.Diagnostics.Trace.WriteLine("**"); System.Diagnostics.Trace.WriteLine("** OnReportError: [" + pJob.PrintSessionGUID + "] - " + Error); System.Diagnostics.Trace.WriteLine("** OnReportError: " + pJob.Document); System.Diagnostics.Trace.WriteLine("** OnReportError: " + pJob.PrintSessionGUID); System.Diagnostics.Trace.WriteLine("**");
// release file object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob);
}
See Also: OnCloseFile OnEndImage OnEndJob OnEndPage OnGetNextFileName OnOpenFile OnStartImage OnStartJob OnStartPage IPNJob
OnStartImage
Description
The OnStartImage event occurs each time a new image for a page is created. Currently
245
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
only one image is created per page.
SyntaxobjectName_OnStartImage(pImage)
where the IPNSession object is declared with events.
Parameters
IPNImage pImageAn IPNImage object representing the image being created and added to the currentoutput file.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnStartImage(ByVal pImage As IPNImage) Handles Session.OnStartImage
SetLogData("OnStartImage: Image is on page " + pImage.PageNumber + _ " at " + pImage.BitsPerPixel.ToString() + "bpp")
' release image object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pImage)
End Sub
C#
printSession.OnStartImage += new _IPNSessionEvents_OnStartImageEventHandler(printSession_OnStartImage);
void printSession_OnStartImage(IPNImage pImage){ this.SetLogData("OnStartImage: Image is on page " + pImage.PageNumber + " at " + pImage.BitsPerPixel.ToString() + "bpp");
// release file object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pImage);}
See Also: OnCloseFile OnEndImage OnEndJob OnEndPage OnGetNextFileName OnOpenFile OnReportError OnStartJob OnStartPage IPNImage
OnStartJob
Description
The OnStartJob event occurs each time a file is printed, just as the print job enters theprint queue. This event is useful for tracking the files printed.
SyntaxobjectName_OnStartJob(pJob)
where the IPNSession object is declared with events.
PNSrv10 COM Interface
246 PNSrv10 COM Interface Object ReferenceIPNSession
Parameters
IPNJob pJobAn IPNJob object representing the print job information for the file currently printing.
Examples
Demonstrates how to add the event handler.
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnStartJob(ByVal pJob As IPNJob) Handles Session.OnStartJob
SetLogData("Starting job " + pJob.JobGUID + "for document:" + pJob.Document)
' release job object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob)
End Sub
C#
printSession.OnStartJob += new _IPNSessionEvents_OnStartJobEventHandler(printSession_OnStartJob);
void printSession_OnStartJob(IPNJob pJob){ this.SetLogData("Starting job " + pJob.JobGUID + "for document:" + pJob.Document)
// release job object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pJob);}
See Also: OnCloseFile OnEndImage OnEndJob OnEndPage OnGetNextFileName OnOpenFile OnReportError OnStartImage OnStartPage IPNJob
OnStartPage
Description
The OnStartPage event occurs each time a new page in an output file is created.
SyntaxobjectName_OnStartPage(pPage)
where the IPNSession object is declared with events.
Parameters
IPNPage pPageAn IPNPage object representing the current page of the file currently printing.
Examples
247
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnStartPage(ByVal pPage As IPNPage) Handles Session.OnStartPage
SetLogData("OnStartPage: Page " + pPage.PageNumber.ToString() + _ " was printed at " pPage.BitsPerPixel.ToString() + " bpp")
' release page object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pPage)
End Sub
C#
printSession.OnStartPage += new _IPNSessionEvents_OnStartPageEventHandler(printSession_OnStartPage);
void printSession_OnStartPage(IPNPage pPage){ this.SetLogData("OnStartPage: Page " + pPage.PageNumber.ToString() + " was printed at " + pPage.BitsPerPixel.ToString() + "bpp");
// release page object pointer System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pPage);}
See Also: OnCloseFile OnEndImage OnEndJob OnEndPage OnGetNextFileName OnOpenFile OnReportError OnStartImage OnStartJob IPNPage
PNSrv10 COM Interface
248 PNSrv10 COM Interface Object ReferenceIPNSession
Driver Preferences Method Map
Printer Tab Supported Drivers Methods
LayoutPaper/Quality
Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
ForcePrinterColorModeForcePrinterOrientationForcePrinterPaperSizeForcePrinterResolution
SetDevmodeSettings [Deprecated]ClearDevmodeSettings [Deprecated]
Page Processing Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetPageRotationOptionsClearPageRotationOptions
SetPageCropOn
SetPageCropAreaOptionsClearPageCropAreaOptions
SetPageCropMarginOptionsClearPageCropMarginOptions
SetPageTrimOptionsClearPageTrimOptions
SetPageBrightnessClearPageBrightness
ImageProcessing
Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetImageCopyToOn
SetImageCopyToOptionsClearImageCopyToOptions
SetResamplingOn
SetResamplingOptionsClearResamplingOptions
Compression TIFF Image Printer10.0, Raster Image Printer10.0
SetTIFFCompressionOptionsClearTIFFCompressionOptions
SetCompressionOptions [Deprecated]ClearCompressionOptions [Deprecated]
PDF Image Printer10.0, Raster ImagePrinter 10.0
SetPDFCompressionOptionsClearTIFFCompressionOptions
SetPDFFileFormatOptions [Deprecated]ClearPDFFileFormatOptions [Deprecated]
Raster Image Printer10.0
SetJPEGCompressionOptionsClearJPEGCompressionOptions
Fax/TIFF or Fax Raster Image Printer SetFaxModeOn
249
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNSession
Printer Tab Supported Drivers Methods
10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetFaxOptionsClearFaxOptions
TIFF Image Printer10.0, Raster Image Printer10.0
SetTIFFAdvancedOptionsClearTIFFAdvancedOptions
PDF Security PDF Image Printer10.0
SetPDFSecurityClearPDFSecurity
SetPDFPasswordClearPDFPassword
WatermarkRaster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetWatermarkOptionsOn
SetPortraitWatermarkOptionsSetLandscapeWatermarkOptionsClearWatermarkOptions
Save Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetSaveOptionsClearSaveOptions
SetNamingProfileFormatClearNamingProfileFormat
SetFileNamingOptions [Deprecated]ClearFileNamingOptions [Deprecated]
Run Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetRunAtStartCommandClearRunAtStartCommand
SetRunAtPageCommandClearRunAtPageCommand
SetRunAtFileCloseCommandClearRunAtFileCloseCommand
SetRunAtEndCommandClearRunAtEndCommand
Email Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetEmailOn
SetEmailMessageOptionsClearEmailMessageOptions
SetEmailServiceClearEmailService
SetMAPIEmailServiceSetSMTPEmailServiceSetVIMEmailService
PNSrv10 COM Interface
250 PNSrv10 COM Interface Object ReferenceIPNSession
Printer Tab Supported Drivers Methods
AdvancedFeatures
Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetHardwareMarginsClearHardwareMargins
SetCustomPaperOn
SetCustomPaperOptionsClearCustomPaperOptions
Text Extraction Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetTextExtractionOn
SetTextExtractionOptionsClearTextExtractionOptions
EnableControlStrings
Error Reporting Raster Image Printer10.0, TIFF ImagePrinter 10.0, PDFImage Printer 10.0
SetErrorReportingClearErrorReporting
SetMessageBoxAlertsClearMessageBoxAlerts
251
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
IPNPrintSession
Description
Represents a single printer from the pool of PEERNET printers held by the IPNSession object.A new IPNPrintSession object is needed to control and synchronize the printing process foreach document that will be printed.
Use the NewPrintSessionEx method on IPNSession to get a print session object. Each printsession object copies the current settings from the IPNSession object. The print sessionsettings are read-only.
The pool of printers is accessed in a round-robin sequence. A printer can only be assigned toa IPNPrintSession when it is free. While a printer is being used by any IPNPrintSessionobject it is seen as busy and cannot be used by any other IPNPrintSession object.
Public Methods
Cancel Cancels the current set of print jobs.
GetProperty Retrieves print settings from the printer
MakeSystemDefaultPrinter Sets the printer associated with this print session asthe system default printer.
Pause Pauses the printer queue associated with thisIPNPrintSession object.
PrintUsingCommand Print a file using a custom command line andarguments.
Resume Resume the printer queue associated with thisIPNPrintSession object.
ShellPrint Use the Windows Explorer shell verb "print" to print aa file.
ShellPrintTo Use the Windows Explorer shell verb "printto" to printa a file.
WaitForJobsCompleted Waits a given timeout period for all jobs in this printsession to be completed before returning control backto the calling application.
WaitForJobsPrinted Waits a given timeout period for all jobs in this printsession to be printed before returning control back tothe calling application.
WaitForJobsSpooled Waits a given timeout period for all jobs in this printsession to be spooled before returning control back tothe calling application.
PNSrv10 COM Interface
252 PNSrv10 COM Interface Object ReferenceIPNPrintSession
WaitForJobsSpooling Waits a given timeout period for all jobs in this printsession to be spooling before returning control backto the calling application.
Public Properties
PrinterName Read-only; The name of the printer associated withthis IPNPrintSession object.
PrintSessionGUID Read-only; A unique identifier associated with thisIPNPrintSession object.
253
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
Methods
Cancel
Description
Cancels the current print session, allowing the printer to be returned to the pool ofavailable printers. Canceling the print session does not delete any currently printingdocuments, any remaining jobs in the printer queue will finish printing.associated withthis IPNPrintSession object.
Syntaxexpression.Cancel()
where expression is an IPNPrintSession object.
Examples
Visual Basic
For Each file_info As System.IO.FileInfo In file_infos Dim bSpooling As Boolean
...
' print in the background oDoc.PrintOut(Background:=True)
' wait for document to enter spooling state, how long to wait here ' depends on how long it may take the printing application to print ' the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000)
If Not bSpooling Then documentPrintSession.Cancel() End If
...
Next file_info
C#
// loop through each file and convertforeach (System.IO.FileInfo iFI in infos){ boolean bSpooling = false;
...
// print in the background oDoc.PrintOut(ref myTrue, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// wait for document to enter spooling state, how long to wait here // depends on how long it may take the printing application to print // the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000); if (bSpooling == false) {
PNSrv10 COM Interface
254 PNSrv10 COM Interface Object ReferenceIPNPrintSession
documentPrintSession.Cancel(); }
...
}
See Also: Pause Resume
GetProperty
Description
Allows you to retrieve any properties, or options set on the IPNPrintSession object. TheIPNPrintSession object copies all of the current settings from the IPNSession objectwhen NewPrintSession is called.
The properties are organized into sections and then by name within that section. Thesection and properties names are case sensitive. The section and property names, andvalues for each property are the same as the configuration file settings explained in the"Customizing Driver Defaults" section of the User Guide for the printer being used.
Not all properties are available to all printers, and some properties are specific to certainprinters. See the individual set option methods on the IPNSession object for a list ofsection and property names that can be used to retrieve the individual settings for each.
Syntaxexpression.GetProperty(SectionName, PropertyName)
where expression is an IPNPrintSession object.
Returns a VARIANT containing the property value, or VT_EMPTY if that property is notset.
Parameters
String rSectionName
The section name for the property you are retrieving.
String PropertyName
The property name.
Examples
Visual Basic
Public WithEvents Session As PNSession
Dim documentPrintSession As IPNPrintSessionDim basefilename As String
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 2, Nothing, False)
' set name and save location, create multipage tiff
255
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
' and append all into a single fileSession.SetFileNamingOptions("C:\TIFFOutput\", "TIFFReport", _ bMultipage, bAppend, _ False, True, True, True, False)
'get new print session, need a new one for each file we are printingdocumentPrintSession = Session.NewPrintSession(1000, 2000)
' get the name we usedbasefilename = documentPrintSession.GetProperty("Save", _ "Output filename")MsgBox(basefilename)
C#
PNSession session = null;IPNPrintSession documentPrintSession = null;
String basefilename;session = new PNSession();session.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// set name and save location, create multipage tiff// and append all into a single fileSession.SetFileNamingOptions("C:\TIFFOutput\", "TIFFReport", bMultipage, bAppend, False, True, True, True, False)
// get new print session, need a new one for each file we are printingdocumentPrintSession = session.NewPrintSession(5000, 2000);
// get the name we usedbasefilename = (String)documentPrintSession.GetProperty("Save", "Output filename");MessageBox.Show(basefilename);
MakeSystemDefaultPrinter
Description
Not all applications have the ability to choose a specific printer and rely on the systemdefault printer when printing.The default printer is a global setting; when you set thedefault printer, it is set for the entire system. When printing in a multi-threadedenvironment, care must be taken to share the default printer setting between thethreads to ensure that one thread is not changing the default printer while anotherthread is about to print to the default printer.
The MakeSystemDefaultPrinter method sets the printer associated with this print sessionas the system default printer and blocks any other IPNPrintSession printers frombecoming the default printer, allowing for thread-safe printing from applications that relyon the system default printer. When this print session is released back into the pool ofavailable printers, the original system default printer is restored.
Note: If at all possible, try to avoid having to set the default printer. Even when using MakeSystemDefaultPrinter to control the default printer, you cannot protect againstthe default printer being changed by an outside process or manually by a user. As well,having to share the default printer, a single resource, between multiple threads can
PNSrv10 COM Interface
256 PNSrv10 COM Interface Object ReferenceIPNPrintSession
slow down processing.
Syntaxexpression.MakeSystemDefaultPrinter()
where expression is an IPNPrintSession object.
Examples
Visual Basic
For Each file_info As System.IO.FileInfo In file_infos Dim bSpooling As Boolean Dim bSpooled As Boolean Dim bSetPrinter As Boolean
' Open the Publisher document oDoc = pPubApp.Open(Filename:=file_info.FullName)
' Get the print session documentPrintSession = Nothing Try While documentPrintSession Is Nothing documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) End While Catch ex As Exception oDoc.Close() Continue For End Try
bSetPrinter = False While Not bSetPrinter Try ' Wait 20 seconds bSetPrinter = printSession.MakeSystemDefaultPrinter(20000) Catch ex As Exception Exit While End Try End While
If (Not bSetPrinter) Then ' cancel print session and close document documentPrintSession.Cancel() oDoc.Close() Else
' set active printer oDoc.ActivePrinter = documentPrintSession.PrinterName
' print document oDoc.PrintOut()
' wait for document to enter spooling state, how long to wait here ' depends on how long it may take the printing application to print ' the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000)
If Not bSpooling Then documentPrintSession.Cancel() Else
' wait for document to be completely spooled to the printer. How long ' to wait here depends on the size of the presentation, the printer ' settings and how long it may take for the presentation to spool completely. bSpooled = documentPrintSession.WaitForJobsSpooled(120000) If Not bSpooled Then documentPrintSession.Cancel()
257
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
End If End If
' Printing started or failed and has been cancelled. ' Release the print session so another document may start printing If Not documentPrintSession Is Nothing Then InteropServices.Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
' Also do a GC to help .NET move things along System.GC.Collect() End If
' close document oDoc.Close()
End If
Next file_info
C#
foreach (System.IO.FileInfo iFI in infos){ bool bSpooling = false, bSpooled = false, bSetPrinter = false;
// open document oDoc = oPubApp.Open(iFI.FullName, true, false, PbSaveOptions.pbDoNotSaveChanges);
// Get the print session documentPrintSession = null; try { while (documentPrintSession == null ) { documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } } catch (Exception ex) { oDoc.Close(); continue; }
bSetPrinter = false; while (!bSetPrinter) { try { // Wait 20 seconds bSetPrinter = documentPrintSession.MakeSystemDefaultPrinter(20000); } catch (Exception ex) { break; } }
if (!bSetPrinter) { // cancel print session and close document documentPrintSession.Cancel(); oDoc.Close(); } else { // set active printer oDoc.ActivePrinter = documentPrintSession.PrinterName;
PNSrv10 COM Interface
258 PNSrv10 COM Interface Object ReferenceIPNPrintSession
//' print document oDoc.PrintOut(1, oDoc.Pages.Count, "", 1, false);
// wait for document to enter spooling state, how long to wait here // depends on how long it may take the printing application to print // the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000);
if (!bSpooling) { documentPrintSession.Cancel(); } else { // wait for document to be completely spooled to the printer. How long // to wait here depends on the size of the presentation, the printer // settings and how long it may take for the presentation to spool completely. bSpooled = documentPrintSession.WaitForJobsSpooled(120000); if (!bSpooled) { documentPrintSession.Cancel(); } } }
// Printing started or failed and has been cancelled. // Release the print session so another document may start printing if (documentPrintSession) { InteropServices.Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = Nothing; }
// close document oDoc.Close();}
Pause
Description
Pauses the printer queue associated with this IPNPrintSession object. Any jobs in theprinter queue will not be processed until Resume is called.
Syntaxexpression.Pause()
where expression is an IPNPrintSession object.
Examples
Visual Basic
If bForceJobOrder Then Try Dim sht As Excel.Worksheet
'open worbook oExcelApp.EnableEvents = False oWB = oExcelApp.Workbooks.Open(Me.tbFile.Text) oExcelApp.EnableEvents = True
' pause printer so we can spool all jobs
259
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
PrintSession.Pause()
oWB.PrintOut(ActivePrinter:=printerName)
' wait for all jobs from this document to be spooled bResult = PrintSession.WaitForJobsSpooled(120000)
' resume printer PrintSession.Resume()
'Close workbook (optional) oWB.Close()
'Clean up memory (you must do this) oWB = Nothing
Catch ex As Exception MessageBox.Show("Exception in Excel (" + ex.Message + ").") End TryEnd If
' close applicationoExcelApp.Quit()
C#
if (strFullPath.EndsWith(".xls", StringComparison.CurrentCultureIgnoreCase)){ ExcelApp.Application oExcelApp = new ExcelApp.Application(); ExcelApp.Workbook oWorkbook ; Boolean bResult = false;
oWorkbook = oExcelApp.Workbooks.Open(strFullPath,0, false, 5, "", "",false, ExcelApp.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
oWorkbook.PrintOut(System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, false, documentPrintSession.PrinterName, false, false, "");
// pause the printer if (bForceJobOrder) { documentPrintSession.Pause(); }
// wait max 1 minute then cancel print job bResult = documentPrintSession.WaitForJobsSpooled(60000);
// resume the printer if (bForceJobOrder) { documentPrintSession.Resume(); }
if (bResult == false) { documentPrintSession.Cancel(); }
oWorkbook.Close(false, System.Reflection.Missing.Value, false); oExcelApp.Quit();}
See Also: Cancel Resume
PNSrv10 COM Interface
260 PNSrv10 COM Interface Object ReferenceIPNPrintSession
PrintUsingCommand
Description
Specify a custom program to print the files to the IPNPrintSession object's printer.
Syntaxexpression.PrintUsingCommand(PathToEXE, Parameters, WaitMode, WaitModeTimeout, SetAsDefaultPrinter, ForceHiddenWnd, ShellProcessTimout, ForceAppClose, CheckExitCode, ValidExitCode)
where expression is an IPNPrintSession object.
Returns Boolean True if the shell executed correctly and the file being printed reachedthe requested state (spooled, printed or completed) in the time period specified.
The method returns False if:
the printer cannot be set as the system default printer within the timeout periodspecified by the WaitModeTimeout argument.
the file being printed has not entered the print queue within a set amount of time.This timeout period used is the FirstJobTimeout value passed in theNewPrintSessionEx call when getting the IPNPrintSession object. IfNewPrintSession is used instead the timeout value is preset at 2 minutes.
the file being printed has not reached the requested state(spooled, printed,completed) within the timeout period specified by WaitModeTimeout.
An exception is thrown if the shell call fails. See the Remarks section below for a list oferrors.
Parameters
String PathToEXEFully-qualified path to the program to use to print the file.
String ParametersAny parameters needed by the program to print the file.
pnShellAndCommandWaitMode WaitModeA pnShellAndCommandWaitMode constant to determine the wait mode (spooled,printed, completed) for the file being printed.
Integer WaitModeTimeoutHow long, in milliseconds, to wait for the program to print the document and for theprint job to be spooled, printed or completed.
Boolean SetAsDefaultPrinterPass True if the program requires the printer to be the default printer. The originaldefault printer is restored when the print command is completed.
Boolean ForceHiddenWndPass True to force the program window to be hidden. This will not work on allapplications.
Integer ShellProcessTimout
261
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
The amount of time, in milliseconds, to wait for the launched program to close byitself. If it has not closed by the end of the timeout period and ForceAppClose isTrue, the program is passed a close message to request that it close cleanly andagain waits the timeout period. If at the end of the second wait the program still hasnot closed, it it forcibly terminated.
Boolean ForceAppClosePass True to force the program to close.
Boolean CheckExitCodePass True if the the program returns an exit code with a meaningful value.
Integer ValidExitCodeIf the program returns an exit code, pass the valid exit code here to have thePrintUsingCommand check the exit code and return accordingly.
Remarks
If the shell call fails one of the following error message is thrown as an exception.
Error Code Description
ERROR_FILE_NOT_FOUND The specified file was not found
ERROR_PATH_NOT_FOUND The specified path was not found
ERROR_DDE_FAIL The Dynamic Data Exchange (DDE)transaction failed.
ERROR_NO_ASSOCIATION There is no application associated with thegiven file name extension.
ERROR_ACCESS_DENIED Access to the specified file is denied.
ERROR_DLL_NOT_FOUND One of the library files necessary to run theapplication can't be found.
ERROR_CANCELLED The function prompted the user foradditional information, but the user canceledthe request.
ERROR_NOT_ENOUGH_MEMORY There is not enough memory to perform thespecified action.
ERROR_SHARING_VIOLATION A sharing violation occurred.
Examples
Visual Basic
Public WithEvents Session As PNSession
Dim PrintSession As IPNPrintSessionDim bPrinted As Boolean
' allocate a sessionSession = New PNSession
' Set the printer and the number of printer clones to use in this session
PNSrv10 COM Interface
262 PNSrv10 COM Interface Object ReferenceIPNPrintSession
Session.SetSessionPrinter("TIFF Image Printer 10.0", 1, Nothing, False)
'get new print session, need a new one for each file we are printingPrintSession = Session.NewPrintSession(1000, 2000)
' print using custom program, program takes the file to be printed' as a single argument, needs printer to be default, and automatically' exits when printing is complete.' Returns valid exit code of 1, 0 means failure.PrintSession.PrintUsingCommand("C:\TIFFUtils\PrintMyFile.exe", _ strFilePath, True, _ pnShellAndCommandWaitMode.pnShellAndCommandWaitModePrinted, _ 60000, True, 30000, False, True, 1)
C#
PNSession session = null;IPNPrintSession documentPrintSession = null;
// allocate a sessionsession = new PNSession();
// Set the printer and the number of printer clones to use in this sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// get new print session, need a new one for each file we are printingdocumentPrintSession = session.NewPrintSession(5000, 2000);
// print using custom program, program takes the file to be printed as a single argument,// needs printer to be default, automatically exits when printing is complete.// Returns valid exit code of 1, 0 means failure.PrintSession.PrintUsingCommand("C:\TIFFUtils\PrintMyFile.exe", strFilePath, true, pnShellAndCommandWaitMode.pnShellAndCommandWaitModePrinted, 60000, true, 30000, false, true, 1);
See Also: ShellPrintTo ShellPrint
Resume
Description
Resumes the printer queue associated with this IPNPrintSession object. Any jobsaccumulated in the printer queue since the Pause call will now be processed.
Syntaxexpression.Resume()
where expression is an IPNPrintSession object.
Examples
Visual Basic
If bForceJobOrder Then Try Dim sht As Excel.Worksheet
'open worbook oExcelApp.EnableEvents = False oWB = oExcelApp.Workbooks.Open(Me.tbFile.Text)
263
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
oExcelApp.EnableEvents = True
' pause printer so we can spool all jobs PrintSession.Pause()
oWB.PrintOut(ActivePrinter:=printerName)
' wait for all jobs from this document to be spooled bResult = PrintSession.WaitForJobsSpooled(120000)
' resume printer PrintSession.Resume()
'Close workbook (optional) oWB.Close()
'Clean up memory (you must do this) oWB = Nothing
Catch ex As Exception MessageBox.Show("Exception in Excel (" + ex.Message + ").") End TryEnd If
' close applicationoExcelApp.Quit()
C#
if (strFullPath.EndsWith(".xls", StringComparison.CurrentCultureIgnoreCase)){ ExcelApp.Application oExcelApp = new ExcelApp.Application(); ExcelApp.Workbook oWorkbook ; Boolean bResult = false;
oWorkbook = oExcelApp.Workbooks.Open(strFullPath,0, false, 5, "", "", false, ExcelApp.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
oWorkbook.PrintOut(System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, false, documentPrintSession.PrinterName, false, false, "");
// pause the printer if (bForceJobOrder) { documentPrintSession.Pause(); }
// wait max 1 minute then cancel print job bResult = documentPrintSession.WaitForJobsSpooled(60000);
// resume the printer if (bForceJobOrder) { documentPrintSession.Resume(); }
if (bResult == false) { documentPrintSession.Cancel(); }
oWorkbook.Close(false, System.Reflection.Missing.Value, false); oExcelApp.Quit();}
See Also: Pause Cancel
PNSrv10 COM Interface
264 PNSrv10 COM Interface Object ReferenceIPNPrintSession
ShellPrint
Description
Uses the Windows shell verb "print" to print the file. This only works with files that haveknown associations, meaning there is an installed application already on the computerthat knows how to open and print the file.
As a general rule, if you can drag and drop the file onto a printer icon, or if there is aPrint option in the context menu that appears when you right-click the file, you can usethe shell to print it.
The ShellPrint method sets the default printer to be the printer associated with the IPNPrintSession object, then returns to the original default printer when finished.
Syntaxexpression.ShellPrint(FullPathToFile, WaitMode, WaitModeTimeout, ForceHiddenWnd, ShellProcessTimout, ForceAppClose)
where expression is an IPNPrintSession object.
Returns Boolean True if the shell executed correctly and the file being printed reachedthe requested state (spooled, printed or completed) in the time period specified.
The method returns False if:
the printer cannot be set as the system default printer within the timeout periodspecified by the WaitModeTimeout argument.
the file being printed has not entered the print queue within a set amount of time.This timeout period used is the FirstJobTimeout value passed in theNewPrintSessionEx call when getting the IPNPrintSession object. IfNewPrintSession is used instead the timeout value is preset at 2 minutes.
the file being printed has not reached the requested state(spooled, printed,completed) within the timeout period specified by WaitModeTimeout.
An exception is thrown if the shell call fails. See the Remarks section below for a list oferrors.
Parameters
String FullPathToFileFully-qualified path to the file to be printed.
pnShellAndCommandWaitMode WaitModeA pnShellAndCommandWaitMode constant to determine the wait mode (spooled,printed, completed) for the file being printed.
Integer WaitModeTimeoutHow long, in milliseconds, to wait for the program to print the document and for theprint job to be spooled, printed or completed, depending on the wait mode chosenfor WaitMode above.
Boolean ForceHiddenWndPass True to force the program window to be hidden. This will not work on allapplications.
265
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
Integer ShellProcessTimoutThe amount of time, in milliseconds, to wait for the launched program to close byitself. If it has not closed by the end of the timeout period and ForceAppClose isTrue, the program is passed a close message to request that it close cleanly andagain waits the timeout period. If at the end of the second wait the program still hasnot closed, it it forcibly terminated.
Boolean ForceAppClosePass True to force the program to close.
Remarks
If the shell call fails one of the following error message is thrown as an exception.
Error Code Description
ERROR_FILE_NOT_FOUND The specified file was not found
ERROR_PATH_NOT_FOUND The specified path was not found
ERROR_DDE_FAIL The Dynamic Data Exchange (DDE)transaction failed.
ERROR_NO_ASSOCIATION There is no application associated with thegiven file name extension.
ERROR_ACCESS_DENIED Access to the specified file is denied.
ERROR_DLL_NOT_FOUND One of the library files necessary to run theapplication can't be found.
ERROR_CANCELLED The function prompted the user foradditional information, but the user canceledthe request.
ERROR_NOT_ENOUGH_MEMORY There is not enough memory to perform thespecified action.
ERROR_SHARING_VIOLATION A sharing violation occurred.
Examples
Visual Basic
Public WithEvents Session As PNSession
Dim PrintSession As IPNPrintSessionDim bPrinted As Boolean
' allocate a sessionSession = New PNSession
' Set the printer and the number of printer clones to use in this sessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 1, Nothing, False)
'get new print session, need a new one for each file we are printingPrintSession = Session.NewPrintSession(1000, 2000)
' print Excel file using windows shellPrintSession.ShellPrint("C:\InputFiles\MonthySummary.xls", _
PNSrv10 COM Interface
266 PNSrv10 COM Interface Object ReferenceIPNPrintSession
pnShellAndCommandWaitMode pnShellAndCommandWaitModePrinted, _ 60000, True, 30000, False)
C#
PNSession session = null;IPNPrintSession documentPrintSession = null;
// allocate a sessionsession = new PNSession();
// Set the printer and the number of printer clones to use in this sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// get new print session, need a new one for each file we are printingdocumentPrintSession = session.NewPrintSession(5000, 2000);
// print Excel file using windows shellPrintSession.ShellPrint("C:\InputFiles\MonthySummary.xls", pnShellAndCommandWaitMode pnShellAndCommandWaitModePrinted, 60000, true, 30000, false);
See Also: ShellPrintTo PrintUsingCommand
ShellPrintTo
Description
Uses the Windows shell verb "printto" to print the file. This only works with files thathave known associations, meaning there is an installed application already on thecomputer that knows how to open and print the file.
Not all applications support the "printto" verb. As a general rule, if you can drag anddrop the file onto a printer icon, or if there is a Print option in the context menu thatappears when you right-click the file, you can use the shell to print it. Optionally, youcan have ShellPrintTo default to the ShellPrint command in the case where the printtoverb fails.
Syntaxexpression.ShellPrintTo(FullPathToFile, WaitMode, WaitModeTimeout, ForceHiddenWnd, ShellProcessTimout, ForceAppClose, UseShellPrintOnFail)
where expression is an IPNPrintSession object.
Returns Boolean True if the shell executed correctly and the file being printed reachedthe requested state (spooled, printed or completed) in the time period specified.
The method returns False if:
the file being printed has not entered the print queue within a set amount of time.This timeout period used is the FirstJobTimeout value passed in theNewPrintSessionEx call when getting the IPNPrintSession object. IfNewPrintSession is used instead the timeout value is preset at 2 minutes.
the file being printed has not reached the requested state(spooled, printed,completed) within the timeout period specified by WaitModeTimeout.
267
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
An exception is thrown if the shell call fails. See the Remarks section below for a list oferrors.
Parameters
String FullPathToFileFully-qualified path to the file to be printed.
pnShellAndCommandWaitMode WaitModeA pnShellAndCommandWaitMode constant to determine the wait mode (spooled,printed, completed) for the file being printed.
Integer WaitModeTimeoutHow long, in milliseconds, to wait for the program to print the document and for theprint job to be spooled, printed or completed, depending on the value chosen for WaitMode above.
Boolean ForceHiddenWndPass True to force the program window to be hidden. This will not work on allapplications.
Integer ShellProcessTimoutThe amount of time, in milliseconds, to wait for the launched program to close byitself. If it has not closed by the end of the timeout period and ForceAppClose isTrue, the program is passed a close message to request that it close cleanly andagain waits the timeout period. If at the end of the second wait the program still hasnot closed, it it forcibly terminated.
Boolean ForceAppClosePass True to have this method close the program manually.
Boolean UseShellPrintOnFailIf the the shell print verb "printto" fails, automatically call ShellPrint.
Remarks
If the shell call fails one of the following error message is thrown as an exception.
Error Code Description
ERROR_FILE_NOT_FOUND The specified file was not found
ERROR_PATH_NOT_FOUND The specified path was not found
ERROR_DDE_FAIL The Dynamic Data Exchange (DDE)transaction failed.
ERROR_NO_ASSOCIATION There is no application associated with thegiven file name extension.
ERROR_ACCESS_DENIED Access to the specified file is denied.
ERROR_DLL_NOT_FOUND One of the library files necessary to run theapplication can't be found.
ERROR_CANCELLED The function prompted the user foradditional information, but the user canceled
PNSrv10 COM Interface
268 PNSrv10 COM Interface Object ReferenceIPNPrintSession
Error Code Description
the request.
ERROR_NOT_ENOUGH_MEMORY There is not enough memory to perform thespecified action.
ERROR_SHARING_VIOLATION A sharing violation occurred.
Examples
Visual Basic
Public WithEvents Session As PNSession
Dim PrintSession As IPNPrintSessionDim bPrinted As Boolean
' allocate a sessionSession = New PNSession
' Set the printer and the number of printer clones to use in this sessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 1, Nothing, False)
'get new print session, need a new one for each file we are printingPrintSession = Session.NewPrintSession(1000, 2000)
' print Excel file using windows shellPrintSession.ShellPrintTo("C:\InputFiles\MonthySummary.txt", _ pnShellAndCommandWaitMode pnShellAndCommandWaitModePrinted, _ 60000, True, 30000, False, True)
C#
PNSession session = null;IPNPrintSession documentPrintSession = null;
// allocate a sessionsession = new PNSession();
// Set the printer and the number of printer clones to use in this sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// get new print session, need a new one for each file we are printingdocumentPrintSession = session.NewPrintSession(5000, 2000);
// print Excel file using windows shellPrintSession.ShellPrint("C:\InputFiles\MonthySummary.txt", pnShellAndCommandWaitMode pnShellAndCommandWaitModePrinted, 60000, true, 30000, false, true);
See Also: ShellPrint PrintUsingCommand
WaitForJobsCompleted
Description
The collection of wait functions allows you to synchronize and control the flow ofdocuments being printed with your application. The WaitForJobsCompleted methodshould be called after the document has been printed and WaitForJobsSpooling has been
269
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
called to verify that a print job actually entered the printer queue.
The WaitForJobsCompleted method will return when the document is finished printingand the output file is created, or when the given timeout period has elapsed, whicheveris first. This method is not needed if any events, such as OnEndJob, are being used todetermine when the output file is created and ready for further processed. If events arenot being used, this method can be used to determine, in a synchronous manner, whenit is safe to process the output file.
Syntaxexpression.WaitForJobsCompleted(Timeout)
where expression is an IPNPrintSession object.
Returns Boolean True if the print job completed within the timeout period, and False ifthe print job did not complete.
Parameters
Integer TimeoutThe length of time, in milliseconds, to wait for the print job to be completed.
Examples
Visual Basic
For Each file_info As System.IO.FileInfo In file_infos Dim bSpooling As Boolean Dim bCompleted As Boolean Dim bCompleted As Boolean Dim MaxWait, CurrentWait, WaitStep As Integer
' Open the PowerPoint document oPresentation = oPPTApp.Presentations.Open(FileName:=file_info.FullName)
' print in the background oPresentation.PrintOptions.PrintInBackground = MsoTriState.msoTrue
' Get the print session documentPrintSession = Nothing Try While documentPrintSession Is Nothing documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) End While Catch ex As Exception oPresentation.Close Continue For End Try
' set active printer, PowerPoint does not set it as the system default oPPTApp.ActivePrinter = documentPrintSession.PrinterName
' print presentation oPresentation.PrintOut()
' wait for document to enter spooling state, how long to wait here ' depends on how long it may take the printing application to print ' the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000)
If Not bSpooling Then documentPrintSession.Cancel() Else
PNSrv10 COM Interface
270 PNSrv10 COM Interface Object ReferenceIPNPrintSession
' wait for document to be completely printed and output file created. ' How long to wait here depends on the size of the presentation, and the ' printer settings.
' max wait 5 minutes max for file to be done MaxWait = 300000 WaitStep = 60000 CurrentWait = 0 While CurrentWait < MaxWait bCompleted = documentPrintSession.WaitForJobsCompleted(WaitStep) If Not bCompleted Then CurrentWait = CurrentWait + WaitStep End If End While
If bCompleted
'Process output file SendFilesToServer()
Else documentPrintSession.Cancel() End If End If
' Printing complete, or has failed and been canceled. ' Release the print session so another document may start printing If Not documentPrintSession Is Nothing Then System.Runtime.InteropServices.Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing
End If
' close presentation oPresentation.Close()
Next file_info
C#
foreach (System.IO.FileInfo iFI in infos){ bool bSpooling = false, bPrinted = false, bCompleted = false; int MaxWait = 0, CurrentWait= 0, WaitStep = 0;
// Open the PowerPoint document oPresentation = oPPTApp.Presentations.Open(iFI.FullName, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
// print in the background oPresentation.PrintOptions.PrintInBackground = MsoTriState.msoTrue;
// Get a PrintSession object documentPrintSession = null; try { While (documentPrintSession == null) { documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } } Catch (Exception ex) { oPresentation.Close(); continue; }
271
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
// set active printer, PowerPoint does not set it as the system default oPPTApp.ActivePrinter = documentPrintSession.PrinterName;
// print presentation in the background as set above oPresentation.PrintOut(1, oPresentation.Slides.Count,"", 1,MsoTriState.msoTrue);
// wait for document to enter spooling state, how long to wait here // depends on how long it may take the printing application to print // the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000);
if ( !bSpooling ) { documentPrintSession.Cancel(); } else { // wait for document to be completely printed and output file created. // How long to wait here depends on the size of the presentation, and the // printer settings. MaxWait = 300000; WaitStep = 60000; CurrentWait = 0; while (CurrentWait < MaxWait) { bCompleted = documentPrintSession.WaitForJobsCompleted(WaitStep); if ( bCompleted == false) { CurrentWait += WaitStep; } }
if (bCompleted) { //Process output file SendFilesToServer(); } else { documentPrintSession.Cancel(); } }
// Printing started or failed and has been cancelled. // Release the print session so another document may start printing if (documentPrintSession != null ) { InteropServices.Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null; }
// close presentation oPresentation.Close();
}
See Also: WaitForJobsSpooling WaitForJobsSpooled WaitForJobsPrinted
WaitForJobsSpooled
Description
The collection of wait functions allows you to synchronize and control the flow ofdocuments being printed with your application. The WaitForJobsSpooled method should
PNSrv10 COM Interface
272 PNSrv10 COM Interface Object ReferenceIPNPrintSession
be called after the document has been printed and WaitForJobsSpooling has been calledto verify that a print job actually entered the printer queue.
In many cases, the document needs to be completely spooled to the printer before eitherthe document or the printing application can be closed. Closing either too early in theprocess can cause the application to cancel the print job, or send an incomplete printjob.
Depending on the behaviour of the printing application this method may not need to becalled at all. One example of this is the Microsoft Word automation object wherebackground printing and the BackgroundPrintingStatus flag can be used to determinewhen the file has been completely spooled to the printer and it is safe to close thedocument and/or the application. In comparison, when automating printing withMicrosoft PowerPoint the WaitForJobsSpooled method needs to be called in order todetermine when it is safe to close the PowerPoint file.
Syntaxexpression.WaitForJobsSpooled(Timeout)
where expression is an IPNPrintSession object.
Returns Boolean True if the print job spooled within the timeout period, and False if itdid not.
Parameters
Integer TimeoutThe length of time, in milliseconds, to wait for the print job to be spooled.
Examples
Visual Basic
For Each file_info As System.IO.FileInfo In file_infos Dim bSpooling As Boolean Dim bSpooled As Boolean
' Open the PowerPoint document oPresentation = oPPTApp.Presentations.Open(FileName:=file_info.FullName)
' print in the background oPresentation.PrintOptions.PrintInBackground = MsoTriState.msoTrue
' Get the print session documentPrintSession = Nothing Try While documentPrintSession Is Nothing documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) End While Catch ex As Exception oPresentation.Close Continue For End Try
' set active printer, PowerPoint does not set it as the system default oPPTApp.ActivePrinter = documentPrintSession.PrinterName
' print presentation oPresentation.PrintOut()
' wait for document to enter spooling state, how long to wait here
273
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
' depends on how long it may take the printing application to print ' the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000)
If Not bSpooling Then documentPrintSession.Cancel() Else
' wait for document to be completely spooled to the printer. How long ' to wait here depends on the size of the presentation, the printer ' settings and how long it may take for the presentation to spool completely. bSpooled = documentPrintSession.WaitForJobsSpooled(120000) If Not bSpooled Then documentPrintSession.Cancel() End If
End If
' Printing started or failed and has been cancelled. ' Release the print session so another document may start printing If Not documentPrintSession Is Nothing Then InteropServices.Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing End If
' close presentation oPresentation.Close()
Next file_info
C#
foreach (System.IO.FileInfo iFI in infos){ bool bSpooling = false, bSpooled = false;
// Open the PowerPoint document oPresentation = oPPTApp.Presentations.Open(iFI.FullName, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
// print in the background oPresentation.PrintOptions.PrintInBackground = MsoTriState.msoTrue;
// Get a PrintSession object documentPrintSession = null; try { While (documentPrintSession == null) { documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } } Catch (Exception ex) { oPresentation.Close(); continue; }
// set active printer, PowerPoint does not set it as the system default oPPTApp.ActivePrinter = documentPrintSession.PrinterName;
// print presentation in the background as set above oPresentation.PrintOut(1, oPresentation.Slides.Count,"", 1,MsoTriState.msoTrue);
// wait for document to enter spooling state, how long to wait here // depends on how long it may take the printing application to print // the document.
PNSrv10 COM Interface
274 PNSrv10 COM Interface Object ReferenceIPNPrintSession
bSpooling = documentPrintSession.WaitForJobsSpooling(60000);
if ( !bSpooling ) { documentPrintSession.Cancel(); } else { // wait for document to be completely spooled to the printer. How long // to wait here depends on the size of the presentation, the printer // settings and how long it may take for the presentation to spool completely. bSpooled = documentPrintSession.WaitForJobsSpooled(120000); if (! bSpooled ) { documentPrintSession.Cancel(); } }
// Printing started or failed and has been cancelled. // Release the print session so another document may start printing if (documentPrintSession != null ) { InteropServices.Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null; }
// close presentation oPresentation.Close();
}
See Also: WaitForJobsSpooling WaitForJobsPrinted WaitForJobsCompleted
WaitForJobsSpooling
Description
The collection of wait functions allows you to synchronize and control the flow ofdocuments being printed with your application.
The WaitForJobsSpooling method should be called just after the document has beenprinted and will return as soon as the document has started to spool or when the giventimeout period has elapsed.
This allows for error recovery if the document fails to print from the printing application.If the document does not start spooling within the timeout period the print sessionshould be canceled using the Cancel method before releasing the print session object toallow the printer to be returned to the pool of available printers as soon as possible.
If no print job enters the print queue and the print session is not canceled before beingreleased, the printer will wait a specified timeout period before being returned to thepool of available printers. This timeout period is 2 minutes if the print session wascreated by calling NewPrintSession, or the argument specified as the FirstJobTimeoutparameter if the print session was created by calling NewPrintSessionEx.
In many cases, other printing states such as spooled or printed may need to be checkedbefore the document or printing application can be safely closed. Closing either too earlycan cause the printing application to abort the print job.
275
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
Syntaxexpression.WaitForJobsSpooling(Timeout)
where expression is an IPNPrintSession object.
Returns Boolean True if a print job started spooling in the print queue within the timeoutperiod, and False if it did not.
Parameters
Integer TimeoutThe length of time, in milliseconds, to wait for a print job to start spooling.
Examples
Visual Basic
For Each file_info As System.IO.FileInfo In file_infos Dim bSpooling As Boolean
' Open the word document oDoc = oWordApp.Documents.Open(FileName:=file_info.FullName, _ AddToRecentFiles:=False)
' Get the print session documentPrintSession = Nothing Try While documentPrintSession Is Nothing documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) End While Catch ex As Exception oDoc.Close(SaveChanges:=False) Continue For End Try
If documentPrintSession Is Nothing Then oDoc.Close(SaveChanges:=False) Continue For End If
' set active printer the thread-safe way printerName = documentPrintSession.PrinterName With oWordApp.Dialogs(Word.WdWordDialog.wdDialogFilePrintSetup) .Printer = printerName .DoNotSetAsSysDefault = True .Execute() End With
' print in the background oDoc.PrintOut(Background:=True)
' wait for document to enter spooling state, how long to wait here ' depends on how long it may take the printing application to print ' the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000)
If Not bSpooling Then documentPrintSession.Cancel() End If
'Printing started or has been cancelled.Release the print session so ' another document may start printing If Not documentPrintSession Is Nothing Then InteropServices.Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing End If
PNSrv10 COM Interface
276 PNSrv10 COM Interface Object ReferenceIPNPrintSession
' Make sure Word is finished before closing the document If (bDocSpooling) Then While oWordApp.BackgroundPrintingStatus <> 0 System.Threading.Thread.Sleep(250) End While End If
' close document oDoc.Close(SaveChanges:=False)
Next file_info
C#
// loop through each file and convertforeach (System.IO.FileInfo iFI in infos){ boolean bSpooling = false; object myTrue = true, filename = iFI.FullPath;
// Open the word document oDoc = oWordApp.Documents.Open(ref filename, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// Get the print session documentPrintSession = null; try { while documentPrintSession == null ) { documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } } catch (Exception ex) { oDoc.Close(ref optMissing, ref optMissing, ref optMissing); continue; }
// set active printer the thread-safe way object oWordbasic = oWordApp.WordBasic; object[] argValues = new object[] { printSession.PrinterName, 1 }; String[] argNames = new String[] { "Printer", "DoNotSetAsSysDefault" }; oWordbasic.GetType().InvokeMember("FilePrintSetup", System.Reflection.BindingFlags.InvokeMethod, null, oWordbasic, argValues, null, null, argNames);
// print in the background oDoc.PrintOut(ref myTrue, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
// wait for document to enter spooling state, how long to wait here // depends on how long it may take the printing application to print // the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000); if (bSpooling == false) { documentPrintSession.Cancel(); }
277
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
//Printing started or has been canceled.Release the print session so // another document may start printing InteropServices.Marshal.FinalReleaseComObject(documentPrintSession);
// Make sure Word is finished before closing the document if (bDocSpooling) { while (oWordApp.BackgroundPrintingStatus != 0 ) { System.Threading.Thread.Sleep(250); } }
// close document oDoc.Close(ref optMissing, ref optMissing, ref optMissing);
}
See Also: WaitForJobsPrinted WaitForJobsCompleted WaitForJobsSpooled
WaitForJobsPrinted
Description
The collection of wait functions allows you to synchronize and control the flow ofdocuments being printed with your application. The WaitForJobsPrinted method shouldbe called after the document has been printed and WaitForJobsSpooling has been calledto verify that a print job actually entered the printer queue.
There is a distinction between when the document finishes printing and when the outputfile is complete.The document can be printed and have left the print queue before theprinter has finished creating the output file; this difference is minimal and only becomesapparent in automation code when trying to use the output file before the printer hasfinished creating it.
Depending on the behaviour of the printing application this method may not need to becalled at all. One example of this is the Microsoft Word automation object wherebackground printing and the BackgroundPrintingStatus flag can be used to determinewhen the file has been completely spooled to the printer and it is safe to close thedocument and/or the application. In comparison, other applications may need to wait forthe entire file to completely printed before it is safe to close both the file and theapplication.
Syntaxexpression.WaitForJobsPrinted(Timeout)
where expression is an IPNPrintSession object.
Returns Boolean True if the print job has completed printing within the timeout period,and False if it did not.
Parameters
Integer TimeoutThe length of time, in milliseconds, to wait for the print job to be printed.
PNSrv10 COM Interface
278 PNSrv10 COM Interface Object ReferenceIPNPrintSession
Examples
Visual Basic
For Each file_info As System.IO.FileInfo In file_infos Dim bSpooling As Boolean Dim bPrinted As Boolean
' Open the PowerPoint document oPresentation = oPPTApp.Presentations.Open(FileName:=file_info.FullName)
' print in the background oPresentation.PrintOptions.PrintInBackground = MsoTriState.msoTrue
' Get the print session documentPrintSession = Nothing Try While documentPrintSession Is Nothing documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) End While Catch ex As Exception oPresentation.Close Continue For End Try
' set active printer, PowerPoint does not set it as the system default oPPTApp.ActivePrinter = documentPrintSession.PrinterName
' print presentation oPresentation.PrintOut()
' wait for document to enter spooling state, how long to wait here ' depends on how long it may take the printing application to print ' the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000)
If Not bSpooling Then documentPrintSession.Cancel() Else
' wait for document to be completely printed to the printer. How long ' to wait here depends on the size of the presentation, the printer ' settings and how long it may take for the presentation to print completely. bPrinted = documentPrintSession.WaitForJobsPrinted(120000) If Not bSpooled Then documentPrintSession.Cancel() End If
End If
' Printing started or failed and has been cancelled. ' Release the print session so another document may start printing If Not documentPrintSession Is Nothing Then InteropServices.Marshal.FinalReleaseComObject(documentPrintSession) documentPrintSession = Nothing End If
' close presentation oPresentation.Close()
Next file_info
C#
foreach (System.IO.FileInfo iFI in infos){ bool bSpooling = false, bPrinted = false;
279
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
// Open the PowerPoint document oPresentation = oPPTApp.Presentations.Open(iFI.FullPath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
// print in the background oPresentation.PrintOptions.PrintInBackground = MsoTriState.msoTrue;
// Get a PrintSession object documentPrintSession = null; try { While (documentPrintSession == null) { documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } } Catch (Exception ex) { oPresentation.Close(); continue; }
// set active printer, PowerPoint does not set it as the system default oPPTApp.ActivePrinter = documentPrintSession.PrinterName;
// print presentation in the background as set above oPresentation.PrintOut(1, oPresentation.Slides.Count,"", 1,MsoTriState.msoTrue);
// wait for document to enter spooling state, how long to wait here // depends on how long it may take the printing application to print // the document. bSpooling = documentPrintSession.WaitForJobsSpooling(60000);
if ( !bSpooling ) { documentPrintSession.Cancel(); } else { // wait for document to be completely printed to the printer. How long // to wait here depends on the size of the presentation, the printer // settings and how long it may take for the presentation to print completely. bSpooled = documentPrintSession.WaitForJobsPrinted(120000); if (! bSpooled ) { documentPrintSession.Cancel(); } }
// Printing started or failed and has been cancelled. // Release the print session so another document may start printing if (documentPrintSession != null ) { InteropServices.Marshal.FinalReleaseComObject(documentPrintSession); documentPrintSession = null; }
// close presentation oPresentation.Close();
}
See Also: WaitForJobsSpooling WaitForJobsSpooled WaitForJobsCompleted
PNSrv10 COM Interface
280 PNSrv10 COM Interface Object ReferenceIPNPrintSession
Properties
PrinterName
Description
Returns the name of the printer associated with this print session object. Use this printername when setting the default printer or passing the printer name to a program.
Read-only.
Syntaxexpression.PrinterName
where expression is an IPNPrintSession object.
Returns a String.
Examples
This sample uses the PrinterName from the print session object to set the printer on theWord automation object.
Visual Basic
Dim Session As PNSessionDim PrintSession As IPNPrintSession
Dim oExcelApp As Excel.ApplicationDim oWB As Excel.WorkbookDim printerName As String
Session = New PNSessionSession.SetSessionPrinter("TIFF Image Printer 10.0", 1,"", False )
'get new print session, need a new one for each file we are printingPrintSession = Session.NewPrintSession(1000, 2000)
printerName = PrintSession.PrinterNameTry 'open worbook oWB = oExcelApp.Workbooks.Open("C:\ExcelFiles\Budget.xls")
oWB.PrintOut(ActivePrinter:=printerName)
'Close workbook (optional) oWB.Close()
' wait for file to be complete PrintSession.WaitForJobsCompleted(120000) ' 2 min max to print
'Clean up memory (you must do this) oWB = Nothing
Catch ex As Exception MessageBox.Show("Exception in Excel (" + ex.Message + ").")End Try
C#
PNSession session = null;IPNPrintSession documentPrintSession = null;ExcelApp.Application oExcelApp = new ExcelApp.Application();
281
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
ExcelApp.Workbook oWorkbook ;
// allocate a sessionsession = new PNSession();
// Set the printer and the number of printer clones to use in this sessionsession.SetSessionPrinter("TIFF Image Printer 10.0", 1, null, false);
// get new print session, need a new one for each file we are printingdocumentPrintSession = session.NewPrintSession(5000, 2000);
// open the spreadsheetoWorkbook = oExcelApp.Workbooks.Open("C:\ExcelFiles\Budget.xls", 0, false, 5, "", "", false, ExcelApp.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
// print spreadsheet to COM object printeroWorkbook.PrintOut(System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, false, documentPrintSession.PrinterName, false, false, "");
// wait for job to completedocumentPrintSession.WaitForJobsCompleted(60000);
oWorkbook.Close(false, System.Reflection.Missing.Value, false);oExcelApp.Quit();
See Also: SetSessionPrinter NewPrintSession
PrintSessionGUID
Description
A string based unique identifier for matching IPNJob information to a print session. Everynew print session is given a unique identifier, and every print job processed by that printsession is also assigned that unique identifier.
This identifier can be used to track information from the printing cycle to be used in theevent handlers. The IPNJob object sent to the event handler also contains a reference tothe PrintSessionGUID. An example of this would be to storing the source document namein a key-value mapped collection keyed by PrintSessionGUID to later be used on the OnEndJob event handler.
Read-only.
Syntaxexpression.PrintSessionGUID
where expression is an IPNPrintSession object.
Returns a String.
Examples
Visual Basic
Public guidSourceMap As New StringDictionary()
PNSrv10 COM Interface
282 PNSrv10 COM Interface Object ReferenceIPNPrintSession
Public dictLock As New Object
For Each file_info As System.IO.FileInfo In file_infos Dim bSpooling As Boolean
' Open the word document oDoc = oWordApp.Documents.Open(FileName:=file_info.FullName, _ AddToRecentFiles:=False)
' Get the print session documentPrintSession = Nothing Try While documentPrintSession Is Nothing documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0) End While Catch ex As Exception oDoc.Close(SaveChanges:=False) Continue For End Try
If documentPrintSession Is Nothing Then oDoc.Close(SaveChanges:=False) Continue For End If
' thread safe access SyncLock (dictLock) guidSourceMap.Add(documentPrintSession.PrintSessionGUID, _ file_info.FullName)
End SyncLock
...
Next file_info
Private Sub Session_OnEndJob(ByVal pJob As IPNJob) Handles Session.OnEndJob Dim sourceFile As String
' thread safe access SyncLock (dictLock) ' get the source file(s) for this JobGUID If guidSourceMap.ContainsKey(pJob.PrintSessionGUID) Then sourceFile = guidSourceMap(pJob.PrintSessionGUID) SetLogData("OnEndJob: " + pJob.JobGUID + _ " Source File was " + sourceFile) End If End SyncLockEnd Sub
C#
private StringDictionary guidSourceMap = new StringDictionary();private Object dictLock = new Object(); // lock access to guidSourceMap
// loop through each file and convertforeach (System.IO.FileInfo iFI in infos){ boolean bSpooling = false; object myTrue = true, filename = iFI.FullPath;
// Open the word document oDoc = oWordApp.Documents.Open(ref filename, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing, ref optMissing);
283
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPrintSession
// Get the print session documentPrintSession = null; try { while documentPrintSession == null ) { documentPrintSession = session.NewPrintSessionEx(5000, 60000, 250, 0); } } catch (Exception ex) { oDoc.Close(ref optMissing, ref optMissing, ref optMissing); continue; }
// thread-safe access lock( dictLock) { -guidSourceMap.Add(documentPrintSession.PrintSessionGUID, iFI.FullPath); }
...
}
void session_OnEndJob(IPNJob pJob){ // thread safe access lock (dictLock) { // get the source file(s) for this JobGUID if (this.guidSourceMap.ContainsKey(pJob.PrintSessionGUID)) { String sourceFileName = this.guidSourceMap[pJob.PrintSessionGUID]; this.SetLogData("OnEndJob: " + pJob.JobGUID + _ " Source File was " + sourceFileName); } }}
See Also: IPNJob IPNJob.PrintSessionGUID
PNSrv10 COM Interface
284 PNSrv10 COM Interface Object ReferenceIPNJobs Collection
IPNJobs Collection
Description
A collection of IPNJob objects, one for every job that has been printed. Allows quickiteration through the collection using the foreach statement of the C# language and thefor each statement in Visual Basic.
Public Methods
Item Returns an individual IPNJob item from the collection.The collection can be indexed by position or by JobGUID string.
Public Properties
Count Read-only; Returns an Integer that represents thenumber of IPNJob objects in the collection.
285
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJobs Collection
Methods
Item
Description
Returns an individual IPNJob item from the collection.
Syntaxexpression.Item(Index)
where expression is an IPNJobs collection
Returns an IPNJob item, or E_FAIL if the Index is out of range.
Parameters
Object IndexThe collection can be indexed by integer position or by JobGUID string.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each JobObject As IPNJob In jobs
Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + JobObject.JobGUID) jobNode.Nodes.Add("Document: " + JobObject.Document)
jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString())
Next JobObject
' find a certain job in the list first by index, then by stringDim jobByIndex, jobByString As IPNJob
jobByIndex = jobs(2)jobByString = jobs(jobByIndex.JobGUID)
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob JobObject in jobs){
PNSrv10 COM Interface
286 PNSrv10 COM Interface Object ReferenceIPNJobs Collection
TreeNode jobNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + JobObject.JobGUID); jobNode.Nodes.Add("Document: " + JobObject.Document); jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString());
}// find a certain job in the list first by index, then by stringIPNJob jobByIndex, jobByString;
jobByIndex = jobs[2];jobByString = jobs[jobByIndex.JobGUID];
See Also: Count IPNJob
287
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJobs Collection
Properties
Count
Description
Returns the number of IPNJob objects in the IPNJobs collection. Each time a file isprinted, a new IPNJob object is added to the collection. If nothing has been printed, thecollection will be empty.
Read-only Integer.
Syntaxexpression.Count
where expression is an IPNJobs collection
Returns an Integer.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
If (jobs.Count > 0) Then MsgBox("There are " + jobs.Count.ToString + " jobs in the collection")End If
C#
IPNJobs jobs;
jobs = session.Jobs ;
if (jobs.Count > 0){ MessageBox.Show("There are " + jobs.Count.ToString() + " jobs in the collection");}
See Also: Item IPNJob
PNSrv10 COM Interface
288 PNSrv10 COM Interface Object ReferenceIPNJob
IPNJob
Description
Each IPNJob object represents a single print job sent to any one of the printer queues inthe current IPNSession object. Most often there is a single print job created each for eachdocument printed, but some applications can send multiple jobs when printing a singlefile. One example of this is Excel when printing a workbook containing multipleworksheets at different print quality settings. Excel will create a separate print job foreach group of worksheets with different print qualities.
The job object is identified by a unique identifier, the JOBGUID and contains informationabout the job such as the job status and the number of pages spooled and printed. Italso provides access to two collections: an IPNFiles collection of the files created by thisjob and an IPNPages collection of the printed pages belonging to this job.
Public Methods
GetVariableByKeyword Retrieves the job setting, or variable, represented bythe pnJobVariable enumeration value passed in.
GetVariable Retrieves the job setting, or variable, represented bythe string value passed in.
SetVariableByKeyword Sets the job setting, or variable, represented by thepnJobVariable enumeration value passed in.
SetVariable Sets the job setting, or variable, represented by thestring value passed in.
Public Properties
AbortedBySystem Read-only; Boolean value True if the job was deletedby the system.
AbortedByUser Read-only; Boolean value True if the job was deletedby the user.
BytesPrinted Read-only; How much of the spooled document hasbeen printed. This value is updated during theprinting process.
BytesSpooled Read-only; Size of the document (in bytes)in theprinter queue. This value is updated as the file isspooled.
ConversionStatus Read-only; Boolean value True if the job wassuccessfully converted to the output file.
Document Read-only; Name of the document printed.
289
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
Files Read-only; IPNFiles collection of IPNFile objectscreated by this print job. This value is updated duringthe printing process.
JobGUID Read-only; Unique identifier for this object. Can beused to query the IPNJobs collection.
JobID Read-only; non-unique identifier used by the Windowsprinting sub-system.
Pages Read-only; collection of IPNPage objects created bythis print job. This value is updated during the printingprocess.
PagesPrinted Read-only; count of the number of pages printed. Thisvalue is updated during the printing process.
PagesSpooled Read-only; count of the number of pages spooled. Thisvalue is updated during the printing process.
PrintSessionGUID Read-only; Unique identifier that can be used toassociate this job with a print session.
Session Read-only; The parent IPNSession object that createdthis IPNJob object.
Status Read-only; current print status of the job as anInteger value. This value is updated during theprinting process.
StatusMessage Read-only; current print status of the job as an stringvalue. This value is updated during the printingprocess.
SubmittedTime Read-only; VT_DATE variant that specifies the timethis document was spooled.
UserName Read-only; name of the user who printed thedocument.
PNSrv10 COM Interface
290 PNSrv10 COM Interface Object ReferenceIPNJob
Methods
SetVariableByKeyword
Description
Allows you to further customize the job settings when using the IPNSession objectevents, such as supplying a custom file name during the OnGetNextFileName event, orusing the OnStartPage event to count pages and start a new file after a certain numberof pages. Not all variables can be used on all events; see Using job variables to setproperties for a list of variables and the events they can be used in.
Syntaxexpression.SetVariableByKeyword(Name, Value)
where expression is an IPNJob object.
Parameters
pnJobVariable NameA pnJobVariable constant for the setting to change.
Variant ValueA variant object containing the appropriate value for the pnJobVariable specified.
Examples
Visual Basic
Public WithEvents Session As PNSessionPublic m_currentFileNumber As IntegerPublic m_BaseName As String
Private Sub Session_OnGetNextFileName(ByVal pJob As IPNJob) Handles Session.OnGetNextFileName
Dim strCombinedBaseName As String
strCombinedBaseName = "SampleFileName_" + _ String.Format("{0:000000}",m_currentFileNumber) pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, strCombinedBaseName)End Sub
C#
printSession.OnGetNextFileName += new _IPNSessionEvents_OnGetNextFileNameEventHandler(printSession_OnGetNextFileName);
void printSession_OnGetNextFileName(IPNJob pJob){ string strCombinedBaseName;
filename = "SampleFileName_" + String.Format("{0:000000}", m_currentFileNumber); pJob.SetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName, strCombinedBaseName);}
See Also: pnJobVariable GetVariableByKeyword SetVariable GetVariable
291
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
OnGetNextFileName OnOpenFile OnStartImage OnStartJob OnStartPage OnCloseFileOnEndImage OnEndJob OnEndPage
SetVariable
Description
This function is the same as SetVariableByKeyword. Where possible, it is better to useSetVariableByKeyword which reduces the possibility of a spelling error by using anenumeration to pass the variable name instead of the string argument used bySetVariable. See Using string keywords to set properties for a list of string values andthe events they can be used in.
Syntaxexpression.SetVariable(Name, Value)
where expression is an IPNJob object.
Parameters
String NameA string representing the name of the variable to set.
Variant ValueA variant object containing the appropriate value for the string specified in Name.
Examples
Visual Basic
Public WithEvents Session As PNSessionPublic m_currentFileNumber As IntegerPublic m_BaseName As String
Private Sub Session_OnGetNextFileName(ByVal pJob As IPNJob) Handles Session.OnGetNextFileName
Dim strCombinedBaseName As String
strCombinedBaseName = "SampleFileName_" + _ String.Format("{0:000000}", m_currentFileNumber) pJob.SetVariable("OutputFilename", strCombinedBaseName)End Sub
C#
printSession.OnGetNextFileName += new _IPNSessionEvents_OnGetNextFileNameEventHandler(printSession_OnGetNextFileName);
void printSession_OnGetNextFileName(IPNJob pJob){ string strCombinedBaseName;
filename = "SampleFileName_" + String.Format("{0:000000}", m_currentFileNumber); pJob.SetVariable("OutputFilename", strCombinedBaseName);}
PNSrv10 COM Interface
292 PNSrv10 COM Interface Object ReferenceIPNJob
See Also:
pnJobVariable GetVariableByKeyword SetVariableByKeyword GetVariableOnGetNextFileName OnOpenFile OnStartImage OnStartJob OnStartPage OnCloseFileOnEndImage OnEndJob OnEndPage
GetVariable
Description
This function is the same as GetVariableByKeyword. Where possible, it is better to useGetVariableByKeyword which reduces the possibility of a spelling error by using anenumeration to pass the variable name instead of the string argument used byGetVariable. See Using string keywords to set properties for a list of string values andthe events they can be used in.
Syntaxexpression.GetVariable(Name)
where expression is an IPNJob object.
Returns a VARIANT containing appropriate value for the variable name specified.
Parameters
String strNameA string representing the name of the variable to retrieve.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnOpenFile(ByVal pFile As IPNFile) Handles Session.OnOpenFile Dim outputFileName As String outputFileName = pFile.Job.GetVariable("OutputFilename")End Sub
C#
printSession.OnOpenFile += new _IPNSessionEvents_OnOpenFileEventHandler(printSession_OnOpenFile);
void printSession_OnOpenFile(IPNFile pFile){ string outputFileName; outputFileName = pFile.Job.GetVariable("OutputFilename");}
See Also: pnJobVariable GetVariableByKeyword SetVariableByKeyword SetVariableOnGetNextFileName OnOpenFile OnStartImage OnStartJob OnStartPage OnCloseFileOnEndImage OnEndJob OnEndPage
293
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
GetVariableByKeyword
Description
Allows you to query the current job settings when using the IPNSession object events. Acommon use would be to retrieve the current custom file name being used during the OnGetNextFileName event. Not all variables can be used on all events; see Using jobvariables to set properties for a list of variables and the events they can be used in.
Syntaxexpression.GetVariableByKeyword(Name)
where expression is an IPNJob object.
Returns a VARIANT containing appropriate value for the pnJobVariable specified.
Parameters
pnJobVariable NameA pnJobVariable constant for the setting to retrieve.
Examples
Visual Basic
Public WithEvents Session As PNSession
Private Sub Session_OnOpenFile(ByVal pFile As IPNFile) Handles Session.OnOpenFile Dim outputFileName As String
outputFileName = pFile.Job.GetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName)End Sub
C#
printSession.OnOpenFile += new _IPNSessionEvents_OnOpenFileEventHandler(printSession_OnOpenFile);
void printSession_OnOpenFile(IPNFile pFile){ string outputFileName;
outputFileName = pFile.Job.GetVariableByKeyword(pnJobVariable.pnJobVariableOutputFileName);}
See Also: pnJobVariable SetVariableByKeyword SetVariable GetVariableOnGetNextFileName OnOpenFile OnStartImage OnStartJob OnStartPage OnCloseFileOnEndImage OnEndJob OnEndPage
PNSrv10 COM Interface
294 PNSrv10 COM Interface Object ReferenceIPNJob
Properties
AbortedBySystem
Description
This property is True if the job was halted during the conversion process. This canhappen if the Windows printing subsystem (print spooler) is restarted while the job isbeing spooled and printed.
Read-only.
Syntaxexpression.AbortedBySystem
where expression is an IPNJob object.
Returns a Boolean.
Examples
Visual Basic
Dim sessionNode,jobNode As TreeNodeDim jobs As IPNJobs
jobs = Session.JobstvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")jobNode = sessionNode.Nodes.Add("Jobs")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim w32Error As New Win32Exception(Job.ConversionStatus)
jobNode.Nodes.Add("Job GUID:" + Job.JobGUID.ToString()) jobNode.Nodes.Add("Document: " + Job.Document) jobNode.Nodes.Add("Aborted By User:" + Job.AbortedByUser.ToString()) jobNode.Nodes.Add("Aborted By System:" + Job.AbortedBySystem.ToString()) jobNode.Nodes.Add("Conversion Status: " + w32Error.Message + _ " (" + w32Error.NativeErrorCode.ToString() + ")")Next
C#
IPNJobs jobs; TreeNode jobNode;
jobs = session.Jobs ;tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");jobNode = m_TVSessionRoot.Nodes.Add("Jobs");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ Win32Exception w32Error;
jobNode.Nodes.Add("Job GUID: " + Job.JobGUID); jobNode.Nodes.Add("Document: " + Job.Document); jobNode.Nodes.Add("AbortedBySystem: " + Job.AbortedBySystem.ToString()); jobNode.Nodes.Add("AbortedByUser: " + Job.AbortedByUser.ToString());
295
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
w32Error = new Win32Exception(Job.ConversionStatus); jobNode.Nodes.Add("Conversion Status: " + w32Error.Message + " (" + w32Error.NativeErrorCode.ToString() + ")");}
See Also: AbortedByUser BytesPrinted BytesSpooled ConversionStatus Document FilesJobGUID JobID Pages PagesPrinted PagesSpooled Session StatusStatusMessage SubmittedTime UserName
AbortedByUser
Description
This property is True if the job was halted during the conversion process. This canhappen if the job was manually deleted by the user from the printer queue.
Read-only.
Syntaxexpression.AbortedByUser
where expression is an IPNJob object.
Returns a Boolean.
Examples
Visual Basic
Dim sessionNode,jobNode As TreeNodeDim jobs As IPNJobs
jobs = Session.JobstvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")jobNode = sessionNode.Nodes.Add("Jobs")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim w32Error As New Win32Exception(Job.ConversionStatus)
jobNode.Nodes.Add("Job GUID:" + Job.JobGUID.ToString()) jobNode.Nodes.Add("Document: " + Job.Document) jobNode.Nodes.Add("Aborted By User:" + Job.AbortedByUser.ToString()) jobNode.Nodes.Add("Aborted By System:" + Job.AbortedBySystem.ToString()) jobNode.Nodes.Add("Conversion Status: " + w32Error.Message + _ " (" + w32Error.NativeErrorCode.ToString() + ")")Next
C#
IPNJobs jobs; TreeNode jobNode;
jobs = session.Jobs ;tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");jobNode = m_TVSessionRoot.Nodes.Add("Jobs");
// fill in job node in tree view
PNSrv10 COM Interface
296 PNSrv10 COM Interface Object ReferenceIPNJob
foreach (IPNJob Job in jobs){ Win32Exception w32Error;
jobNode.Nodes.Add("Job GUID: " + Job.JobGUID); jobNode.Nodes.Add("Document: " + Job.Document); jobNode.Nodes.Add("AbortedBySystem: " + Job.AbortedBySystem.ToString()); jobNode.Nodes.Add("AbortedByUser: " + Job.AbortedByUser.ToString());
w32Error = new Win32Exception(Job.ConversionStatus); jobNode.Nodes.Add("Conversion Status: " + w32Error.Message + " (" + w32Error.NativeErrorCode.ToString() + ")");}
See Also: AbortedBySystem BytesPrinted BytesSpooled ConversionStatus Document FilesJobGUID JobID Pages PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
BytesPrinted
Description
Returns the size of the printed job in bytes. This can be different from BytesSpooled, andis updated while the file is being printed.
Read-only.
Syntaxexpression.BytesPrinted
where expression is an IPNJob object.
Returns an Integer.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Document: " + Job.Document) jobNode.Nodes.Add("Bytes Printed:" + Job.BytesPrinted.ToString())
Next
C#
IPNJobs jobs;
297
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Document: " + Job.Document); jobNode.Nodes.Add("Bytes Printed:" + Job.BytesPrinted.ToString());
}
See Also: AbortedBySystem AbortedByUser BytesSpooled ConversionStatus DocumentFiles JobGUID JobID Pages PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
BytesSpooled
Description
The size of the spooled job in bytes. This value us updated as the file is spooled to theprinter and can be different from BytesPrinted.
Read-only.
Syntaxexpression.BytesSpooled
where expression is an IPNJob object.
Returns an Integer.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Document: " + Job.Document) jobNode.Nodes.Add("Bytes Spooled:" + Job.BytesSpooled.ToString())
Next
PNSrv10 COM Interface
298 PNSrv10 COM Interface Object ReferenceIPNJob
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Document: " + Job.Document); jobNode.Nodes.Add("Bytes Spooled:" + Job.BytesSpooled.ToString());
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted PagesSpooled Session StatusStatusMessage SubmittedTime UserName
ConversionStatus
Description
This property returns an HRESULT value for the conversion status. To get the status andany error message information the property, use the HRESULT to create an instance of a Win32Exception class. This state can only be checked when the job is completelyfinished.
Read-only.
Syntaxexpression.ConversionStatus
where expression is an IPNJob object.
Returns an Integer containing the HRESULT return code.
Examples
Visual Basic
Dim sessionNode,jobNode As TreeNodeDim jobs As IPNJobs
jobs = Session.JobstvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")jobNode = sessionNode.Nodes.Add("Jobs")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim w32Error As New Win32Exception(Job.ConversionStatus)
jobNode.Nodes.Add("Job GUID:" + Job.JobGUID.ToString()) jobNode.Nodes.Add("Document: " + Job.Document)
299
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
jobNode.Nodes.Add("Aborted By User:" + Job.AbortedByUser.ToString()) jobNode.Nodes.Add("Aborted By System:" + Job.AbortedBySystem.ToString()) jobNode.Nodes.Add("Conversion Status: " + w32Error.Message + _ " (" + w32Error.NativeErrorCode.ToString() + ")")Next
C#
IPNJobs jobs; TreeNode jobNode;
jobs = session.Jobs ;tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");jobNode = m_TVSessionRoot.Nodes.Add("Jobs");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ Win32Exception w32Error;
jobNode.Nodes.Add("Job GUID: " + Job.JobGUID); jobNode.Nodes.Add("Document: " + Job.Document); jobNode.Nodes.Add("AbortedBySystem: " + Job.AbortedBySystem.ToString()); jobNode.Nodes.Add("AbortedByUser: " + Job.AbortedByUser.ToString());
w32Error = new Win32Exception(Job.ConversionStatus); jobNode.Nodes.Add("Conversion Status: " + w32Error.Message + " (" + w32Error.NativeErrorCode.ToString() + ")");}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled Document FilesJobGUID JobID Pages PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
Document
Description
The name of the document printed that created this print job. This is the name theprinting application uses in the print queue. It can be different from the actual documentname.
Read-only.
Syntaxexpression.Document
where expression is an IPNJob object.
Returns a String.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
PNSrv10 COM Interface
300 PNSrv10 COM Interface Object ReferenceIPNJob
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Document: " + Job.Document)
Next
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Document: " + Job.Document);
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusFiles JobGUID JobID Pages PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
Files
Description
The IPNFiles collection of IPNFile objects for this job. There will be one IPNFile object forevery file created by this job. The collection is updated during the printing process.
Read-only.
Syntaxexpression.Files
where expression is an IPNJob object.
Returns an IPNFiles collection.
Examples
Visual Basic
Dim jobs As IPNJobsDim files As IPNFiles
301
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
jobs = Session.JobsFor Each JobObject As IPNJob In jobs files = JobObject.Files If (files.Count > 0) Then MsgBox("There are " + files.Count.ToString + " files in the collection") End IfNext
C#
IPNJobs jobs;IPNFiles files;
jobs = session.Jobs ;foreach (IPNJob jobObject in jobs){ files = jobObject.Files; if (files.Count > 0) { MessageBox.Show("There are " + files.Count.ToString + " files in the collection"); }}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument JobGUID JobID Pages PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
JobGUID
Description
A string based unique identifier for this object. This string can be used to query the IPNJobs collection.
Read-only.
Syntaxexpression.JobGUID
where expression is an IPNJob object.
Returns a String.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID)
PNSrv10 COM Interface
302 PNSrv10 COM Interface Object ReferenceIPNJob
jobNode.Nodes.Add("Document: " + Job.Document)
Next
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Document: " + Job.Document);
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobID Pages PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
JobID
Description
This is a non-unique numerical identifier used by the Windows printing sub-system.
Read-only.
Syntaxexpression.JobID
where expression is an IPNJob object.
Returns an Integer.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Job ID: " + Job.JobID.ToString())
303
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
Next
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Job ID: " + Job.JobID.ToString());
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID Pages PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
Pages
Description
The IPNPages collection of IPNPage objects for this job. There will be one IPNPage objectfor every document page printed by this job. The collection is updated during theprinting process.
Read-only.
Syntaxexpression.Pageswhere expression is a IPNJob object.
Returns an IPNPages collection.
Examples
Visual Basic
Dim jobs As IPNJobsDim pages As IPNPages
jobs = Session.JobsFor Each JobObject As IPNJob In jobs pages = JobObject.Pages If (pages.Count > 0) Then MsgBox("There are " + pages.Count.ToString + " pages in the job.") End IfNext
PNSrv10 COM Interface
304 PNSrv10 COM Interface Object ReferenceIPNJob
C#
IPNJobs jobs;IPNPages pages;
jobs = session.Jobs ;foreach (IPNJob jobObject in jobs){ pages = jobObject.Pages; if (pages.Count > 0) { MessageBox.Show("There are " + pages.Count.ToString + " pages in the job."); }}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID PagesPrinted PagesSpooled Session Status StatusMessageSubmittedTime UserName
PagesPrinted
Description
Returns the number of pages printed. This can be different from PagesSpooled, and isupdated while the file is being printed.
Read-only.
Syntaxexpression.PagesPrinted
where expression is an IPNJob object.
Returns an Integer.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Pages Printed: " + Job.PagesPrinted.ToString())
Next
C#
IPNJobs jobs;
305
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Pages Printed: " + Job.PagesPrinted.ToString());
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesSpooled Session Status StatusMessageSubmittedTime UserName
PagesSpooled
Description
Returns the number of pages spooled. This can be different from PagesPrinted, and isupdated while the file is being spooled to the printer by the printing application.
Read-only.
Syntaxexpression.PagesSpooled
where expression is an IPNJob object.
Returns an Integer.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Pages Spooled: " + Job.PagesSpooled.ToString())
Next
C#
IPNJobs jobs;
PNSrv10 COM Interface
306 PNSrv10 COM Interface Object ReferenceIPNJob
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Pages Spooled: " + Job.PagesSpooled.ToString());
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted Session Status StatusMessageSubmittedTime UserName
PrintSessionGUID
Description
A string based unique identifier for matching IPNPrintSession information to jobsprocessed by that print session. Every new print session is given a unique identifier, andevery print job processed by that print session is also assigned that unique identifier.
This identifier can be used to track information from the printing cycle to be used in theevent handlers. The IPNJob object sent to the event handler also contains a reference tothe PrintSessionGUID. An example of this would be to storing the source document namein a key-value mapped collection keyed by PrintSessionGUID to later be used on the OnEndJob event handler.
Read-only.
Syntaxexpression.Session
where expression is an IPNJob object.
Returns a String.
Examples
Visual Basic
Private Sub Session_OnEndJob(ByVal pJob As IPNJob) Handles Session.OnEndJob Dim sessionJobsCollection As IPNJobs
' Get the collection of jobs this job belongs to. sessionJobsCollection = pJob.Session.Jobs MsgBox("There are " + sessionJobsCollection.Count.ToString() + " jobs.")End Sub
C#
void m_session_OnEndJob(IPNJob pJob)
307
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
{ try { IPNJobs sessionJobsCollection; // Get the collection of jobs this job belongs to. sessionJobsCollection = pJob.Session.Jobs; MessageBox.Show("There are " + sessionJobsCollection.Count.ToString() + " jobs.") ; } catch (Exception getJobCollEx) { MessageBox.Show("Exception getting job collection from parent session. (" + getJobCollEx.Message + ")..."); }}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted PagesSpooled StatusStatusMessageSubmittedTime UserName
Session
Description
The parent IPNSession object that created this IPNJob object.
Read-only.
Syntaxexpression.Session
where expression is an IPNJob object.
Returns an IPNSession object.
Examples
Visual Basic
Private Sub Session_OnEndJob(ByVal pJob As IPNJob) Handles Session.OnEndJob Dim sessionJobsCollection As IPNJobs
' Get the collection of jobs this job belongs to. sessionJobsCollection = pJob.Session.Jobs MsgBox("There are " + sessionJobsCollection.Count.ToString() + " jobs.")End Sub
C#
void m_session_OnEndJob(IPNJob pJob){ try { IPNJobs sessionJobsCollection; // Get the collection of jobs this job belongs to. sessionJobsCollection = pJob.Session.Jobs; MessageBox.Show("There are " + sessionJobsCollection.Count.ToString() + " jobs.") ; } catch (Exception getJobCollEx) { MessageBox.Show("Exception getting job collection from parent session. (" +
PNSrv10 COM Interface
308 PNSrv10 COM Interface Object ReferenceIPNJob
getJobCollEx.Message + ")..."); }}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted PagesSpooled StatusStatusMessageSubmittedTime UserName
Status
Description
The current print status of the job as a numerical value. This value is updated during theprinting process. See the Remarks section for a list of the status values and what theymean.
Read-only.
Syntaxexpression.Status
where expression is an IPNJob object.
Returns an Integer.
Remarks
The status is reported as a Long and can be one or more of the values in the tablebelow.These are the same values used by the JOB_INFO_2 structure in Microsoft's Win32Printing and Print Spooler functions and structures. See the Microsoft documentation formore details.
The values are OR'd together to define the current status of the job. To determine whichvalues, the hexadecimal values must be examined:
If Status = 388, which is 0x00000184
JOB_STATUS_DELETED 0x00000100JOB_STATUS_PRINTED 0x00000080JOB_STATUS_DELETING 0x00000004------------------------------------ 0x00000184
Job Status Hexadecimal Value Integer Value
JOB_STATUS_PAUSED 0x00000001 1
JOB_STATUS_ERROR 0x00000002 2
JOB_STATUS_DELETING 0x00000004 4
JOB_STATUS_SPOOLING 0x00000008 8
JOB_STATUS_PRINTING 0x00000010 16
JOB_STATUS_OFFLINE 0x00000020 32
JOB_STATUS_PAPEROUT 0x00000040 64
JOB_STATUS_PRINTED 0x00000080 128
JOB_STATUS_DELETED 0x00000100 256
JOB_STATUS_BLOCKED_DEVQ 0x00000200 512
309
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
Job Status Hexadecimal Value Integer Value
JOB_STATUS_USER_INTERVENTION 0x00000400 1024
JOB_STATUS_RESTART 0x00000800 2048
JOB_STATUS_COMPLETE 0x00001000 4096
JOB_STATUS_RETAINED 0x00002000 8192
JOB_STATUS_RENDERING_LOCALLY 0x00004000 16384
Examples
Visual Basic
Dim jobNode, PagesNode, FilesNode, jobStatusNode As TreeNodeDim jobStatus As Integer
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID)
jobNode.Nodes.Add("Document: " + Job.Document)jobNode.Nodes.Add("Job ID:" + Job.JobID.ToString())jobStatusNode = jobNode.Nodes.Add("Job Status: " + Job.Status.ToString)jobStatus = CInt(Job.Status)
If ((jobStatus And 4) = 4) Then jobStatusNode.Nodes.Add("JOB_STATUS_DELETING")End IfIf ((jobStatus And 16) = 16) Then jobStatusNode.Nodes.Add("JOB_STATUS_PRINTING")End IfIf ((jobStatus And 128) = 128) Then jobStatusNode.Nodes.Add("JOB_STATUS_PRINTED")End IfIf ((jobStatus And 256) = 256) Then jobStatusNode.Nodes.Add("JOB_STATUS_DELETED")End If
C#
int jobStatus;TreeNode jobNode, PagesNode, FilesNode, JobStatusNode;
jobNode = this.m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID);
jobNode.Nodes.Add("Document: " + Job.Document);jobNode.Nodes.Add("Job ID:" + Job.JobID.ToString());
JobStatusNode = jobNode.Nodes.Add("Job Status: " + Job.Status.ToString());jobStatus = (int)Job.Status;if ((jobStatus & 4) == 4){ JobStatusNode.Nodes.Add("JOB_STATUS_DELETING");}if ((jobStatus & 16) == 16){ JobStatusNode.Nodes.Add("JOB_STATUS_PRINTING");}if ((jobStatus & 128) == 128){ JobStatusNode.Nodes.Add("JOB_STATUS_PRINTED");}if ((jobStatus & 256) == 256){ JobStatusNode.Nodes.Add("JOB_STATUS_DELETED");}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted PagesSpooled Session StatusMessage
PNSrv10 COM Interface
310 PNSrv10 COM Interface Object ReferenceIPNJob
SubmittedTime UserName
StatusMessage
Description
The current print status of the job as an string value. This value is updated during theprinting process, and can be an empty string.
Read-only.
Syntaxexpression.StatusMesage
where expression is an IPNJob object.
Returns a String.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Job Status: " + Job.StatusMessage)
Next
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Job Status: " + Job.StatusMessage);
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted PagesSpooled Session StatusSubmittedTime UserName
311
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
SubmittedTime
Description
Returns the time this document was spooled.
Read-only.
Syntaxexpression.SubmittedTime
where expression is an IPNJob object.
Returns a VT_DATE VARIANT.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("Submitted Time: " + Job.SubmittedTime.ToString())
Next
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("Submitted Time: " + Job.SubmittedTime.ToString());
}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted PagesSpooled Session StatusStatusMessage UserName
PNSrv10 COM Interface
312 PNSrv10 COM Interface Object ReferenceIPNJob
UserName
Description
Returns the name of the user who printed the document.
Read-only.
Syntaxexpression.UserName
where expression is an IPNJob object.
Returns a String.
Examples
Visual Basic
Dim sessionNode As TreeNodeDim jobs As IPNJobs
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each Job As IPNJob In jobs Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + Job.JobGUID) jobNode.Nodes.Add("User Name: " + Job.UserName)
Next
C#
IPNJobs jobs;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob Job in jobs){ TreeNode jobNode, PagesNode, FilesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + Job.JobGUID); jobNode.Nodes.Add("User Name: " + Job.UserName);}
See Also: AbortedBySystem AbortedByUser BytesPrinted BytesSpooled ConversionStatusDocument Files JobGUID JobID Pages PagesPrinted PagesSpooled Session StatusStatusMessage SubmittedTime
313
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
Job Properties Event Map
Using job variables to set properties
Job properties can be set or retrieved using the pnJobVariable values withSetVariableByKeyword and GetVariableByKeyword methods on an IPNJob object within theIPNSession events.
Use the following to set job properties; all values are passed as VT_BSTR.
Variable Name Value Events
pnJobVariableOutputDir A valid filename excluding path andextension
OnStartPageOnEndPageOnGetNextFileName
pnJobVariableOutputFileName A valid filename excluding path andextension.
OnStartPageOnEndPageOnGetNextFileName
pnJobVariableOutputFileFormat JPEGTIFF MultipagedTIFF SerializedAdobe PDF MultipagedAdobe PDF SerializedCompuServe GIFCompuServe PNGWindows BMPTARGAAdobe Photoshop 3.0ZSoft PCXZSoft DCX ** Not all formats listed are validfor all drivers
OnStartPageOnEndPage
pnJobVariableStartNewFile Starts a new file, pass an emptystring.
OnStartPageOnEndPageOnGetNextFileName
pnJobVariableAppend 0 = Create a new file1 = Append to existing file on disk
OnStartPageOnEndPageOnStartImageOnEndImage
pnJobVariableOverwrite 0 = Prompt before overwriting files1 = Overwrite existing files withoutprompting
OnStartPageOnEndPageOnStartImageOnEndImage
pnJobVariablePrompt 0 = Prompt only if document nameis invalid1 = Always prompt for filename
OnStartPageOnEndPageOnStartImageOnEndImage
pnJobVariableSkipPage Skips the current page, pass anempty string
OnStartPageOnEndPageOnStartImageOnEndImage
pnJobVariableSkipPageOn 0 = Stop skipping pages (resume)1 = Start skipping pages (exclude
OnStartPageOnEndPage
PNSrv10 COM Interface
314 PNSrv10 COM Interface Object ReferenceIPNJob
Variable Name Value Events
from output) OnStartImageOnEndImage
pnJobVariableUseJobID 0 = Do not include JobID infilename1 = Include JobID in filename
OnStartPageOnEndPageOnStartImageOnEndImage
pnJobVariableRemoveProductName
0 = Leave product name infilename 1 = Remove product name fromfilename
OnStartPageOnEndPageOnStartImageOnEndImage
pnJobVariableDeleteFiles 0 = Do not delete output files1 = Delete all output files
OnStartPageOnEndPageOnStartImageOnEndImage
pnJobVariableTempDir Full path to a directory to use asthe temporary folder
ReservedDo not use.
pnJobVariableFileNumber A positive integer between 0 and65535, used to start a serializednaming sequence.
ReservedDo not use.
pnJobVariablePrintRange Comma and dash delimited list ofpages and ranges to print (e.g. 3,6-9,12-15,25)
ReservedDo not use.
pnJobVariableCancelJob 1 = Cancels the job OnStartPageOnOpenFileOnStartImageOnEndImageOnCloseFileOnEndPage
pnJobVariableUser0-9 Custom user variables OnStartPageOnOpenFileOnStartImageOnEndImageOnCloseFileOnEndPage
Using string keywords to set properties
Job properties can be set or retrieved using keyword string values by using the SetVariableand GetVariable methods on an IPNJob object within the IPNSession events.
The following strings can be used to set job information. All job information is passed as aVT_BSTR.
Variable Name Value EventsOutputDir Full path to a directory OnStartPage
OnEndPageOnGetNextFileName
OutputFilename A valid filename excluding path and extension OnStartPageOnEndPageOnGetNextFileName
OutputFileFormat JPEG OnStartPage
315
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNJob
Variable Name Value EventsTIFF MultipagedTIFF SerializedAdobe PDF MultipagedAdobe PDF SerializedCompuServe GIFCompuServe PNGWindows BMPTARGAAdobe Photoshop 3.0ZSoft PCXZSoft DCX
OnEndPage
NewFile Starts a new file, pass an empty string. OnStartPageOnEndPageOnGetNextFileName
Append 0 = Create a new file1 = Append to existing file on disk
OnStartPageOnEndPageOnStartImageOnEndImage
Overwrite 0 = Prompt before overwriting files1 = Overwrite existing files without prompting
OnStartPageOnEndPageOnStartImageOnEndImage
Prompt 0 = Prompt only if document name is invalid1 = Always prompt for filename
OnStartPageOnEndPageOnStartImageOnEndImage
SkipPage Skips the current page, pass an empty string OnStartPageOnEndPageOnStartImageOnEndImage
SkipOn 0 = Stop skipping pages (resume)1 = Start skipping pages (exclude from output)
OnStartPageOnEndPageOnStartImageOnEndImage
UseJobID 0 = Do not include JobID in filename1 = Include JobID in filename
OnStartPageOnEndPageOnStartImageOnEndImage
RemoveProductName 0 = Leave product name in filename 1 = Remove product name from filename
OnStartPageOnEndPageOnStartImageOnEndImage
DeleteFiles 0 = Do not delete output files at end of job1 = Delete all output files at end of job
OnStartPageOnEndPageOnStartImageOnEndImage
TempDir Reserved. do not use.Full path to a directory to use as the temporary folder
ReservedDo not use.
FileNumber Reserved. do not use.A positive integer between 0 and 65535, used to start aserialized naming sequence
ReservedDo not use.
PrintRange Reserved. do not use.Comma and dash delimited list of pages and ranges toprint (e.g. 3,6-9,12-15,25)
ReservedDo not use.
PNSrv10 COM Interface
316 PNSrv10 COM Interface Object ReferenceIPNJob
Variable Name Value EventsCancelJob 1 = Cancels the job OnStartPage
OnOpenFileOnStartImageOnEndImageOnCloseFileOnEndPage
Var0-Var9 Custom user variables OnStartPageOnOpenFileOnStartImageOnEndImageOnCloseFileOnEndPage
317
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNFiles Collection
IPNFiles Collection
Description
A collection of IPNFile objects. Allows quick iteration through the collection using theforeach statement of the C# language and the for each statement in Visual Basic.
Public Methods
Item Returns an individual IPNFile item from the collection.The collection is indexed by position.
Public Properties
Count Returns an Integer that represents the number of IPNFile objects in the collection.
PNSrv10 COM Interface
318 PNSrv10 COM Interface Object ReferenceIPNFiles Collection
Methods
Item
Description
Returns an individual IPNFile item from the collection.
Syntaxexpression.Item(Index)
where expression is an IPNFiles collection
Returns an IPNFile item, or E_FAIL if the Index is out of range.
Parameters
Object IndexThe collection is indexed by integer position.
Examples
Visual Basic
Dim sessionNode, filesNode As TreeNodeDim jobs As IPNJobsDim files As IPNFiles
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each JobObject As IPNJob In jobs
Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + JobObject.JobGUID) jobNode.Nodes.Add("Document: " + JobObject.Document)
jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString())
....' add the files created to a child node under Job FilesNode = jobNode.Nodes.Add("Files")
' get the files collection for this job and add a node for each files = JobObject.Files For Each FileObject As IPNFile In files FilesNode.Nodes.Add("File: " + FileObject.Filename) Next FileObjectNext JobObject
C#
TreeNode m_TVSessionRoot;IPNJobs jobs;IPNFiles files;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
319
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNFiles Collection
// fill in job node in tree viewforeach (IPNJob JobObject in jobs){ TreeNode jobNode, filesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + JobObject.JobGUID); jobNode.Nodes.Add("Document: " + JobObject.Document); jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString());
....// add the files created to a child node under Job FilesNode = jobNode.Nodes.Add("Files");
// get the files collection for this job and add a node for each files = JobObject.Files foreach (FileObject As IPNFile In files) { FilesNode.Nodes.Add("File: " + FileObject.Filename); }}
See Also: Count IPNFile
PNSrv10 COM Interface
320 PNSrv10 COM Interface Object ReferenceIPNFiles Collection
Properties
Count
Description
Returns the number of IPNFile objects in the IPNFiles collection. Each time the printercreates a new file, a new IPNFile object is added to the collection. The printer settings forfile creation, such as multi-page or serialized output, and append mode will determinethe resulting number of IPNFile objects in the collection.
Read-only.
Syntaxexpression.Count
where expression is an IPNFiles collection
Returns an Integer.
Examples
Visual Basic
Dim jobs As IPNJobsDim files As IPNFiles
jobs = Session.JobsFor Each JobObject As IPNJob In jobs files = JobObject.Files If (files.Count > 0) Then MsgBox("There are " + files.Count.ToString + " files in the collection") End IfNext
C#
IPNJobs jobs;IPNFiles files;
jobs = session.Jobs ;foreach (IPNJob jobObject in jobs){ files = jobObject.Files; if (files.Count > 0) { MessageBox.Show("There are " + files.Count.ToString + " files in the collection"); }}
See Also: Item IPNFile
321
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNFile
IPNFile
Description
An IPNFile object is created for every file created by the printer. The file objectrepresents the physical file on disk and provides access to the full output filename andtwo collections: an IPNPages collection of the printed pages used to create the file andan IPNImages collection of the images that make up each page of the file.
Public Properties
Filename Read-only; The filename of the file created by theprinter.
Images Read-only; IPNImages collection of IPNImage objectsin this file. This value is updated during the printingprocess.
Job Read-only; The parent IPNJob object that created thisIPNFile object.
Pages Read-only; IPNPages collection of IPNPage objects inthis file. This value is updated during the printingprocess.
Session Read-only; The parent IPNSession object that createdthis IPNFile object.
PNSrv10 COM Interface
322 PNSrv10 COM Interface Object ReferenceIPNFile
Properties
Filename
Description
The name of the file created. This is the fully qualified path, including directory andfilename.
Read-only.
Syntaxexpression.Filename
where expression is an IPNFile object
Returns a String.
Examples
Visual Basic
Dim fileNode As TreeNode
For Each File As IPNFile In files
fileNode = FilesRootNote.Add("File: " + File.Filename) fileNode.Nodes.Add("Created by Job: " + File.Job.JobGUID)
Next
C#
TreeNode fileNode;
foreach (IPNFile File in files){ // Add file node fileNode = FilesRootNode.Nodes.Add("File: " + File.Filename); fileNode.Nodes.Add("Created by Job: " + File.Job.JobGUID);}
See Also: Images Job Pages Session
Images
Description
The IPNImages collection of IPNImage objects for this file. There will be one IPNImageobject for every printed page. The collection is updated during the printing process.
Read-only.
Syntaxexpression.Images
323
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNFile
where expression is an IPNFile object
Returns an IPNImages collection.
Examples
Visual Basic
Dim files As IPNFilesDim images As IPNImages
files = job.FilesFor Each FileObject As IPNFile In files images = FileObject.Images If (images.Count > 0) Then MsgBox("There are " + images.Count.ToString + " images in the file.") End IfNext
C#
IPNFiles files;IPNImages images;
files = jobs.Files;foreach (IPNFile fileObject in files){ images = fileObject.Images; if (images.Count > 0) { MessageBox.Show("There are " + images.Count.ToString + " images in the file."); }}
See Also: Filename Job Pages Session
Job
Description
The parent IPNJob object that created this IPNFile object.
Read-only.
Syntaxexpression.Job
where expression is an IPNFile object
Returns an IPNJob object.
Examples
Visual Basic
Dim fileNode As TreeNode
For Each File As IPNFile In files
PNSrv10 COM Interface
324 PNSrv10 COM Interface Object ReferenceIPNFile
fileNode = FilesRootNote.Add("File: " + File.Filename) fileNode.Nodes.Add("Created by Job: " + File.Job.JobGUID)
Next
C#
TreeNode fileNode;
foreach (IPNFile File in files){ // Add file node fileNode = FilesRootNode.Nodes.Add("File: " + File.Filename); fileNode.Nodes.Add("Created by Job: " + File.Job.JobGUID);}
See Also: Filename Images Pages Session
Pages
Description
The IPNPages collection of IPNPage objects for this file. There will be one IPNPage objectfor every printed page that was put in this file. The collection is updated during theprinting process.
Read-only.
Syntaxexpression.Pages
where expression is an IPNFile object
Returns an IPNPages collection.
Examples
Visual Basic
Dim files As IPNFilesDim pages As IPNPages
files = job.FilesFor Each FileObject As IPNFile In files pages = FileObject.Pages If (pages.Count > 0) Then MsgBox("There are " + pages.Count.ToString + " pages in the file.") End IfNext
C#
IPNFiles files;IPNPages pages;
files = jobs.Files;
325
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNFile
foreach (IPNFile fileObject in files){ pages = fileObject.Files; if (pages.Count > 0) { MessageBox.Show("There are " + pages.Count.ToString + " pages in the file."); }}
See Also: Filename Images Job Session
Session
Description
The parent IPNSession object that created this IPNFile object.
Read-only.
Syntaxexpression.Session
where expression is an IPNFile object
Returns an IPNSession object.
Examples
Visual Basic
Private Sub Session_OnCloseFile(ByVal pFile As IPNFile) Handles Session.OnCloseFile Dim parentSession As IPNSession Dim sessionJobsCollection As IPNJobs
parentSession = pFile.Session ' Get the collection of jobs this file belongs to. sessionJobsCollection = parentSession.Jobs MsgBox("There are " + sessionJobsCollection.Count.ToString() + " jobs.")End Sub
C#
void m_session_OnCloseFile(IPNFile pFile){ try { IPNSession parentSession; IPNJobs sessionJobsCollection;
parentSession = pFile.Session; // Get the collection of jobs this job belongs to. sessionJobsCollection = parentSession.Jobs; MessageBox.Show("There are " + sessionJobsCollection.Count.ToString() + " jobs.") ; } catch (Exception getJobCollEx) { MessageBox.Show("Exception getting job collection from parent session. (" + getJobCollEx.Message + ")..."); }}
PNSrv10 COM Interface
326 PNSrv10 COM Interface Object ReferenceIPNFile
See Also: Filename Images Job Pages
327
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPages Collection
IPNPages Collection
Description
A collection of IPNPage objects. Allows quick iteration through the collection using theforeach statement of the C# language and the for each statement in Visual Basic.
Public Methods
Item Returns an individual IPNPage item from thecollection. The collection is indexed by position.
Public Properties
Count Returns an Integer that represents the number of IPNPage objects in the collection.
PNSrv10 COM Interface
328 PNSrv10 COM Interface Object ReferenceIPNPages Collection
Methods
Item
Description
Returns an individual IPNPage item from the collection.
Syntaxexpression.Item(Index)
where expression is an IPNPages collection
Returns an IPNPage item, or E_FAIL if the Index is out of range.
Parameters
Object IndexThe collection is indexed by integer position.
Examples
Visual Basic
Dim sessionNode, filesNode, pagesNode As TreeNodeDim jobs As IPNJobsDim files As IPNFilesDim pages As IPNPages
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each JobObject As IPNJob In jobs
Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + JobObject.JobGUID) jobNode.Nodes.Add("Document: " + JobObject.Document) jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString())
' add the files created to a child node under Job filesNode = jobNode.Nodes.Add("Files")
' get the files collection for this job and add a node for each files = JobObject.Files For Each FileObject As IPNFile In files
filesNode.Nodes.Add("File: " + FileObject.Filename)
' add the pages in this file to a child node under Files pagesNode = filesNode.Nodes.Add("Pages")
' get the pages collection for this file and add a node for each pages = FileObject.Pages For Each PageObject As IPNPage In pages pagesNode.Nodes.Add("Page: " + PageObject.PageNumber.ToString()) Next PageObject Next FileObjectNext JobObject
329
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPages Collection
C#
TreeNode m_TVSessionRoot;IPNJobs jobs;IPNFiles files;IPNPages pages;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob JobObject in jobs){ TreeNode jobNode, filesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + JobObject.JobGUID); jobNode.Nodes.Add("Document: " + JobObject.Document); jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString());
....// add the files created to a child node under Job FilesNode = jobNode.Nodes.Add("Files");
// get the files collection for this job and add a node for each files = JobObject.Files; foreach (FileObject As IPNFile In files) { TreeNode PagesNode;
FilesNode.Nodes.Add("File: " + FileObject.Filename);
// add the pages created to a child node under File PagesNode = FilesNode.Nodes.Add("Pages");
// get the pages collection for this file and add a node for each pages = FileObject.Pages foreach(PageObject As IPNPage In pages) { PagesNode.Nodes.Add("Page: " + PageObject.PageNumber.ToString()); } // pages } // files} // jobs
See Also: Count IPNPage
PNSrv10 COM Interface
330 PNSrv10 COM Interface Object ReferenceIPNPages Collection
Properties
Count
Description
Returns the number of IPNPage objects in the IPNPages collection. Each IPFile cancontain one or more pages.
Read-only.
Syntaxexpression.Count
where expression is an IPNPages collection
Returns an Integer.
Examples
Visual Basic
Dim jobs As IPNJobsDim files As IPNFilesDim pages As IPNPages
jobs = Session.JobsFor Each JobObject As IPNJob In jobs files = JobObject.Files For Each FileObject As IPNFile In files pages = FileObject.Pages If (pages.Count > 0) Then MsgBox("There are " + pages.Count.ToString() + " pages in " + File.Filename) End If NextNext
C#
IPNJobs jobs;IPNFiles files;IPNPages pages;
jobs = session.Jobs;foreach (IPNJob jobObject in jobs){ files = jobObject.Files; foreach (IPNFile fileObject in files) { pages = fileObject.Pages; if (pages.Count > 0) { MessageBox.Show("There are " + pages.Count.ToString() + " pages in " + File.Filename); } }}
See Also
Item IPNPage
331
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPage
IPNPage
Description
An IPNPage object is created for every page of the printed document or file. The pageobject represents the print settings of the page when spooled to the printer (as set by SetDevmodeSettings). These settings are different from the IPNImage settings, whichare the settings of the output file created. For instance, when printing a single pagedocument in color and creating a fax resolution TIFF image will give an IPNPage objectwith a BitsPerPixel = 24, and an IPNImage object with BitsPerPixel = 1.
The page object also provides access to two collections: an IPNFiles collection of filesthat contain this page as an IPNImage, currently only a collection of one, and anIPNImages collection of the images that were created from this page, also currently onlya collection of one.
Public Properties
BitsPerPixel Read-only; The bits per pixel, or color depth of theprinted page.
Files Read-only; IPNFiles collection of IPNFile objectscreated by this page. Currently each page belongs toa single file.This value is updated during the printingprocess.
HeightInPixels Read-only; The height of the printed page in pixels.
Images Read-only; IPNImages collection of IPNImage objectsin this page. Currently each page creates a singleimage.This value is updated during the printingprocess.
Job Read-only; The parent IPNJob object that created thisIPNFile object.
Orientation Read-only; The orientation of the printed page, either Portrait or Landscape.
PageNumber Read-only; The page number of the printed page.
Session Read-only; The parent IPNSession object that createdthis IPNPage object.
Skipped Read-only; Boolean value True if the page wasskipped, meaning it was not printed.
WidthInPixels Read-only; The weight of the printed page in pixels.
XPixelsPerInch Read-only; The vertical dots per inch, or resolution, ofthe printed page.
PNSrv10 COM Interface
332 PNSrv10 COM Interface Object ReferenceIPNPage
YPixelsPerInch Read-only; The horizontal dots per inch, or resolution,of the printed page.
333
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPage
Properties
BitsPerPixel
Description
This is the color depth, or bit depth of the printed page. This can be different from the BitsPerPixel values in any IPNImage objects in the Images collection. It is commonly 1for black and white, or monochrome printing, and 24 when printing in color.
Read-only.
Syntaxexpression.BitsPerPixel
where expression is an IPNPage object
Returns an Integer.
Examples
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages
' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString) pageNode.Nodes.Add("Bits Depth: " + Page.BitsPerPixel.ToString)Next
C#
foreach (IPNPage Page in pages){....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());....pageNode.Nodes.Add("Bits Depth: " + Page.BitsPerPixel.ToString());}
See Also: Files HeightInPixels Images Job Orientation PageNumber Session SkippedWidthInPixels XPixelsPerInch YPixelsPerInch
Files
Description
The IPNFiles collection of IPNFile objects for this page. There will be one IPNFile objectfor every page.
Read-only.
Syntaxexpression.Files
PNSrv10 COM Interface
334 PNSrv10 COM Interface Object ReferenceIPNPage
where expression is an IPNPage object
Returns an IPNFiles collection.
Examples
Visual Basic
For Each pageObject As IPNPage In pages files = pageObject.Files If (files.Count > 0) Then MsgBox("This page is in " + files.Count.ToString + " file(s).") End IfNext
C#
foreach (IPNPage Page in pages){ files = Page.Files if (files.Count > 0) { MessageBox.Show("The page is in " + files.Count.ToString + " file(s)."); }}
See Also: BitsPerPixel HeightInPixels Images Job Orientation PageNumber Session Skipped WidthInPixels XPixelsPerInch YPixelsPerInch
HeightInPixels
Description
This is the height of the printed page in pixels.
Read-only.
Syntaxexpression.HeightInPixels
where expression is an IPNPage object
Returns an Integer.
Examples
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages
' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString) pageNode.Nodes.Add("Height in Pixels: " + Page.HeightInPixels.ToString) pageNode.Nodes.Add("Width in Pixels: " + Page.WidthInPixels.ToString)Next
335
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPage
C#
foreach (IPNPage Page in pages){....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());....pageNode.Nodes.Add("Height in Pixels: " + Page.HeightInPixels.ToString());....pageNode.Nodes.Add("Width in Pixels: " + Page.WidthInPixels.ToString());}
See Also: BitsPerPixel Files Images Job Orientation PageNumber Session SkippedWidthInPixels XPixelsPerInch YPixelsPerInch
Images
Description
The IPNImages collection of IPNImage objects for this page. There will be one IPNImageobject for every printed page. The collection is updated during the printing process.
Read-only.
Syntaxexpression.Images
where expression is an IPNPage object
Returns an IPNImages collection.
Examples
Visual Basic
Dim pages As IPNPagesDim images As IPNImages
pages = job.PagesFor Each PageObject As IPNPage In pages images = PageObject.Images If (images.Count > 0) Then MsgBox("There are " + images.Count.ToString + " images for this page.") End IfNext
C#
IPNPages pages;IPNImages images;
pages = jobs.Pages;foreach (IPNPage PageObject in pages){ images = PageObject.Images; if (images.Count > 0) { MessageBox.Show("There are " + images.Count.ToString + " images for this page."); }}
PNSrv10 COM Interface
336 PNSrv10 COM Interface Object ReferenceIPNPage
See Also: BitsPerPixel Files HeightInPixels Job Orientation PageNumber Session SkippedWidthInPixels XPixelsPerInch YPixelsPerInch
Job
Description
The parent IPNJob object that created this IPNPage object.
Read-only.
Syntaxexpression.Job
where expression is an IPNPage object
Returns an IPNJob object.
Examples
Visual Basic
Dim pageNode As TreeNode
For Each Page As IPNPage In pages
pageNode = FilesRootNote.Add("Page: " + Page.PageNumber.ToString()) pageNode.Nodes.Add("Created by Job: " + Page.Job.JobGUID)
Next
C#
TreeNode pageNode;
foreach (IPNPage Page in pages){ // Add file node pageNode = FilesRootNode.Nodes.Add("Page: " + Page.PageNumber.ToString()); pageNode.Nodes.Add("Created by Job: " + Page.Job.JobGUID);}
See Also: BitsPerPixel Files HeightInPixels Images Orientation PageNumber SessionSkipped WidthInPixels XPixelsPerInch YPixelsPerInch
Orientation
Description
This is the orientation, either Portrait or Landscape, of the printed page.
Read-only.
Syntax
337
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPage
expression.Orientation
where expression is an IPNPage object
Returns an Integer where Portrait = 0 and Landscape = 1.
Examples
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages
' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString) If Page.Orientation = 0 Then pageNode.Nodes.Add("Orientation: Portrait") Else pageNode.Nodes.Add("Orientation: Landscape") End IfNext
C#
foreach (IPNPage Page in pages){....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());....if (Page.Orientation == 0)....{........pageNode.Nodes.Add("Orientation: Portrait");....}....else....{........pageNode.Nodes.Add("Orientation: Landscape");....}}
See Also: BitsPerPixel Files HeightInPixels Images Job PageNumber Session SkippedWidthInPixels XPixelsPerInch YPixelsPerInch
PageNumber
Description
This is the page number of the printed page. When appending, this can be different fromthe page number of the image in the resulting file.
Read-only.
Syntaxexpression.PageNumber
where expression is an IPNPage object
Returns an Integer.
Examples
PNSrv10 COM Interface
338 PNSrv10 COM Interface Object ReferenceIPNPage
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages ' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString)Next
C#
foreach (IPNPage Page in pages){....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());}
See Also: BitsPerPixel Files HeightInPixels Images Job Orientation Session SkippedWidthInPixels XPixelsPerInch YPixelsPerInch
Session
Description
The parent IPNSession object that created this IPNPage object.
Read-only.
Syntaxexpression.Session
where expression is an IPNPage object
Returns an IPNSession object.
Examples
Visual Basic
Private Sub Session_OnEndPage(ByVal pPage As IPNPage) Handles Session.OnEndPage Dim sessionJobsCollection As IPNJobs
' Get the collection of jobs this page belongs to. sessionJobsCollection = pPage.Session.Jobs MsgBox("There are " + sessionJobsCollection.Count.ToString() + " jobs.")End Sub
C#
void m_session_OnEndPage(IPNPage pPage){ try { IPNJobs sessionJobsCollection; // Get the collection of jobs this job belongs to. sessionJobsCollection = pPage.Session.Jobs; MessageBox.Show("There are " + sessionJobsCollection.Count.ToString() + " jobs.") ;
339
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPage
} catch (Exception getJobCollEx) { MessageBox.Show("Exception getting job collection from parent session. (" + getJobCollEx.Message + ")..."); }}
See Also: BitsPerPixel Files HeightInPixels Images Job Orientation PageNumber SkippedWidthInPixels XPixelsPerInch YPixelsPerInch
Skipped
Description
This Boolean property is True if the page was skipped.
Read-only.
Syntaxexpression.Skipped
where expression is an IPNPage object
Returns a Boolean.
Examples
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages
' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString) pageNode.Nodes.Add("Skipped: " + Page.Skipped.ToString)Next
C#
foreach (IPNPage Page in pages){....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());....pageNode.Nodes.Add("Skipped: " + Page.Skipped.ToString());}
See Also: BitsPerPixel Files HeightInPixels Images Job Orientation PageNumber SessionWidthInPixels XPixelsPerInch YPixelsPerInch
WidthInPixels
Description
PNSrv10 COM Interface
340 PNSrv10 COM Interface Object ReferenceIPNPage
This is the width of the printed page in pixels.
Read-only.
Syntaxexpression.HeightInPixel
where expression is an IPNPage object
Returns an Integer.
Examples
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages
' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString) pageNode.Nodes.Add("Height in Pixels: " + Page.HeightInPixels.ToString) pageNode.Nodes.Add("Width in Pixels: " + Page.WidthInPixels.ToString)Next
C#
foreach (IPNPage Page in pages){....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());....pageNode.Nodes.Add("Height in Pixels: " + Page.HeightInPixels.ToString());....pageNode.Nodes.Add("Width in Pixels: " + Page.WidthInPixels.ToString());}
See Also: BitsPerPixel Files HeightInPixels Images Job Orientation PageNumber SessionSkipped XPixelsPerInch YPixelsPerInch
XPixelsPerInch
Description
This is the vertical dots per inch (DPI), or resolution, of the printed page.
Read-only.
Syntaxexpression.XPixelsPerInch
where expression is an IPNPage object
Returns an Integer.
Examples
341
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNPage
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages
' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString) pageNode.Nodes.Add("X DPI: " + Page.XPixelsPerInch.ToString) pageNode.Nodes.Add("Y DPI: " + Page.YPixelsPerInch.ToString)Next
C#
foreach (IPNPage Page in pages){....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());....pageNode.Nodes.Add("X DPI: " + Page.XPixelsPerInch.ToString());....pageNode.Nodes.Add("Y DPI: " + Page.YPixelsPerInch.ToString());}
See Also: BitsPerPixel Files HeightInPixels Images Job Orientation PageNumber SessionSkipped WidthInPixels YPixelsPerInch
YPixelsPerInch
Description
This is the horizontal dots per inch, or resolution, of the printed page.
Read-only.
Syntaxexpression.YPixelsPerInch
where expression is an IPNPage object
Returns an Integer.
Examples
Visual Basic
Dim pageNode, ImagesNode As TreeNode
For Each Page As IPNPage In pages
' Add page node pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString) pageNode.Nodes.Add("X DPI: " + Page.XPixelsPerInch.ToString) pageNode.Nodes.Add("Y DPI: " + Page.YPixelsPerInch.ToString)Next
C#
foreach (IPNPage Page in pages)
PNSrv10 COM Interface
342 PNSrv10 COM Interface Object ReferenceIPNPage
{....// Add page node....pageNode = PagesRootNode.Nodes.Add("Page " + Page.PageNumber.ToString());....pageNode.Nodes.Add("X DPI: " + Page.XPixelsPerInch.ToString());....pageNode.Nodes.Add("Y DPI: " + Page.YPixelsPerInch.ToString());}
See Also: BitsPerPixel Files HeightInPixels Images Job Orientation PageNumber SessionSkipped WidthInPixels XPixelsPerInch
343
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImages Collection
IPNImages Collection
Description
A collection of IPNImage objects. Allows quick iteration through the collection using theforeach statement of the C# language and the for each statement in Visual Basic.
Public Methods
Item Returns an individual IPNImage item from thecollection. The collection is indexed by position.
Public Properties
Count Returns an Integer that represents the number of IPNImage objects in the collection.
PNSrv10 COM Interface
344 PNSrv10 COM Interface Object ReferenceIPNImages Collection
Methods
Item
Description
Returns an individual IPNImage item from the collection.
Syntaxexpression.Item(Index)
where expression is an IPNImages collection
Returns an IPNImage item, or E_FAIL if the Index is out of range.
Parameters
Object IndexThe collection is indexed by integer position.
Examples
Visual Basic
Dim sessionNode, filesNode, pagesNode, imagesNode As TreeNodeDim jobs As IPNJobsDim files As IPNFilesDim pages As IPNPagesDim images As IPNImages
jobs = Session.Jobs
tvSession.Nodes.Clear()sessionNode = tvSession.Nodes.Add("Session")
' fill in job node in tree viewFor Each JobObject As IPNJob In jobs
Dim jobNode As TreeNode
jobNode = sessionNode.Nodes.Add("Job " + JobObject.JobGUID) jobNode.Nodes.Add("Document: " + JobObject.Document) jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString())
' add the files created to a child node under Job filesNode = jobNode.Nodes.Add("Files")
' get the files collection for this job and add a node for each files = JobObject.Files For Each FileObject As IPNFile In files
filesNode.Nodes.Add("File: " + FileObject.Filename)
' add the pages in this file to a child node under Files pagesNode = filesNode.Nodes.Add("Pages")
' get the pages collection for this file and add a node for each pages = FileObject.Pages For Each PageObject As IPNPage In pages
pagesNode.Nodes.Add("Page: " + PageObject.PageNumber.ToString())
' add the images in this file to a child node under pages imagesNode = pagesNode.Nodes.Add("Images")
345
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImages Collection
' get the images collection for this page images = PageObject.Images For Each ImageObject As IPNImage In images imagesNode.Nodes.Add("Image for page " + _ ImageObject.PageNumber.ToString() + _ " is in file " + ImageObject.File.Filename) Next ImageObject Next PageObject Next FileObjectNext JobObject
C#
TreeNode m_TVSessionRoot;IPNJobs jobs;IPNFiles files;IPNPages pages;IPNImages images;
jobs = session.Jobs ;
tvTrackInfo.Nodes.Clear();m_TVSessionRoot = tvTrackInfo.Nodes.Add("Session");
// fill in job node in tree viewforeach (IPNJob JobObject in jobs){ TreeNode jobNode, filesNode;
jobNode = m_TVSessionRoot.Nodes.Add("Job " + JobObject.JobGUID); jobNode.Nodes.Add("Document: " + JobObject.Document); jobNode.Nodes.Add("Job ID:" + JobObject.JobID.ToString());
// add the files created to a child node under Job FilesNode = jobNode.Nodes.Add("Files");
// get the files collection for this job and add a node for each files = JobObject.Files foreach (FileObject As IPNFile In files) { TreeNode PagesNode;
FilesNode.Nodes.Add("File: " + FileObject.Filename);
// add the pages created to a child node under File PagesNode = FilesNode.Nodes.Add("Pages");
// get the pages collection for this job and add a node for each pages = FileObject.Pages; foreach(PageObject As IPNPage In pages) { TreeNode ImagesNode; PagesNode.Nodes.Add("Page: " + PageObject.PageNumber.ToString());
// add the pages created to a child node under File ImagesNode = PagesNode.Nodes.Add("Images");
// get the pages collection for this job and add a node for each pages = PageObject.Pages; foreach(ImageObject As IPNImage In images) { ImagesNode.Nodes.Add("Image for page " + ImageObject.PageNumber.ToString() + " is in file " + ImageObject.File.Filename); } // images } // pages } // files} // jobs
PNSrv10 COM Interface
346 PNSrv10 COM Interface Object ReferenceIPNImages Collection
See Also: Count IPNImage
347
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImages Collection
Properties
Count
Description
Returns the number of IPNImage objects in the IPNImages collection.
Read-only.
Syntaxexpression.Count
where expression is an IPNImages collection
Returns an Integer.
Examples
Visual Basic
Dim jobs As IPNJobsDim files As IPNFilesDim pages As IPNPagesDim images As IPNImages
jobs = Session.JobsFor Each JobObject As IPNJob In jobs files = JobObject.Files For Each FileObject As IPNFile In files pages = FileObject.Pages For Each PageObject As IPNPage In pages image = PageObject.Images If (images.Count > 0) Then MsgBox("There are " + images.Count.ToString() + " images.") End If Next ' pages Next ' filesNext ' jobs
C#
IPNJobs jobs;IPNFiles files;IPNPages pages;IPNImages images;
jobs = session.Jobs ;foreach (IPNJob jobObject in jobs){ files = jobObject.Files; foreach (IPNFile fileObject in files) { pages = fileObject.Pages; foreach(IPNPage pageObject in pages) { images = pageObject.Images; if (images.Count > 0) { MessageBox.Show("There are " + images.Count.ToString() + " images "); } } // pages } // files} // jobs
PNSrv10 COM Interface
348 PNSrv10 COM Interface Object ReferenceIPNImages Collection
See Also: Item IPNImage
349
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImage
IPNImage
Description
An image object represents a single page in the output physical file on disk.
The image object also provides access to two collections: an IPNFiles collection of filesthat contain this image, currently only a collection of one, and an IPNPages collection ofthe pages that were used to create this image, also currently only a collection of one.
Public Properties
BitsPerPixel Read-only; The bits per pixel, or color depth of theoutput image.
Files Read-only; IPNFiles collection of IPNFile that referencethis image. Currently each image belongs to a singlefile.This value is updated during the printing process.
HeightInPixels Read-only; The height of the output image in pixels.
Job Read-only; The parent IPNJob object that created thisIPNFile object.
Orientation Read-only; The orientation of the output image,either Portrait or Landscape.
PageNumber Read-only; The page number of the image in theoutput file.
Pages Read-only; IPNPages collection of IPNPage objects inthe output file. This value is updated during theprinting process.
RotationInDegress Read-only; The rotation of the image in the outputfile.
Session Read-only; The parent IPNSession object that createdthis IPNImage object.
WidthInPixels Read-only; The weight of the image in pixels.
XPixelsPerInch Read-only; The vertical dots per inch, or resolution, ofthe output image.
YPixelsPerInch Read-only; The horizontal dots per inch, or resolution,of the output image.
PNSrv10 COM Interface
350 PNSrv10 COM Interface Object ReferenceIPNImage
Properties
BitsPerPixel
Description
This is the color depth, or bit depth of the output image. This can be different from the BitsPerPixel values in any IPNPage objects in the Pages collection. This value depends inthe settings of the printer. For instance, 1 for fax mode TIFF creation. and 24 whencreating a full color TIFF image.
Read-only.
Syntaxexpression.BitsPerPixel
where expression is an IPNImage object
Returns an Integer.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) imageNode.Nodes.Add("BitsPerPixel: " + Image.BitsPerPixel.ToString) If Image.Orientation = 0 Then imageNode.Nodes.Add("Orientation: Portrait") Else imageNode.Nodes.Add("Orientation: Landscape") End If imageNode.Nodes.Add("Rotation: " + Image.RotationInDegrees.ToString() + " degrees") imageNode.Nodes.Add("Height in Pixels: " + Image.HeightInPixels.ToString) imageNode.Nodes.Add("Width in Pixels: " + Image.WidthInPixels.ToString) imageNode.Nodes.Add("X DPI: " + Image.XPixelsPerInch.ToString) imageNode.Nodes.Add("Y DPI: " + Image.YPixelsPerInch.ToString)
pagesNode = imageNode.Nodes.Add("Pages") AddPagesToTreeNode(pagesNode, Image.Pages, False)Next
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); imageNode.Nodes.Add("BitsPerPixel: " + Image.BitsPerPixel.ToString()); if (Image.Orientation == 0) { imageNode.Nodes.Add("Orientation: Portrait"); } else { imageNode.Nodes.Add("Orientation: Landscape"); } imageNode.Nodes.Add("Rotation: " +
351
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImage
Image.RotationInDegrees.ToString() + " degrees"); imageNode.Nodes.Add("Height in Pixels: " + Image.HeightInPixels.ToString()); imageNode.Nodes.Add("Width in Pixels: " + Image.WidthInPixels.ToString()); imageNode.Nodes.Add("X DPI: " + Image.XPixelsPerInch.ToString()); imageNode.Nodes.Add("Y DPI: " + Image.YPixelsPerInch.ToString());
pagesNode = imageNode.Nodes.Add("Pages"); this.AddPagesToTreeNode(pagesNode, Image.Pages, false);}
See Also: Files HeightInPixels Job Orientation PageNumber Pages RotationInDegreesSession WidthInPixels XPixelsPerInch YPixelsPerInch
Files
Description
The IPNFiles collection of IPNFile objects for this image. There will be one IPNFile objectfor every image.
Read-only.
Syntaxexpression.Files
where expression is an IPNImage object
Returns an IPNFiles collection.
Examples
Visual Basic
For Each imageObject As IPNImage In images files = imageObject.Files For Each fileObject As INPFile in files MsgBox("This image is in this file:" + fileObject.FileName + " ") Next fileObjectNext
C#
foreach (IPNImage Image in images){ files = Image.Files foreach (IPNFile File in files) { MessageBox.Show("This image is in this file:" + File.FileName + " "); }}
See Also: BitsPerPixel HeightInPixels Job Orientation PageNumber PagesRotationInDegrees Session WidthInPixels XPixelsPerInch YPixelsPerInch
PNSrv10 COM Interface
352 PNSrv10 COM Interface Object ReferenceIPNImage
HeightInPixels
Description
This is the height of the output image in pixels.
Read-only.
Syntaxexpression.HeightInPixels
where expression is an IPNImage object
Returns an Integer.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) imageNode.Nodes.Add("Height in Pixels: " + Image.HeightInPixels.ToString) imageNode.Nodes.Add("Width in Pixels: " + Image.WidthInPixels.ToString)Next
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); imageNode.Nodes.Add("Height in Pixels: " + Image.HeightInPixels.ToString()); imageNode.Nodes.Add("Width in Pixels: " + Image.WidthInPixels.ToString());}
See Also: BitsPerPixel Files Job Orientation PageNumber Pages RotationInDegrees SessionWidthInPixels XPixelsPerInch YPixelsPerInch
Job
Description
The parent IPNJob object that created this IPNImage object.
Read-only.
Syntaxexpression.Job
where expression is an IPNImage object
Returns an IPNJob object.
353
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImage
Examples
Visual Basic
Dim imageNode As TreeNode
For Each Image As IPNImage In images
imageNode = FilesRootNote.Add("Image: " + Image.PageNumber.ToString()) imageNode.Nodes.Add("Created by Job: " + Image.Job.JobGUID)
Next
C#
TreeNode imageNode;
foreach (IPNImage Image in image){ // Add file node imageNode = FilesRootNode.Nodes.Add("Image: " + Image.PageNumber.ToString()); imageNode.Nodes.Add("Created by Job: " + Image.Job.JobGUID);}
See Also: BitsPerPixel Files HeightInPixels Orientation PageNumber PagesRotationInDegrees Session WidthInPixels XPixelsPerInch YPixelsPerInch
Orientation
Description
This is the orientation, either Portrait or Landscape, of the output image.
Read-only.
Syntaxexpression.Orientation
where expression is an IPNImage object
Returns an Integer where Portrait = 0 and Landscape = 1.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) If Image.Orientation = 0 Then imageNode.Nodes.Add("Orientation: Portrait") Else imageNode.Nodes.Add("Orientation: Landscape") End IfNext
PNSrv10 COM Interface
354 PNSrv10 COM Interface Object ReferenceIPNImage
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); if (Image.Orientation == 0) { imageNode.Nodes.Add("Orientation: Portrait"); } else { imageNode.Nodes.Add("Orientation: Landscape"); }}
See Also: BitsPerPixel Files HeightInPixels Job PageNumber Pages RotationInDegreesSession WidthInPixels XPixelsPerInch YPixelsPerInch
PageNumber
Description
This is the page number of the image in the output file. When appending or creatingserialized output, this can be different from the page number of the orginal printed page.
Read-only.
Syntaxexpression.PageNumber
where expression is an IPNImage object
Returns an Integer.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename)Next
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename);}
See Also: BitsPerPixel Files HeightInPixels Job Orientation Pages RotationInDegrees
355
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImage
Session WidthInPixels XPixelsPerInch YPixelsPerInch
Pages
Description
The IPNPages collection of IPNPage objects used to create this output image. Thecollection is updated during the printing process.
Read-only.
Syntaxexpression.Pages
where expression is an IPNImage object
Returns an IPNPages collection.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) pagesNode = imageNode.Nodes.Add("Pages") AddPagesToTreeNode(pagesNode, Image.Pages, False)Next
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); pagesNode = imageNode.Nodes.Add("Pages"); AddPagesToTreeNode(pagesNode, Image.Pages, false);}
See Also: BitsPerPixel Files HeightInPixels Job Orientation PageNumber RotationInDegreesSession WidthInPixels XPixelsPerInch YPixelsPerInch
RotationInDegrees
Description
This is the rotation, one of 0°, 90°, 180°, 270°, of the output image. The output imagesare always rotated counter-clockwise.
Read-only.
PNSrv10 COM Interface
356 PNSrv10 COM Interface Object ReferenceIPNImage
Syntaxexpression.BitsPerPixel
where expression is an IPNImage object
Returns an Integer, one of 0, 90, 180 or 270.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) imageNode.Nodes.Add("Rotation: " + Image.RotationInDegrees.ToString() + " degrees")Next
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); imageNode.Nodes.Add("Rotation: " + Image.RotationInDegrees.ToString() + " degrees");}
See Also: BitsPerPixel Files HeightInPixels Job Orientation PageNumber Pages SessionWidthInPixels XPixelsPerInch YPixelsPerInch
Session
Description
The parent IPNSession object that created this IPNImage object.
Read-only.
Syntaxexpression.Session
where expression is an IPNImage object
Returns an IPNSession object.
Examples
Visual Basic
Private Sub Session_OnEndImage(ByVal pImage As IPNImage) Handles Session.OnEndImage
Dim sessionJobsCollection As IPNJobs
' Get the collection of jobs this image belongs to.
357
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImage
sessionJobsCollection = pImage.Session.Jobs MsgBox("There are " + sessionJobsCollection.Count.ToString() + " jobs.")End Sub
C#
void m_session_OnEndImage(IPNImage pImage){ try { IPNJobs sessionJobsCollection; // Get the collection of jobs this job belongs to. sessionJobsCollection = pImage.Session.Jobs; MessageBox.Show("There are " + sessionJobsCollection.Count.ToString() + " jobs.") ; } catch (Exception getJobCollEx) { MessageBox.Show("Exception getting job collection from parent session. (" + getJobCollEx.Message + ")..."); }}
See Also: BitsPerPixel Files HeightInPixels Job Orientation PageNumber PagesRotationInDegrees WidthInPixels XPixelsPerInch YPixelsPerInch
WidthInPixels
Description
This is the width of the output image in pixels.
Read-only.
Syntaxexpression.HeightInPixel
where expression is an IPNImage object
Returns an Integer.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) imageNode.Nodes.Add("Height in Pixels: " + Image.HeightInPixels.ToString) imageNode.Nodes.Add("Width in Pixels: " + Image.WidthInPixels.ToString)Next
C#
foreach (IPNImage Image in images){ // Add image node
PNSrv10 COM Interface
358 PNSrv10 COM Interface Object ReferenceIPNImage
imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); imageNode.Nodes.Add("Height in Pixels: " + Image.HeightInPixels.ToString()); imageNode.Nodes.Add("Width in Pixels: " + Image.WidthInPixels.ToString());}
See Also: BitsPerPixel Files HeightInPixels Job Orientation PageNumber PagesRotationInDegrees Session XPixelsPerInch YPixelsPerInch
XPixelsPerInch
Description
This is the vertical dots per inch (DPI), or resolution, of the output image.
Read-only.
Syntaxexpression.XPixelsPerInch
where expression is an IPNImage object
Returns an Integer.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) imageNode.Nodes.Add("X DPI: " + Image.XPixelsPerInch.ToString) imageNode.Nodes.Add("Y DPI: " + Image.YPixelsPerInch.ToString)Next
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); imageNode.Nodes.Add("X DPI: " + Image.XPixelsPerInch.ToString()); imageNode.Nodes.Add("Y DPI: " + Image.YPixelsPerInch.ToString());}
See Also: BitsPerPixel Files HeightInPixels Job Orientation PageNumber PagesRotationInDegrees Session WidthInPixels YPixelsPerInch
YPixelsPerInch
Description
359
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceIPNImage
This is the horizontal dots per inch, or resolution, of the output image.
Read-only.
Syntaxexpression.YPixelsPerInch
where expression is an IPNImage object
Returns an Integer.
Examples
Visual Basic
For Each Image As IPNImage In images
' Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString) imageNode.Nodes.Add("File: " + Image.File.Filename) imageNode.Nodes.Add("X DPI: " + Image.XPixelsPerInch.ToString) imageNode.Nodes.Add("Y DPI: " + Image.YPixelsPerInch.ToString)Next
C#
foreach (IPNImage Image in images){ // Add image node imageNode = ImagesRootNode.Nodes.Add("Image " + Image.PageNumber.ToString()); imageNode.Nodes.Add("File: " + Image.File.Filename); imageNode.Nodes.Add("X DPI: " + Image.XPixelsPerInch.ToString()); imageNode.Nodes.Add("Y DPI: " + Image.YPixelsPerInch.ToString());}
See Also: BitsPerPixel Files HeightInPixels Job Orientation PageNumber PagesRotationInDegrees Session WidthInPixels XPixelsPerInch
PNSrv10 COM Interface
360 PNSrv10 COM Interface Object ReferenceEnumerations
Enumerations
pnBWCompressionMethod
Description
Compression algorithms for monochrome, or black and white, images.
Details
Name Value Description
pnBWCompressionNone 1 No compression algorithm used
pnBWCompressionGroup4 2 CCITT Group4 Fax compression
pnBWCompressionGroup32D 3 CCITT Group3 2D Fax compression
pnBWCompressionGroup31D 4 CCITT Group3 1D Fax compression
pnBWCompressionMH 5 CCITT Modified Huffman compression
pnBWCompressionLZW 6 LZW compression
pnBWCompressionPackbits 7 Packbits (RLE) compression
Remarks
Not all of the compression methods can be used by each driver. Calling these methodson a driver that does not support them will return an invalid argument exception, or anargument out of range exception.
Name Driver Support
pnBWCompressionNone Raster Image Printer 10.0, TIFF Image Printer 10.0,PDF Image Printer 10.0
pnBWCompressionGroup4 Raster Image Printer 10.0, TIFF Image Printer 10.0,PDF Image Printer 10.0
pnBWCompressionGroup32D Raster Image Printer 10.0, TIFF Image Printer 10.0,PDF Image Printer 10.0
pnBWCompressionGroup31D Raster Image Printer 10.0, TIFF Image Printer 10.0,PDF Image Printer 10.0
pnBWCompressionMH TIFF Image Printer 10.0, Raster Image Printer 10.0
pnBWCompressionLZW TIFF Image Printer 10.0, Raster Image Printer 10.0
pnBWCompressionPackbits TIFF Image Printer 10.0, Raster Image Printer 10.0
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also:pnColorCompressionMethod pnGrayscaleCompressionMethodpnIndexedCompressionMethod pnPDFContentEncodingMethod SetTIFFCompressionOptionsSetPDFCompressionOptions SetJPEGCompressionOptions
361
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnColorCompressionMethod
Description
Compression algorithms for color images.
Details
Name Value
Description
pnColorCompressionNone 1 No color compression, RBG color
pnColorCompressionNoneCMYK 2 No color compression, CMYK color
pnColorCompressionPackbits 3 Packbits (RLE) compression, RGB color
pnColorCompressionPackbitsCMYK 4 Packbits (RLE) compression, CMYK color
pnColorCompressionJPEGHighQuality 5 High quality JPEG compression
pnColorCompressionJPEGMediumQuality 6 Medium quality JPEG compression
pnColorCompressionJPEGLowQuality 7 Low quality JPEG compression
pnColorCompressionLZW 8 LZW compression, RGB color
pnColorCompressionLZWCMYK 9 LZW compression, CMYK color
pnColorCompressionZIP 10 ZIP compression
Remarks
Not all of the compression methods can be used by each driver. Calling these methodson a driver that does not support them will return an invalid argument exception, or anargument out of range exception.
Name Driver Supprt
pnColorCompressionNone Raster Image Printer 10.0, TIFF Image Printer10.0, PDF Image Printer 10.0
pnColorCompressionNoneCMYK TIFF Image Printer 10.0, Raster Image Printer10.0
pnColorCompressionPackbits Raster Image Printer 10.0, TIFF Image Printer10.0, PDF Image Printer 10.0
pnColorCompressionPackbitsCMYK TIFF Image Printer 10.0, Raster Image Printer10.0
pnColorCompressionJPEGHighQuality Raster Image Printer 10.0, TIFF Image Printer10.0, PDF Image Printer 10.0
pnColorCompressionJPEGMediumQuality Raster Image Printer 10.0, TIFF Image Printer10.0, PDF Image Printer 10.0
pnColorCompressionJPEGLowQuality Raster Image Printer 10.0, TIFF Image Printer10.0, PDF Image Printer 10.0
pnColorCompressionLZW Raster Image Printer 10.0, TIFF Image Printer10.0, PDF Image Printer 10.0
pnColorCompressionLZWCMYK TIFF Image Printer 10.0, Raster Image Printer10.0
pnColorCompressionZIP PDF Image Printer 10.0, Raster Image Printer10.0
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
PNSrv10 COM Interface
362 PNSrv10 COM Interface Object ReferenceEnumerations
See Also: pnBWCompressionMethod pnGrayscaleCompressionMethodpnIndexedCompressionMethod pnPDFContentEncodingMethod SetTIFFCompressionOptionsSetPDFCompressionOptions SetJPEGCompressionOptions
363
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnColorReduction
Description
Color reduction options for reducing the number of colors in true color images.
Details
Name Value Description
pnColorReductionNone 1 No color reduction
pnColorReductionOptimal 2 Reduce to lowest color count needed perpage
pnColorReductionBlackAndWhite 3 Reduce to black and white using selecteddithering method
pnColorReductionGreyscale 4 Reduce to greyscale
pnColorReduction256Colors 5 Create all pages as 8-bit color (256colors)
pnColorReduction16Colors 6 Create all pages as 4-bit color (16colors)
pnColorReductionOptimalMax256Colors 7 Reduces to lowest color count needed foreach page, any pages over 256 colorsare reduced to 256 colors.
pnColorReductionOptimalMax16Colors 8 Reduces to lowest color count needed foreach page, any pages over 16 colors arereduced to 16 colors.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnDitheringMethod SetSaveOptions
PNSrv10 COM Interface
364 PNSrv10 COM Interface Object ReferenceEnumerations
pnDitheringMethod
Description
Dithering algorithms to control how color images are reduces to black and white.
Details
Name Value Description
pnDitheringNone 1 No dithering
pnDitheringFloyd 2 Floyd-Steinberg dithering
pnDitheringBurkes 3 Burkes dithering
pnDitheringBayer 4 Bayer dithering
pnDitheringHalftone 5 Halftone dithering
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnColorReduction SetSaveOptions
365
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnEmailDialog
Description
The type of dialog box to use when creating new email messages. Not all dialog boxtypes apply to all types of email services.
Details
Name Value Description
pnEmailDialogStandard 1 Use generic default compose dialog suppliedby the printer
pnEmailDialogClient 2 Use email client’s compose dialog, emailservice must be set to MAPI
pnEmailDialogLotus 3 Use the Lotus compose dialog, email servicemust be set to VIM
pnEmailDialogAutosend 4 No dialog (autosend)
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnEmailService pnMAPIEmailLogon SetEmailService SetMAPIEmailServiceSetSMTPEmailService SetVIMEmailService
PNSrv10 COM Interface
366 PNSrv10 COM Interface Object ReferenceEnumerations
pnEmailService
Description
Set the e-mail service used to automatically e-mail the created output files.
Details
Name Value Description
pnEmailServiceMAPI 1 Use simple MAPI e-mail service, supports mostemail clients, including Outlook Express,Outlook, Netscape Messenger, and Eudora.
pnEmailServiceSMTP 2 Use SMTP protocol for sending e-mailmessages between servers; not require anemail client to be installed.
pnEmailServiceVIM 3 Send email over a Lotus Notes/Dominosystem.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnEmailDialog pnMAPIEmailLogon SetEmailService SetMAPIEmailServiceSetSMTPEmailService SetVIMEmailService
367
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnErrorMessageBoxStyle
Description
Choose the level of error message display.
Details
Name Value
Description
pnErrorMessageBoxStyleNone 1 Do not display an error message
pnErrorMessageBoxStyleTimed 2 Display error message, dialog auto-dismissedafter 5 seconds
pnErrorMessageBoxStyleStandard 3 Display error message and wait for userresponse
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetMessageBoxAlerts
PNSrv10 COM Interface
368 PNSrv10 COM Interface Object ReferenceEnumerations
pnFaxPageScaling
Description
Determines how the original information is placed on the fax sized paper.
Details
Name Value Description
pnFaxPageScalingFitToPage 1 Scale the original image to fit on the fax papersize chosen.
pnFaxPageScalingActualSize 2 Keeps the original information at the samesize, any part that does not fit on the faxpaper is cut off.
Supported Printers: TIFF Image Printer 10.0
See Also: pnFaxProfile pnFaxResolution pnFaxPaperWidth pnFaxPaperHeightpnFaxPageScalingHAlign pnFaxPageScalingVAlign SetFaxOptions
369
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnFaxPageScalingHAlign
Description
Determines how to horizontally align the incoming image on the fax sized paper.
Details
Name Value Description
pnFaxPageScalingHAlignLeft 1 Align to the left of the page
pnFaxPageScalingHAlignMiddle 2 Align in the middle of the page
pnFaxPageScalingHAlignRight 3 Align to the right of the page
Supported Printers: TIFF Image Printer 10.0
See Also: pnFaxProfile pnFaxResolution pnFaxPaperWidth pnFaxPaperHeightpnFaxPageScaling pnFaxPageScalingVAlign SetFaxOptions
PNSrv10 COM Interface
370 PNSrv10 COM Interface Object ReferenceEnumerations
pnFaxPageScalingVAlign
Description
Determines how to vertically align the incoming image on the fax sized paper.
Details
Name Value Description
pnFaxPageScalingVAlignTop 1 Align to the top of the page
pnFaxPageScalingVAlignMiddle 2 Align in the middle of the page
pnFaxPageScalingVAlignBottom 3 Align to the bottom of the page
Supported Printers: TIFF Image Printer 10.0
See Also: pnFaxProfile pnFaxResolution pnFaxPaperWidth pnFaxPaperHeightpnFaxPageScaling pnFaxPageScalingHAlign SetFaxOptions
371
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnFaxPaperHeight
Description
Determines the height of the fax paper.
Details
Name Value Description
pnFaxPaperHeightVariable 1 Varies the image length depending on the sizeof the incoming document.
pnFaxPaperHeightFixed 2 Limit the image length based on the pnFaxPaperWidth chosen
Supported Printers: TIFF Image Printer 10.0
See Also: pnFaxProfile pnFaxResolution pnFaxPaperWidth pnFaxPageScalingpnFaxPageScalingHAlign pnFaxPageScalingVAlign SetFaxOptions SetFaxOptions
PNSrv10 COM Interface
372 PNSrv10 COM Interface Object ReferenceEnumerations
pnFaxPaperWidth
Description
Determines the width of the fax paper.
Details
Name Value Description
pnFaxPaperWidthLetter 1 Letter
pnFaxPaperWidthLegal 2 Legal
pnFaxPaperWidthA4 3 A4 (ISO)
pnFaxPaperWidthB4 4 B4 (ISO)
pnFaxPaperWidthA3 5 A3 (ISO)
Supported Printers: TIFF Image Printer 10.0
See Also: pnFaxProfile pnFaxResolution pnFaxPaperHeight pnFaxPageScalingpnFaxPageScalingHAlign pnFaxPageScalingVAlign SetFaxOptions
373
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnFaxProfile
Description
Determines the fax profile used to create a fax image.
Details
Name Value Description
pnFaxProfileF 1 Profile F (standard) monochrome fax
pnFaxProfileS 2 Profile S (simplified) monochrome fax
pnFaxProfileC 3 Profile C color fax
Supported Printers: TIFF Image Printer 10.0
See Also: pnFaxResolution pnFaxPaperHeight pnFaxPaperWidth pnFaxPageScalingpnFaxPageScalingHAlign pnFaxPageScalingVAlign SetFaxOptions
PNSrv10 COM Interface
374 PNSrv10 COM Interface Object ReferenceEnumerations
pnFaxResolution
Description
Determines the fax resolution used to create a fax image. Note that the fax profilechosen (pnFaxProfile) affects which resolutions can be chosen. Not all resolutions arevalid for all fax profiles.
Details
Name Value Description
pnFaxResolution100x100 1 100 x 100 resolution (Profile F, C)
pnFaxResolution200x100 2 200 x 100 resolution (Profile S, F)
pnFaxResolution200x200 3 200 x 200 resolution (Profile S, F, C)
pnFaxResolution204x98 4 204 x 98 resolution (Profile S, F)"
pnFaxResolution204x196 5 204 x 196 resolution (Profile S, F)
pnFaxResolution300x300 6 300 x 300 resolution (Profile F, C)
pnFaxResolution400x400 7 400 x 400 resolution (Profile F, C)
pnFaxResolution408x391 8 408 x 391 resolution (Profile F)
pnFaxResolution204x391 9 204 x 391 resolution (Profile F)
pnFaxResolution300x600 10 300 x 600 resolution (Profile F)
pnFaxResolution400x800 11 400 x 800 resolution (Profile F)
pnFaxResolution600x600 12 600 x 600 resolution (Profile F, C)
pnFaxResolution600x1200 13 600 x 1200 resolution (Profile F)
pnFaxResolution1200x1200 14 1200 x 1200 resolution (Profile F, C)
Supported Printers: TIFF Image Printer 10.0
See Also: pnFaxProfile pnFaxPaperHeight pnFaxPaperWidth pnFaxPageScalingpnFaxPageScalingHAlign pnFaxPageScalingVAlign SetFaxOptions
375
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnGrayscaleCompressionMethod
Description
Compression algorithms for greyscale images.
Details
Name Value Description
pnGreyscaleCompressionNone 1 No color compression
pnGreyscaleCompressionPackbits 2 Packbits (RLE) compression
pnGreyscaleCompressionJPEGHighQuality 3 High quality JPEG compression
pnGreyscaleCompressionJPEGMediumQuality 4 Medium quality JPEG compression
pnGreyscaleCompressionJPEGLowQuality 5 Low quality JPEG compression
pnGreyscaleCompressionLZW 6 LZW compression
pnGreyscaleCompressionZIP 7 ZIP compression
Remarks
Not all of the compression methods can be used by each driver. Calling these methodson a driver that does not support them will return an invalid argument exception, or anargument out of range exception.
Name Driver Support
pnGreyscaleCompressionNone Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnGreyscaleCompressionPackbits TIFF Image Printer 10.0, Raster ImagePrinter 10.0
pnGreyscaleCompressionJPEGHighQuality Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnGreyscaleCompressionJPEGMediumQuality Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnGreyscaleCompressionJPEGLowQuality Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnGreyscaleCompressionLZW Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnGreyscaleCompressionZIP PDF Image Printer 10.0, Raster ImagePrinter 10.0
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnBWCompressionMethod pnColorCompressionMethodpnIndexedCompressionMethod pnDitheringMethod pnPDFContentEncodingMethodSetJPEGCompressionOptions SetTIFFCompressionOptions SetPDFCompressionOptions
PNSrv10 COM Interface
376 PNSrv10 COM Interface Object ReferenceEnumerations
pnImageCopyScaling
Description
Determines how the original page is placed on the new image.
Details
Name Value Description
pnImageCopyScalingFitToPage 1 Scales the original page up or down tofit on the new image size chosen.
pnImageCopyScalingActualSize 2 Keeps the original information at thesame size, any part that does not fit onthe new image size will be cut off.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnUnits pnImageCopyScalingHAlign pnImageCopyScalingVAlignSetImageCopyToOptions
377
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnImageCopyScalingHAlign
Description
Choose how to horizontally align the image on the output pag when copying the imageto a new page size.
Details
Name Value Description
pnImageCopyScalingHAlignLeft 1 Align to the left of the page
pnImageCopyScalingHAlignMiddle 2 Align in the middle of the page
pnImageCopyScalingHAlignRight 3 Align to the right of the page
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnUnits pnImageCopyScaling pnImageCopyScalingVAlignSetImageCopyToOptions
PNSrv10 COM Interface
378 PNSrv10 COM Interface Object ReferenceEnumerations
pnImageCopyScalingVAlign
Description
Choose how to vertically align the image on the output page when copying the image toa new page size.
Details
Name Value Description
pnImageCopyScalingVAlignTop 1 Align to the top of the page
pnImageCopyScalingVAlignMiddle 2 Align in the middle of the page
pnImageCopyScalingVAlignBottom 3 Align to the bottom of the page
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnUnits pnImageCopyScaling pnImageCopyScalingHAlignSetImageCopyToOptions
379
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnIndexedCompressionMethod
Description
Compression algorithms for indexed images. An indexed image is an image that has 256colors or less.
Details
Name Value Description
pnIndexedCompressionNone 1 No color compression
pnIndexedCompressionPackbits 2 Packbits (RLE) compression
pnIndexedCompressionJPEGHighQuality 3 High quality JPEG compression
pnIndexedCompressionJPEGMediumQuality 4 Medium quality JPEG compression
pnIndexedCompressionJPEGLowQuality 5 Low quality JPEG compression
pnIndexedCompressionLZW 6 LZW compression
pnIndexedCompressionZIP 7 ZIP compression
Remarks
Not all of the compression methods can be used by each driver. Calling these methodson a driver that does not support them will return an invalid argument exception, or anargument out of range exception.
Name Driver Support
pnIndexedCompressionNone Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnIndexedCompressionPackbits Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnIndexedCompressionJPEGHighQuality Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnIndexedCompressionJPEGMediumQuality Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnIndexedCompressionJPEGLowQuality Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnIndexedCompressionLZW Raster Image Printer 10.0, TIFF ImagePrinter 10.0, PDF Image Printer 10.0
pnIndexedCompressionZIP PDF Image Printer 10.0
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnBWCompressionMethod pnColorCompressionMethodpnGrayscaleCompressionMethod. pnPDFContentEncodingMethod SetTIFFCompressionOptions SetPDFCompressionOptions SetJPEGCompressionOptions
PNSrv10 COM Interface
380 PNSrv10 COM Interface Object ReferenceEnumerations
pnJobVariable
Description
Job properties that can be set or retrieved during certain IPNSession events usingSetVariableByKeyword to set the property and GetVariableByKeyword to get the propertyvalue. These properties can only be retrieved and set while the job is running. See the Job Properties Event Map for a list of the properties that can be set and the argumentsrequired for each property.
Details
Name ValueDescription
pnJobVariableOutputDir 1 Output directory of the new file
pnJobVariableOutputFileName 2 Base filename of the new file
pnJobVariableOutputFileFormat 3 File format string for the file type to create
pnJobVariableStartNewFile 4 Triggers the printer to start a new file, setonly.
pnJobVariableAppend 5 Switch to append mode.
pnJobVariableOverwrite 6 Enable\disable prompt when overwriting.
pnJobVariablePrompt 7 Enable\disable prompt for filename.
pnJobVariableSkipPage 8 Skips the current page.
pnJobVariableSkipPageOn 9 Enable\disable page skipping, set only.
pnJobVariableUseJobID 10 Enable\disable using Job ID as part of thefile name.
pnJobVariableRemoveProductName 11 Enable\disable removing the product namefrom the file name.
pnJobVariableDeleteFiles 12 Enable\disable deleting output files whendone.
pnJobVariableTempDir 13 Reserved, do not use.
pnJobVariableFileNumber 14 Reserved, do not use.
pnJobVariablePrintRange 15 Reserved, do not use.
pnJobVariableCancelJob 16 Cancels the current job, set only.
pnJobVariableUser0-9 17-26 User variables
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetVariableByKeyword GetVariableByKeyword
381
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnMAPIEmailLogon
Description
The type of email logon behaviour to use when creating new email messages. Onlyapplies to MAPI email service.
Details
Name Value Description
pnMAPIEmailLogonWhenNeeded 1 If an email client is already open, the user willnot be prompted to log on to their email client.
pnMAPIEmailLogonNewSession 2 This option will prompt a user to log on totheir email client every time they print.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnEmailDialog pnEmailService SetEmailService SetMAPIEmailServiceSetSMTPEmailService SetVIMEmailService
PNSrv10 COM Interface
382 PNSrv10 COM Interface Object ReferenceEnumerations
pnNamingProfile
Description
The naming profile to use when creating files.
Details
Name Value Description
pnNamingProfileMultipage 1 Use the multi-page file naming format.
pnNamingProfileMultipageWithJobID 2 Use the multi-page file naming format withJob ID as part of the name.
pnNamingProfileSerialized 3 Use the serialized file naming format.
pnNamingProfileSerializedWithJobID 4 Use the serialized file naming format withJob ID as part of the name.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetNamingProfileFormat
383
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnOutputFileFormat
Description
The output format, or type of file to create.
Not all formats can be used with all drivers. For instance, pnOutputFileFormatTIFFMultipaged and pnOutputFileFormatTIFFSerialized can only beused with TIFF Image Printer 10.0 and Raster Image Printer 10.0, while pnOutputFileFormatJPEG can only be used with Raster Image Printer 10.0.
Details
Name Value Description
pnOutputFileFormatTIFFMultipaged 1 TIFF Multipaged (*.tif) (TIFF Image Printer
10.0, Raster Image Printer 10.0)
pnOutputFileFormatTIFFSerialized 2 TIFF Serialized (*.tif) (TIFF Image Printer
10.0, Raster Image Printer 10.0)
pnOutputFileFormatAdobePDFMultipaged 3 Adobe PDF Multipaged (*.pdf) (PDF
Image Printer 10.0, Raster Image Printer 10.0)
pnOutputFileFormatAdobePDFSerialized 4 Adobe PDF Serialized (*.pdf) (PDF Image
Printer 10.0, Raster Image Printer 10.0)
pnOutputFileFormatJPEG 5 JPEG (*.jpg)
pnOutputFileFormatCompuServeGIF 6 CompuServe GIF (*.gif) (Raster Image
Printer 10.0)
pnOutputFileFormatCompuServePNG 7 CompuServe PNG (*.png) (Raster Image
Printer 10.0)
pnOutputFileFormatWindowsBMP 8 Windows BMP (*.bmp) (Raster Image
Printer 10.0)
pnOutputFileFormatTARGA 9 Targa (*.tga) (Raster Image Printer 10.0)
pnOutputFileFormatAdobePhotoshop3 10 Adobe Photoshop 3.0 (*.psd) (Raster
Image Printer 10.0)
pnOutputFileFormatZSoftPCX 11 ZSoft PCX (*.pcx) (Raster Image Printer 10.0)
pnOutputFileFormatZSoftDCX 12 ZSoft DCX (*.dcx) (Raster Image Printer
10.0)
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnColorReduction pnDitheringMethod SetSaveOptions
PNSrv10 COM Interface
384 PNSrv10 COM Interface Object ReferenceEnumerations
pnPDFContentEncodingMethod
Description
Compression algorithms for used for encoding the contents of the PDF files.
Details
Name Value Description
pnPDFContentEncodingNone 1 No content encoding
pnPDFContentEncodingZIP 2 Use ZIP compression to encode the filecontents.
pnPDFContentEncodingPackbits 3 Use Packbits (RLE) compression to encodethe file contents.
pnPDFContentEncodingLZW 4 Use LZW compression to encode the filecontents.
Supported Printers: PDF Image Printer 10.0
See Also: pnBWCompressionMethod pnGrayscaleCompressionMethodpnColorCompressionMethod pnIndexedCompressionMethod SetTIFFCompressionOptionsSetPDFCompressionOptions SetJPEGCompressionOptions
385
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnPDFEncryption
Description
Encryption options for PDF security.
Details
Name Value Description
pnPDFEncryption40 1 Use 40-bit encryption. The PDF file can beopened in Acrobat 3.0 and later versions
pnPDFEncryption128 2 Use 128-bit encryption. The PDF file can beopened in Acrobat 5.0 and later versions
Supported Printers: PDF Image Printer 10.0
See Also: SetPDFSecurity
PNSrv10 COM Interface
386 PNSrv10 COM Interface Object ReferenceEnumerations
pnPrinterColorMode
Description
Sets the current color options for the printer.
Details
Name Value Description
pnPrinterColorModeDefault 0 Uses the current printer setting.
pnPrinterColorModeColor 1 Color
pnPrinterColorModeBW 2 Black and White (monochrome)
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnPrinterResolution pnPrinterOrientation ForcePrinterColorModeSetDevmodeSettings
387
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnPrinterOrientation
Description
The pnPrinterOrientationDefault setting will use the default orientation of the printer andallow the printing application to control the paper orientation. Setting pnPrinterOrientationPortrait or pnPrinterOrientationLandscape will force the printer intothe chosen orientation.
Details
Name Value Description
pnPrinterOrientationDefault 0 Uses the current printer setting.
pnPrinterOrientationPortrait 1 Portrait
pnPrinterOrientationLandscape 2 Landscape
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnPrinterResolution pnPrinterColorMode ForcePrinterOrientationSetDevmodeSettings
PNSrv10 COM Interface
388 PNSrv10 COM Interface Object ReferenceEnumerations
pnPrinterResolution
Description
Sets the current printer resolution.
Details
Name Value Description
pnPrinterResolutionDefault 0 Uses the current printer setting.
pnPrinterResolution50 1 50 DPI
pnPrinterResolution60 2 60 DPI
pnPrinterResolution75 3 75 DPI
pnPrinterResolution100 4 100 DPI
pnPrinterResolution120 5 120 DPI
pnPrinterResolution150 6 150 DPI
pnPrinterResolution200 7 200 DPI
pnPrinterResolution240 8 240 DPI
pnPrinterResolution254 9 254 DPI
pnPrinterResolution300 10 300 DPI
pnPrinterResolution360 11 360 DPI
pnPrinterResolution400 12 400 DPI
pnPrinterResolution600 13 600 DPI
pnPrinterResolution720 14 720 DPI
pnPrinterResolution1200 15 1200 DPI
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnPrinterColorMode pnPrinterOrientation ForcePrinterResolutionSetDevmodeSettings
389
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnResampleUnits
Description
Determine how to scale the output image.
Details
Name Value Description
pnResampleUnitsPixels 1 Scale using new width and height in pixels.
pnResampleUnitsPercentage 2 Scale as a percentage (%) of the original size.
pnResampleUnitsDPI 3 Scale by setting a new image resolution (DPI).
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetResamplingOptions
PNSrv10 COM Interface
390 PNSrv10 COM Interface Object ReferenceEnumerations
pnRotation
Description
Determine how much to rotate the output image. Rotation is counter-clockwise.
Details
Name Value Description
pnRotationNone 1 Do not rotate the image.
pnRotation90 2 Rotate 90 degrees.
pnRotation180 3 Rotate 180 degrees.
pnRotation270 4 Rotate 270 degrees.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetPageRotationOptions
391
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnRunCommmandsWaitMode
Description
Determines the wait mode when running commands through the printer.
Details
Name Value Description
pnRunCommandsWaitModeCompletion 1 Wait for the command tocomplete.
pnRunCommandsWaitModeWaitWithExit 2 Wait for the command tocomplete and return the exitcode.
pnRunCommandsWaitModeDoNotWait 3 Do not wait.
pnRunCommandsWaitModePromptToContinue 4 Display prompt to continue.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnRunCommandWindowState SetRunAtStartCommand SetRunAtPageCommandSetRunAtFileCloseCommand SetRunAtEndCommand
PNSrv10 COM Interface
392 PNSrv10 COM Interface Object ReferenceEnumerations
pnRunCommmandWindowState
Description
Determines the window state of applications launched when running commands throughthe printer.
Details
Name Value Description
pnRunCommandWindowStateNormal 1 Open window normally.
pnRunCommandWindowStateMinimized 2 Minimize window to the taskbar.
pnRunCommandWindowStateMaximized 3 Maximize the window to full size.
pnRunCommandWindowStateHidden 4 Hide the window.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnRunCommandsWaitMode SetRunAtStartCommand SetRunAtPageCommandSetRunAtFileCloseCommand SetRunAtEndCommand
393
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnShellAndCommandWaitMode
Description
Determines the printed document state to wait for when printing using the shellcommands or the command line.
Details
Name Value Description
pnShellAndCommandWaitModeSpooled 1 Wait until document is spooled to theprinter queue.
pnShellAndCommandWaitModePrinted 2 Wait until the document is printed.
pnShellAndCommandWaitModeCompleted 3 Wait until the document is printedand the output file is created.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: ShellPrint ShellPrintTo PrintUsingCommand
PNSrv10 COM Interface
394 PNSrv10 COM Interface Object ReferenceEnumerations
pnTextEncoding
Description
Determines the encoding format of the output text extraction file.
Details
Name Value Description
pnTextEncodingANSI 1 ASCII encoded text
pnTextEncodingUTF8 2 UTF-8 encoded text
pnTextEncodingUTF16 3 UTF-16 encoded text
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnTextLayout pnTextEOL SetTextExtractionOptions
395
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnTextEOL
Description
Determines the end-of-line encoding format of the output text extraction file. Dependingon the operating system the text file will be used on, you may need to choose theappropriate line return code.
Details
Name Value Description
pnTextEOLWindows 1 Lines end with the carriage return line feed(CRLF, \r\n) used by Windows.
pnTextEOLMac 2 Lines end with the line feed (LF, \n) used byUNIX.
pnTextEOLUnix 3 Lines end with the carriage return (CR, \r) usedby Macintosh.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnTextLayout pnTextEncoding SetTextExtractionOptions
PNSrv10 COM Interface
396 PNSrv10 COM Interface Object ReferenceEnumerations
pnTextLayout
Description
Determines the layout of the text in the output text extraction file.
Details
Name Value Description
pnTextLayoutPhysical 1 Matches the format of the text in the original fileas best as can be determined.
pnTextLayoutRaw 2 Text is outputted in the order in which is wassent to the printer. This may not be the sameorder in the original file.
pnTextLayoutNone 3 No formatting is attempted. The text is writtento the output file exactly as it is received by theprinter.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: pnTextEncoding pnTextEOL SetTextExtractionOptions
397
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnUnits
Description
Determines the unit of measure used to enter options requiring a unit of measure.
Details
Name Value Description
pnUnitsEnglish 1 Enter the units in inches
pnUnitsMetric 2 Enter the units in centimeters.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetCustomPaperOptions SetHardwareMargins SetImageCopyToOptionsSetPageCropAreaOptions SetPageCropMarginOptions
PNSrv10 COM Interface
398 PNSrv10 COM Interface Object ReferenceEnumerations
pnUserVariable
Description
A set of ten user variables that can be used to store custom information to later beretrieved during the following IPNSession events:
OnStartPage
OnOpenFile
OnStartImage
OnEndImage
OnCloseFile
OnEndPage
User variable data is stored as strings and can be retrieved using during an event byusing the GetVariableByKeyword method on the IPNJob object to get the property value.
Details
Name Value Description
pnUserVariable0 0 User variable 0, same as $(Var0)
pnUserVariable1 1 User variable 1, same as $(Var1)
pnUserVariable2 2 User variable 2, same as $(Var2)
pnUserVariable3 3 User variable 3, same as $(Var3)
pnUserVariable4 4 User variable 4, same as $(Var4)
pnUserVariable5 5 User variable 5, same as $(Var5)
pnUserVariable6 6 User variable 6, same as $(Var6)
pnUserVariable7 7 User variable 7, same as $(Var7)
pnUserVariable8 8 User variable 8, same as $(Var8)
pnUserVariable9 9 User variable 9, same as $(Var9)
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetUserVariable GetVariableByKeyword
399
PNSrv10 COM Interface
PNSrv10 COM Interface Object ReferenceEnumerations
pnWatermarkPosition
Description
Use this option to determine how the watermark image is placed on the page.
Details
Name Value Description
pnWatermarkPositionStretch 1 Stretch the watermark image to fit the page.
pnWatermarkTile 2 Tiles (repeats) the image to fill the page.
pnWatermarkCenter 3 Centers the image in the middle of the page.
Supported Printers: Raster Image Printer 10.0, TIFF Image Printer 10.0, PDF ImagePrinter 10.0
See Also: SetLandscapeWatermarkOptions SetPortraitWatermarkOptions