Components for Developers & PDF Software → Virual Printer Tutorials

Collecting Multiple Documents

In the first tutorial we created a simple client application. It could only parse virtual printer ini file - nothing more - but this was a required step in the virtual printer's documents processing pipeline. So, we're ready to move on.

In the next tutorials we'll create a more powerful client which will be able to collect files from multiple printed documents into collection and transfer them in a zip archive to a remote machine using ftp or http protocols.

Please take a look at our tutorials roadmap:

Virtual Printer Examples Map

Now we'll implement Part II.

First of all, we need to decide where to store collected files from the virtual printer. The C:\.....Local Settings\Application Data is a good place for them.

Next question: How do we track file names ? Virtual printer files can be named identically. Of course, we could write some function which would scan the target directory for a file name coincidence, but since virtual printer file names do not contain any valuable information, there is no reason to do it this way. Instead, we will use Globally Unique Identifier, or GUID, for the file names in the collection. Since each new GUID is unique, there is no need to track actual file names! (Simpler code is more reliable).

How do we store information about the collection ? There are many ways - XML, text files and so on. But, since the virtual printer stores document information in the INI file, it's convenient to use the same format. We can use existing code to read information from the collection.

 

Collecting Multiple Documents - Implementation

This application will be easy too. It looks like this:

Documents collection application

When you hit the "Add to Collection" button, a file will be transfered from the "Printed document files" area to the "Files in documents collection" listbox and will be copied to the ..Local Settings\Application Data directory.

Here is a class diagram which shows all the relations between program classes:

Class diagram

A new class here is CollectionManager. It handles all collection-related functions such as manage printed document files and manage INI file.

As a part of its functionality, it generates the GUID. To generate a GUID in C# and VB.NET is very easy:

in C#:

string strGuid = Guid.NewGuid().ToString();

in VB.NET :

Dim strGUID As String = Guid.NewGuid.ToString;

But if you're using VB6, you have to use a special wrapper around the Win32 API function CoCreateGuid. You can find this wrapper in a module GUID.bas

A second VB6 feature is getting full path to the ..Local Settings\Application Data directory.
.NET languages have a special function for this. Here is an example in C#:

string strLocalApplicationData =
	Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

In VB6, you can use the wrapper around the Win32 API function SHGetSpecialFolderPath. You can find it in a module GetSpecialFolder.bas.

To test, open the solution and select Debug->Start Debugging from the menu. The path to the prepared printer test INI file will be passed to the application by the debugger.

 

Download Collecting Multiple Documents:

Virtual Printer for C#/C++, VB6/VB.NET

Virtual Printer menu

Latest news

December 12 2011
Our driver now supports Windows 8

Send us your comments

We're really eager to hear from you. Please send us your suggestions in one of two ways: