Newsletter Archives - February, 2005

Volume 10. Issue 2

What's Inside?

New ASP Printer Driver Sample

New Fax C++/ActiveX User Strings

AutoPrint and BatchConverter Samples Enhanced PDF Printing

Simplified Image printing with Black Ice Imaging Toolkits

New ASP Printer Driver Sample

Version 9.02 of the Black Ice printer drivers included a new ASP printing sample which demonstrates dynamic, on demand PDF generation and distribution.

The last few years have seen a dramatic growth in internet usage, both for home users as well as corporate employees.  This growth is mainly due to two factors, the increased access to broadband internet access as well as the expansion of many business and service providers expanding their offerings to become available through the world wide web.

From this rise in internet activity, more and more information is being supplied, tracked and presented to users, including bank records, bills and other personal information.  Typically this information is requested by a client through a web service.  The web service will then retrieve the requested data from one or more sources and the n return the data set to the requesting user.  One of the most popular methods to perform this kind of processing is by using Active Server Pages (ASP), which can present the requested data to the user.  But what if the user wants to store a copy of the results on their local PC for later review or to have the information faxed to a recipient?  This is where the Black Ice printer drivers come into play

The Black Ice printer drivers can be used to convert any printjob sent to them and convert that information into a variety of file formats, including TIFF, JPEG, PDF etc.   For web based applications where the desired end result is to provide the user with a downloadable or faxable result, developers can use the Black Ice printer drivers along with a variation of the included ASP printing sample to accomplish this goal.

The new ASP Printing sample for the Black Ice printer drivers will print a text file to the Black Ice printer driver to be converted into a PDF file.  The ASP sample uses a new Print Wrapper Capture OCX specifically created for ASP environments and will wait for the EndDoc event to be received by the new OCX before proceeding.  Once the EndDoc event is received, the newly generated PDF file will be displayed in the browser.

The new ASP Printing sample is written to be used with the Black Ice PDF (Demo) printer driver. In order for the sample to be used with a different Black Ice Printer Driver developers should modify the printer name in the ASP source code.

In order to print from ASP, the specified printer MUST be the Default printer on the system.  For details, developers should refer to the following link which contains a description of an issue where COM Objects Fail to Print When Called From ASP: http://support.microsoft.com/?id=184291

The Black Ice printer must be configured to generate the output files into the ASP home directory, to allow for displaying of the PDF files on the client side.

To set the Output Directory used by the Black Ice printer driver, right click on the Black Ice PDF printer, select Printing Properties\Advanced TAB\Printing Defaults, and specify the full path to the output directory.

As mentioned above, the new ASP Printing sample includes a new Print Wrapper OCX specifically created for use with ASP environments.  The RTK includes source for the new OCX written in both Visual Basic and C++.

Anatomy of the New ASP Printer Driver Sample

In a nutshell, the ASP printing sample performs the following steps:

1. Initializes the messaging interface.  The ASP Printing sample utilizes the new PrintWrapper OCX to capture messages and notify the ASP script when printing has completed:
iRet = PrintWrapper1.StartCapture("Black Ice PDF (Demo)")

2. Prints the text file to the Black Ice printer driver:
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "notepad.exe", path, "", "open", 0
Set objShell = Nothing

3. Waits for printing to finish and displays the name of the generated file.  Since ASP cannot directly receive and process messages, the new PrintWrapper OCX WaitForEndPrinting will return only when printing has finished:
szFileName = PrintWrapper1.WaitForEndPrinting()
Response.Write("<BR><BR>" & " The name of the printed file on the server: " & szFileName)

4. Retrieves the filename of the generated PDF file from the path:
Set fso = CreateObject("Scripting.FileSystemObject")
m_szFileName = fso.GetFileName(szFileName)

5. Presents the user with the option of viewing the generated PDF file.  In order to display the newly created PDF file, Acrobat Reader must be installed:
<a href=<% = m_szFileName %>>Open PDF File</a>

[page 1]

Next

 
 © Black Ice Software, LLC 1989-2005   Contact Us: 603-673-1019 or Sales@BlackIce.com