Help Contents

Printing Jobs

Normally for conversion of documents using Print2HTML5 Automation API you need to provide a document file on disk and then invoke ConvertFile or ConvertDir methods of Server object specifying the path to the document file. However, there is another approach called "printing jobs". Using this approach you may "capture" any print job sent to the Print2HTML5 Printer and convert job output into an HTML5 file. This method offers some advantages:

  • There is no need even to have a file on disk in order convert a print job output to a Print2HTML5 document. You may capture any print job sent to the Print2HTML5 Printer without any connection with a file. For example, if you designed an application that can send some output to a printer, you may easily convert this output to HTML5 format;
  • You may convert documents of any types besides those that have an application registered for printing of this kind of files in the operating system provided that you can send this file to the Print2HTML5 Printer programmatically;
  • You may convert documents with more conversion options provided that you can send this file to the Print2HTML5 Printer programmatically and can control those options.

The drawback of printing jobs is you have to know how to send a document to the printer or create a print job with which you do not have to bother yourself if you use ConvertFile or ConvertDir methods. For documents there may be an API allowing you to print them, for example, MS Office has Automation API for accessing and printing of MS Office documents. Print jobs may be created by your application when you send any output from it to a printer.

Using Printing Jobs

The capturing of a print job into a Print2HTML5 document is accomplished in three steps:

  1. Start a job by calling StartJob method of Server object. The method needs the base output document file name as the first parameter:
    P2H.StartJob "C:\outdocs\doc1"
    The first parameter should specify the base output document name without extension. Here P2H is a reference to the Server object. Additional parameters accepted by this method are references to the Profile, BatchProcessingOptions and PrintingPreferences objects similar to ConvertFile or ConvertDir methods. After this call the Print2HTML5 Printer switches to a special "capture" mode at which any print job sent to it will be converted to an HTML5 document.
  2. Send a document to the Print2HTML5 Printer. You need to use special API for printing the documents or creating print jobs as mentioned above. The first print job sent to the Print2HTML5 Printer after StartJob method call will be captured and converted to a Print2HTML5 document file specified as the first parameter of this method. Even a print job initiated manually will be captured.
  3. Complete the job by invoking EndJob method of Server object:
    This call creates an HTML5 document file at the location specified in the StartJob method call earlier. The HTML5 document file name will be "C:\outdocs\doc1.html" (it will also create a document-related resource folder "C:\outdocs\doc1_files"). After this call the Print2HTML5 Printer reverts to normal mode of operation without capturing print jobs. To convert another document, you may use ConvertFile or ConvertDir methods of Server object or start another printing job using StartJob method.

If you called StartJob method and switched Print2HTML5 to capture mode but later decided not to send a document to the printer, you may cancel this mode using CancelJob method. 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 before calling, for example, ConverttFile method.


The following example demonstrates using printing jobs. It starts a job, sends a PowerPoint document to the Print2HTML5 Printer using PowerPoint Automation API setting some printing options and finally completes the job. After this code execution is completed, an output HTML5 document should be created from the printed PowerPoint document at the location specified in the StartJob method call, i.e. HTML5 file will be written to "c:\outdocs\doc1.html" file and "C:\outdocs\doc1_files" folder.

Set P2H = CreateObject("Print2HTML5.Server")
P2H.StartJob "c:\outdocs\doc1"

Set PowerPoint = CreateObject("PowerPoint.Application") ' Launch MS PowerPoint
PowerPoint.Visible = true
Set Presentation = PowerPoint.Presentations.Open("c:\docs\doc1.ppt", true) ' Open a presentation
Presentation.PrintOptions.ActivePrinter = "Print2HTML5 5 Printer" ' Set active printer
Presentation.PrintOptions.FitToPage = true ' Make slides fill the full page area
Presentation.PrintOptions.PrintInBackground=False ' Turn off background printing
Presentation.PrintOut ' Send the document to the printer
Presentation.Close ' Close the presentation
PowerPoint.Quit ' Close MS PowerPoint