Normally for conversion of documents using
Print2Flash 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 Print2Flash Printer and convert job output into
a Flash or HTML5 file. This method offers some advantages:
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.
The capturing of a print job into a Print2Flash document is accomplished in three steps:
P2F.StartJob "C:\outdocs\doc1" |
P2F.EndJob |
If you called StartJob method and switched Print2Flash 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 Print2Flash 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 Print2Flash Printer using PowerPoint Automation API setting some printing options and finally completes the job. After this code execution is completed, an output Flash file and an HTML5 document should be created from the printed PowerPoint document at the location specified in the StartJob method call, i.e. Flash file will be written to "c:\outdocs\doc1.swf" file, and HTML5 file - to "c:\outdocs\doc1.html" file and "C:\outdocs\doc1_files" folder.
Set P2F = CreateObject("Print2Flash5.Server") P2F.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 = "Print2Flash 3 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 P2F.EndJob |