Help Contents

Server Object

The Server object allows you to convert documents to HTML5 format and provides access to various default conversion options.

Remarks

The Server object is a core object of Print2HTML5 OLE Automation API. For almost all tasks related to Print2HTML5 Server functionality you need to create and use this object. Its primary responsibilities are:

  • Conversion of documents residing in files and folders to Print2HTML5 format;
  • Providing access to default printing profile, default printing preferences, default batch processing options and skins;
  • Providing statistic and error information on performed conversions.

Object access

To access Server object, you need to create it using "Print2HTML5.Server" ProgID such as in the following example:

set P2H=CreateObject("Print2HTML5.Server")
Then you can access its properties and methods using the reference to the created Server object.

 

Properties
 

Name Type Read-only Description
ConvertedPages Integer Yes Returns the number of pages actually present in the last converted Print2HTML5 document. This value may differ from TotalPages property value if you use PageRange property of BatchProcessingOptions object.
DefaultBatchProcessingOptions BatchProcessingOptions object

Yes

Returns BatchProcessingOptions object used for document conversion by default. You can change the returned object properties to modify default batch processing options for subsequent document conversions.
DefaultPrintingPreferences PrintingPreferences object Yes Returns PrintingPreferences object used for document conversion by default. You can change the returned object properties to modify default printing preferences for subsequent document conversions.
DefaultProfile Profile object Yes Returns Profile object used for document conversion by default. You can change the returned object properties to modify default document options for subsequent document conversions.
DirsScanned Integer Yes Returns the number of subdirectories scanned at the last document conversion.
ErrorCount Integer Yes Returns the number of errors occurred at the last document conversion. The error code and message can be retrieved either from conversion log or, in case of single document conversion with ConvertFile method, - from exception returned from that method.
FilesConverted Integer Yes Returns the number of files converted at the last document conversion.
MetadataFileCount Integer Yes Returns the number of metadata files generated at the last document conversion.
Skins SkinCollection object Yes Returns the collection of skins defined on this server.
SVGFileCount Integer Yes Returns the number of page SVG files generated at the last document conversion.
ThumbnailFileCount Integer Yes Returns the number of thumbnail files generated at the last document conversion. Thumbnail files generation is controlled by the ThumbnailPageRange property of Profile object.
TotalPages Integer Yes Returns the total number of pages in the last converted original document.
Version String Yes Returns Print2HTML5 Server version


Methods
 

CancelJob

Method cancels the current printing job.

Signature

CancelJob()

Remarks

This method reverts the Print2HTML5 Printer to normal mode of operation without capturing print jobs. It is safe to call this method even if StartJob method was not called before so you may call this method for safety in order to be sure that printer is in normal non-capturing operation mode. See Printing Jobs help topic for more information on printing jobs.
 

ConvertDir

Method converts all specified files in a directory to Print2HTML5 documents.

Signature

ConvertDir (SourceDirName, [SourceFileMask], [OutputDirName], [IncludeSubDirs], [Profile], [BatchProcessingOptions], [PrintingPreferences])

Arguments

Name Type Description
SourceDirName String The full path and name of the directory where all the document to convert reside
SourceFileMask String The mask for the files to convert, e.g. "*.doc". If this argument is not specified, all files are attempted to convert
OutputDirName String The full path and name of the output directory to which resulting Print2HTML5 documents are written. If this parameter is omitted, the output document files are written to the same directory as SourceDirName.
IncludeSubDirs Boolean Boolean indicator specifying whether to look for files to convert in all subdirectories of the SourceDirName directory in addition to the files located directly in SourceDirName directory. The default is false.
Profile Profile object Profile object with document options to use for conversion. If omitted, options from DefaultProfile property are used
BatchProcessingOptions BatchProcessingOptions object BatchProcessingOptions object with batch processing options to use for conversion. If omitted, options from DefaultBatchProcessingOptions property are used
PrintingPreferences PrintingPreferences object PrintingPreferences  object with printing preferences to use for conversion. If omitted, preferences from DefaultPrintingPreferences property are used

Remarks

At minimum you should provide only the SourceDirName argument. All other arguments are optional.

The method tries to convert all files satisfying the SourceFileMask and residing in SourceDirName directory. If IncludeSubDirs argument is set to true,  the files in all subdirectories of the SourceDirName directory with any nesting level are attempted to convert as well. The output HTML5 documents are named after the original document with .xml extension appended to the original document name.

