Help Contents

PrintingPreferences Object

The PrintingPreferences object controls printing preferences settings used for document conversion.

Remarks

The PrintingPreferences object allows you to control all those options that can be setup in Printer Properties window when converting documents manually but at programmatic conversion. These options include paper size, resolution and orientation. In addition, this object can be used to change default printing preferences shown in Printing Preferences window.

There are three possible scenarios of using PrintingPreferences object:

  • For specifying special (ad hoc) printing preferences applied to a single conversion or series of conversion. In such a case you should create a PrintingPreferences object, setup its properties and pass it to ConvertFile or ConvertDir methods as a PrintingPreferences argument;
  • For changing default printing preferences applied to all document conversions performed via a single Server object instance. In such a case you should obtain reference to the default printing preferences object using DefaultPrintingPreferences 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 default printing preferences shown in Printing Preferences window.  In such a case you should obtain a reference to the default printing preferences object using DefaultPrintingPreferences property, change its properties and save the changes using ApplyChanges method. 

Object access

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

set MyPref=CreateObject("Print2HTML5.PrintingPreferences")
If you need to get a default printing preferences object with default printing preferences, you need to use DefaultPrintingPreferences property of Server object:
 
Set DefPref=P2H.DefaultPrintingPreferences 

Here P2H refers to Server object instance.

Regardless of the method you obtained a PrintingPreferences object, initially it contains the default printing preferences as they have been setup in Printing Preferences window.  After you obtained a reference to PrintingPreferences object using one of the methods above, you can access its properties and methods.

Properties
 

Name Type Read-only Description
Actual Boolean

Yes

Indicates if current object settings correspond to the global default printing preferences. Initially, after creating a PrintingPreferences object, it should return true. If you changed some of the object properties or global default printing preferences were changed since then, this property may return false. You can use this property to check if your PrintingPreferences instance is actual with regard to the global default printing preferences
FormName String Yes The current form selected for printing, e.g. "Letter", "A4", etc. The form name can be set using SetFormName method. If current paper size is specified using custom page width and length, this property returns an empty string
Orientation Integer No Page orientation. It should be set to one of the values from PAPER_ORIENTATION enumeration
PaperLength Integer Yes Current page length in tenths of millimeter (0.1 mm). Page length and width can be specified using SetCustomPaperSize method
PaperWidth Integer Yes Current page width in tenths of millimeter (0.1 mm). Page length and width can be specified using SetCustomPaperSize method
Resolution Boolean No Printing resolution in dots per inch (DPI). It can be any value between 96 and 600 DPI


Methods
 

ApplyChanges

Method saves the default printing preferences.

Signature

ApplyChanges()

Arguments

None

Remarks

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

Examples

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

Set DefPref=P2H.DefaultPrintingPreferences
DefPref.Resolution = 200
DefPref.Orientation = ORIENT_LANDSCAPE
DefPref.SetFormName("Letter")
DefPref.ApplyChanges

 

SetCustomPaperSize

Method specifies a custom paper size.

Signature

SetCustomPaperSize (Width, Length)

Arguments

Name Type Description
Width Integer Page width in tenths of millimeter (0.1 mm)
Length Integer Page length in tenths of millimeter (0.1 mm)

Remarks

Use this method to specify a custom paper size. This method is recommended to use if you want to specify a non-standard paper size. To specify a standard paper size such as "Letter" you may use SetFormName method. The current paper size can be retrieved using PaperLength and PaperWidth properties.

Examples

The following example creates an ad hoc printing preferences object and specifies custom paper size 15x20 cm.

set MyPref=CreateObject("Print2HTML5.PrintingPreferences")
MyPref.SetCustomPaperSize(1500,2000)

SetFormName

Method sets a standard paper size specified by form name.

Signature

SetFormName (FormName)

Arguments

Name Type Description
FormName String Name of the form. The list of valid form names depends on your computer operating system and printing settings. You may see the list of available form names in this way:
  • Launch Print2HTML5 Application;
  • Click Options/Printing Preferences;
  • See the form list in the Standard Paper Size drop down list

Remarks

Use this method to specify a standard paper size. To specify custom paper size use SetCustomPaperSize method.

Examples

The following example creates a default printing preferences object and specifies standard paper size with the form name "A4"

Set DefPref=P2H.DefaultPrintingPreferences 
DefPref.SetFormName("A4")

 

PrintingPreferences Object Examples

The sample below creates an ad hoc printing preferences object, sets its properties and use it for conversion of a document named C:\Docs\MyDoc.txt

set MyPref=CreateObject("Print2HTML5.PrintingPreferences")
MyPref.SetFormName("Letter")
MyPref.Orientation = ORIENT_PORTRAIT
P2H.ConvertFile "C:\Docs\MyDoc.txt", , , ,MyPref
This sample obtains a default printing preferences object, sets its properties and then converts documents in two directories using that printing preferences object default settings:
 
Set DefPref=P2H.DefaultPrintingPreferences
DefPref.SetFormName("Legal")
DefPref.Resolution=96
P2H.ConvertDir "C:\Docs"
P2H.ConvertDir "C:\ReadyDocuments"