Help Contents

BatchProcessingOptions Object

The BatchProcessingOptions object controls several aspects concerning the document conversion process itself.

Remarks

BatchProcessingOptions object is intended for control of automated document conversion process. Its provides access to several conversion options for documents of some types if special processing method is used, controls log file creation and allows you to limit the number of converted pages in output documents. Some properties of BatchProcessingOptions object are intended for cases when it is needed to control abnormal printing application behavior. But normally you don't need to use such properties as Print2HTML5 Server default settings should handle most of the situations arising during document conversion.

To learn how to use some properties of BatchProcessingOptions object, background information on how Print2HTML5 converts documents is needed which is presented further. Print2HTML5 does not convert any types of documents wholly by itself but it instructs the application that can print documents of a given type to send the printing output to the Print2HTML5 printer where output is intercepted and saved to a Print2HTML5 document file. First, Print2HTML5 looks up which application is registered in the operating system for printing of this kind of document. For example, conversion of .doc files is usually handled by Microsoft Word. Then, Print2HTML5 instructs that application to send the document to the Print2HTML5 Printer. And finally, Print2HTML5 Printer gets a printed representation of the document and saves it to an HTML5 file.

As conversion is performed with the help of external applications, some problems can arise:

  1. Application does not start printing regardless of the fact it was instructed to do so
  2. Application requires some user interaction before printing can be started, e.g. shows a Print dialog window
  3. Application prints a document too long or hangs up during printing
  4. Application is not unloaded from memory after printing is completed

It is easy to see that first three problems prevents the document from printing altogether while the last, though allows document conversion, consumes computer memory apparently unnecessarily. By default, Print2HTML5  handles such situations by itself but if you meet with a problem that seems to be of one of the kinds above, you may use BatchProcessingOptions object's abnormal situation control properties to control document conversion process.

There are three possible scenarios of using BatchProcessingOptions object:

  • For specifying special (ad hoc) batch processing options  applied to a single conversion or series of conversion. In such a case you should create a BatchProcessingOptions object, setup its properties and pass it to ConvertFile or ConvertDir methods as a BatchProcessingOptions argument;
  • For changing default batch processing options applied to all document conversions performed via a single Server object instance. In such a case you should obtain reference to the default batch processing options object using DefaultBatchProcessingOptions property and change its properties. Then you may convert files with this Server object instance and all the options you setup will be applied to all document conversions via this instance;
  • For changing global default batch processing options.  In such a case you should obtain a reference to the default batch processing options object using DefaultBatchProcessingOptions property, change its properties and save the changes using ApplyChanges method. 

Object access

To create an ad hoc BatchProcessingOptions object, you need to create it using "Print2HTML5.BatchProcessingOptions" ProgID such as in the following example:

set MyBPOpt=CreateObject("Print2HTML5.BatchProcessingOptions")
If you need to get a default batch processing options object with default batch processing options, you need to use DefaultBatchProcessingOptions property of Server object:
 
Set DefBPOpt=P2H.DefaultBatchProcessingOptions

Here P2H refers to Server object instance.

Regardless of the method you obtained a BatchProcessingOptions object, initially it contains the global default batch processing options setup by Print2HTML5 installation or by the last ApplyChanges method call. After you obtained a reference to BatchProcessingOptions object using one of the methods above, you can access its properties and methods.

Properties
 

Name Type Description

Log file

CreateLogFile Boolean Indicates whether to create a conversion log file which name is specified by LogFileName property
LogFileName String The name of the conversion log file
LoggingLevel Integer Specifies which messages are written to the log file specified by LogFileName property:
  • 0 - Normal logging level. Job start and end messages and each document conversion status are written to the log;
  • 1 - Detailed logging level. In addition to normal logging level, messages are written for each document page conversion which allows tracking document conversion progress.

Special document processing

UseAutomation Integer Bit mask which specifies for which document types special document processing should be used. The mask must be an OR combination of flags from APPLICATIONTYPE enumeration.
ExcelOptions ExcelOptions object Contains special Excel processing options used for conversion of Excel documents if special processing for Microsoft Excel is turned on.
PowerPointOptions PowerPointOptions object Contains special PowerPoint processing options used for conversion of PowerPoint documents if special processing for Microsoft PowerPoint is turned on.
KeepAutomationAppRef Integer This property specifies if the same application instance should be reused for printing of successive documents of the same type. Such reusing prevents closing of the respective application after conversion and uses existing application instance from previous conversion for processing of the next document of the same type. This could save conversion time because application does not have to exit and be loaded for each document conversion. If this flag is turned on for the given application, the application is closed only after the Server object is destroyed. This option works only if special document processing is turned on. The value is an OR combination of flags from APPLICATIONTYPE enumeration.
KillAllAutomationProcesses Integer Specifies if all processes of the given application should be killed if AfterPrintingTimeout expires after document printing is completed. Use this option with care as it kills all instances of the given application regardless of whether an instance actually took part in document conversion or not. For example, after conversion of a Word document, this option kills all Word processes (winword.exe). This option may be useful for ensuring full cleanup after document conversion is done as sometimes applications do not properly exit after printing or it is impossible to determine an actual instance that performed printing and thus KillProcessIfTimeout property cannot work. This option works only if special document processing is turned on. The value is an OR combination of flags from APPLICATIONTYPE enumeration.
CheckPDFEncryption Integer This property makes Print2HTML5 check if a PDF document is encrypted before conversion and return a respective error message if it is. It should have a value from ThreeStateFlag enumeration. If the value is:
  • TSF_YES - check the document encryption;
  • TSF_AUTO - let the Print2HTML5 to determine the best value for this setting automatically;
  • TSF_NO - setting has no effect.

Abnormal situation control

ActivityTimeout Integer Maximum time in milliseconds Print2HTML5 waits for the application to invoke the next Print2HTML5 Printer driver function while printing. This option may be useful for detection of printing application hang-ups. If an application does not show activity within this timeout (i.e. does not call the next driver function), Print2HTML5 proceeds to the next document, and, if KillProcessIfTimeout is true, the application process is killed as well. Zero (0) value means this timeout is not monitored.
AfterPrintingTimeout Integer Maximum time in milliseconds Print2HTML5 waits for the application to exit after document printing is completed. If this time expires, Print2HTML5 proceeds to the next document, and, if KillProcessIfTimeout is true, the application process is killed as well. Zero (0) value means this timeout is not monitored
BeforePrintingTimeout Integer Maximum time in milliseconds Print2HTML5 waits for the application to start document printing. If this time expires, Print2HTML5 proceeds to the next document, and, if KillProcessIfTimeout is true, the application process is killed as well. Zero (0) value means this timeout is not monitored
KillProcessIfTimeout Integer Should have a value from ThreeStateFlag enumeration. If the value is:
KillSplWOW64 Integer This property is used only for 64 bit edition of Print2HTML5. It specifies whether the Windows printer driver host process (splwow64.exe) should be killed after an error occurred at conversion. If your conversion server processes only Print2HTML5 printing jobs, it is recommended to set this value to TSF_YES for possible reset of error condition. However, if your server processes print jobs for other printers, killing of printer driver host process  may disrupt printing on other printers, and the recommended value is TSF_NO. The value should be from ThreeStateFlag enumeration. If the value is:
  • TSF_YES - Print2HTML5 kills the printer driver host if an error occurs at conversion;
  • TSF_AUTO - lets the Print2HTML5 to determine the best value for this setting automatically;
  • TSF_NO - setting has no effect.
PressPrintButton Integer Should have a value from ThreeStateFlag enumeration. If value is:
  • TSF_YES - Print2HTML5 tries to locate a Print dialog window in the application process and press Print button to continue printing without user intervention;
  • TSF_AUTO - lets the Print2HTML5 to determine the best value for this setting automatically;
  • TSF_NO - setting has no effect.
PrintingTimeout Integer Maximum time in milliseconds Print2HTML5 waits for the application to print the document. If this time expires, Print2HTML5 cancels the print job and proceeds to the next document, and, if KillProcessIfTimeout is true, the application process is killed as well. Zero (0) value means this timeout is not monitored

Other options

PageRange String String describing which pages to include in the output Print2HTML5 document. Pages that do not fit the specified range are skipped at printing. The string should be in the following format:

[Range1Start[-][Range1End]] [,Range2Start[-][Range2End]] [, ... ]

This string is composed of a sequence of page ranges separated by commas. Each page range can be either a plain page number such as "3", a page range such as "2-7" or an open page range such as "20-".
For example, string "2-7, 11, 20-" instructs to print pages from 2 to 7, page 11 and pages from page 20 to the end of the document. Page 1, pages from 8 to 10 and from 12 to 19 are skipped and not included in the output document.
Empty string value makes Print2HTML5 print all the document pages.
GenerateExternalViewer Boolean The property specifies whether an external viewer file should be created in the output folder. The viewer file name is docviewer.html.


Methods
 

ApplyChanges

Method saves the global default batch processing options.

Signature

ApplyChanges()

Arguments

None

Remarks

Method takes the object properties and saves them as the global default batch processing options. If you intend to change the global default batch processing options, you need to call this method to save the changes.

Examples

The following example obtains a default batch processing options object, modifies some of its properties and save the changes back to the global default batch processing options. The example assumes that enumeration constants file P2HAPIConst.vb from Print2HTML5 SDK is included:

Set DefBPOpt=P2H.DefaultBatchProcessingOptions
DefBPOpt.BeforePrintingTimeout = 60000
DefBPOpt.PrintingTimeout = 10000
DefBPOpt.PressPrintButton = TSF_AUTO
DefBPOpt.KillProcessIfTimeout = TSF_YES
DefBPOpt.ApplyChanges

BatchProcessingOptions Object Examples

The sample below creates an ad hoc batch processing options object, sets its properties and use it for conversion of a document named C:\Docs\index.htm

set MyBPOpt=CreateObject("Print2HTML5.BatchProcessingOptions")
MyBPOpt.PressPrintButton = TSF_YES
P2H.ConvertFile "C:\Docs\index.htm", , , MyBPOpt
This sample obtains a default batch processing options object, sets its properties and then converts documents in two directories using that batch processing options object's default settings:
 
Set DefBPOpt=P2H.DefaultBatchProcessingOptions
DefBPOpt.AfterPrintingTimeout = 5000
DefBPOpt.CreateLogFile = True
DefBPOpt.LogFileName = "C:\Logs\Print2HTML5Conv.log"
P2H.ConvertDir "C:\Docs"
P2H.ConvertDir "C:\ReadyDocuments"