Examples

The following example converts all documents in a directory named C:\Docs and stores the converted files in the same directory. Documents in subdirectories are not converted:

P2H.ConvertDir "C:\Docs"
This example is similar to the above except that it converts only .doc files:
 

P2H.ConvertDir "C:\Docs", "*.doc"
The next example is similar to the first one but it stores the output document files in a directory named C:\HTMLDocs:
 

P2H.ConvertDir "C:\Docs", , "C:\HTMLDocs" 
And finally this example is again similar to the first one with the only difference it converts the documents in all subdirectories of C:\Docs directory as well:
 

P2H.ConvertDir "C:\Docs", , , True

For usage examples of Profile, BatchProcessingOptions and PrintingPreferences arguments refer to Profile, BatchProcessingOptions and PrintingPreferences objects reference topics.

ConvertFile

Method converts a single file to Print2HTML5 document.

Signature

ConvertFile (SourceFileName , [OutputFileName], [Profile], [BatchProcessingOptions], [PrintingPreferences])

Arguments

Name Type Description
SourceFileName String The full path and name of the source document file
OutputFileName String The base full path and name of the output document file without extension. Print2HTML5 adds .xml extension to this name to obtain the output HTML5 documents file name.
If this parameter is omitted, the file is put into the same folder as the original file. HTML5 documents are named after the original document with .xml extension appended to the original document name.
Profile Profile object Profile object with document options to use for conversion. If omitted, options from DefaultProfile property are used
BatchProcessingOptions BatchProcessingOptions object BatchProcessingOptions object with batch processing options to use for conversion. If omitted, options from DefaultBatchProcessingOptions property are used
PrintingPreferences PrintingPreferences object PrintingPreferences  object with printing preferences to use for conversion. If omitted, preferences from DefaultPrintingPreferences property are used

Remarks

At minimum you should provide only the SourceFileName argument. All other arguments are optional.

Examples

The following example converts a document named C:\Docs\MyDoc.doc and saves the converted HTML5 document - to C:\Docs\MyDoc.doc.xml file (and a related resource folder C:\Docs\MyDoc.doc_files):

P2H.ConvertFile "C:\Docs\MyDoc.doc"
This example is similar to the above except that it saves the resulting HTML5 file under an explicitly specified name C:\HTMLDocs\Doc2.xml (and a related folder C:\HTMLDocs\Doc2_files):
 
P2H.ConvertFile "C:\Docs\MyDoc.doc", "C:\HTMLDocs\Doc2"
For usage examples of Profile, BatchProcessingOptions and PrintingPreferences arguments refer to Profile, BatchProcessingOptions and PrintingPreferences objects reference topics.
 

EndJob

Method ends the current printing job.

Signature

EndJob()

Remarks

This call creates a Print2HTML5 document at the location specified in the earlier StartJob method call. After this call the Print2HTML5 Printer reverts to normal mode of operation without capturing print jobs. See Printing Jobs help topic for more information on printing jobs.


SetP2HPrinterAsDefault

Makes Print2HTML5 Printer a default printer in the system.

Signature

SetP2HPrinterAsDefault()

Remarks

This method call makes Print2HTML5 Printer a default printer in the system. For some applications it may be necessary that Print2HTML5 Printer is a default printer in order to send document output to it successfully. In such cases this method may help you to set Print2HTML5 Printer as a default printer.


StartJob

Method starts a new printing job.

Signature

StartJob(OutputFileName, Profile, BatchProcessingOptions, PrintingPreferences)

Arguments

Name Type Description
OutputFileName String The base full path and name of the output document file without extension. Print2HTML5 adds .xml extension to this name to obtain a resulting HTML5 document file name.
Profile Profile object The Profile object to use for conversion.
BatchProcessingOptions  BatchProcessingOptions  object The BatchProcessingOptions object to use for conversion.
PrintingPreferences PrintingPreferences  object The PrintingPreferences  object to use for conversion.

Remarks

After this call the Print2HTML5 Printer switches to a special "capture" mode at which any print job sent to it will be converted to a Print2HTML5 document written to the file specified by the OutputFileName parameter. See Printing Jobs help topic for more information on printing jobs