Often times it is
desirable to create an application using
the Black Ice printer drivers which
generates output files with the same
name as the input files. For example,
printing “Test.doc” to the Black Ice
Printer Driver and getting an output
file called “Test.pdf”.
The Black Ice printer driver supports
seven filename generation methods:
Use the prefix and extension
Prefix and extension from the registry
Prefix and extension from the INI file
Exact filename
Exact filename from the registry
Exact filename from the INI file
Use the document name
In the past, the “Use the document name”
has created some confusion among our
customers. Many developers, when
printing programmatically to the Black
Ice printer, would like to use the file
name of the original printed document as
the file name of the generated image
file. This is not directly possible
since printer drivers are not aware of
the name of the file printed by the
printing application. When a printer
driver prepares the print job, the
printing application can pass a string
to the printer driver specifying the
document name, but in most cases that is
not the same as the actual file name.
|
For example if Word
prints a file called test.doc, the
document name passed by Word to the
printer driver will be “Microsoft Word –
test.doc”.
There are two basic types of printing
involving the Black Ice printer drivers:
Program driven and User driven.
Depending on how the Black Ice printer
driver is receiving print jobs, you will
want to proceed differently to maintain
the same filenames
Program Driven:
1. When printing is done
programmatically, the printing
application knows the name of the file
which is going to be printed. Before
printing, the application must read the
name of the source file.
2. Once you have the name of the source
file, use the BlackIceDEVMODE.dll or
BlackIceDEVMODE.ocx controls to change
the filename generation method to “Use
exact filename” and set the output file
name using the SetImageFileName()
function to the desired file name.
Cutting the extension of the original
file, and replacing it with the file
extension for the current file type can
create the desired file name. Use the
GetFileExtension() function to get the
file extension for the currently used
file format.
Using these simple steps it is possible
to |
create images having the
source document’s name. The Black Ice
Printer Driver RTKs include simple
sample applications which demonstrate
the above steps and can be used as a
starting point for implementing this
functionality in your own application.
User Driven:
Using the custom plug-in functionality
of the Black Ice Printer Drivers,
developers can perform custom actions at
various stages in the printing process.
To maintain the same file names,
developers can do the following:
1. Use the custom plug-in at the
StartDoc phase of printing and call the
GetDocumentNameFromJobInfo function /
method of the BlackIceDevmodeControls to
retrieve the name of the document passed
to the printer by the printing
application.
2. Parse the text string for known
strings added to the file name by the
printing application. Some examples of
how printing applications pass the
document name are available in Figure 1
below.
3. Use the DocumentName function /
method of the Black Ice printer drivers
to set the output filename to the
modified
string.
4. Resume printing
|