Dev Direct Solution Center

For more information and to buy this product...

Using Black Ice BiAutoPrint control for converting HTML or DOC documents to PDF

  For a copy of the sample project please click here to download and install the product evaluation.

Introduction

In this article we will describe how you can convert DOC files to PDF programmatically using Black Ice BiAutoPrint control and Black Ice PDF printer driver. As of today Black Ice printer drivers are not supporting conversion into DOC format, but using BiAutoPrint control HTML files can also be converted to PDF.

Detail

The BiAutoPrint.dll and BiAutoPrint.ocx collects methods for converting several file formats. You can use BiAutoPrint in all programming language where you are able to call methods from a dynamic link library or ActiveX control (for example C++, C#, Visual Basic, J#).

The BiAutoPrint supports many file types, for example xls, doc, pdf, html, ppt, pps, rtf, txt, dwg, etc.

How conversion works?

The BiAutoPrint prints the selected document to Black Ice printer driver. If you have a Black Ice PDF printer driver installed on your machine you can convert your documents to PDF easily. If you select a Microsoft Word document the BiAutoPrint converts it using COM objects. It looks like the BiAutoPrint opens your document with Microsoft Word and prints it. This printing happens automatically in the background, but the Microsoft Office (2000 or later) has to be installed on your machine.

In case you are converting HTML documents to PDF BiAutoPrint converts them with the help of the default web browser (e.g. Internet Explorer). The actual output will look like as if printed from the browser.

How you can use the BiAutoPrint?

The following code snippets demonstrate you how the BiAutoPrint can be used.

There are 4 easy steps for using the ocx:

1. Use BIAPInitialize method for initializing BiAutoPrint.ocx.

2. Use BIAPStartprinting method for printing the specified document to the specified printer.

3. Use the BIAPEndPrinting method for closing the document printed.

4. After finishing all printings use the BIAPUnInitialize method for uninitializing the BiAutoPrint.ocx.

Following is an example of a Visual Basic code snippet. Delphi, C#, J#, C++ sample applications are also available in the RTK.

Visual Basic
Private BiAutoPrint As BIAUTOPRINTLib.BiAutoPrint ' Initialize BiAutoPrint control BiAutoPrint = New BIAUTOPRINTLib.BiAutoPrint() ' Call init method of the BiAutoPrint.ocx BiAutoPrint.BIAPInitialize() ' Printing document ' szPrinter: Name of the printer (for example Black Ice PDF) ' szFileName: Path and name of the document to print If Not BiAutoPrint.BIAPStartPrinting(szPrinter, szFileName) Then MessageBox.Show(BiAutoPrint.BIAPGetErrorString(BiAutoPrint.BIAPLastError), "AutoPrint VB.NET Sample", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If 'Close the printed document If Not BiAutoPrint.BIAPEndPrinting() Then MessageBox.Show(BiAutoPrint.BIAPGetErrorString(BiAutoPrint.BIAPLastError), "AutoPrint VB.NET Sample", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If

Conclusion

This solution shows how we can convert several document types easily using Black Ice BiAutoPrint control. The entire source of the BiAutoPrint.dll and BiAutoPrint.ocx is available in our printer driver resource toolkit (RTK). There are sample applications in several programming languages (C++, C#, Delphi, Visual Basic) in the RTK that demonstrates the usage of BiAutoPrint dll and ocx. If you purchase a Black Ice printer driver, you will get an RTK free. But you can evaluate the demo RTK if you download a Black Ice demo printer driver.

You can download a demo Black Ice PDF printer driver from:

http://www.blackice.com/Printer%20Drivers/PDF%20Printer%20Drivers.htm  

Visit Black Ice Software for more information and more samples.