|
|
[Home] [What's New] [Download] [Pricing & BuyNow] [Tips] [Developer] [FAQ] [Manual] [Screen Shot] [Contacts]
|
Developer>> |
|
Developer |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Printer friendly version of this page This document contains information about Zan Image Printer's configuration options including how to modify options from your application. It also discusses how to print a document to Zan Image Printer from your application. Zan Image Printer uses ini files to store the printer settings. When you alter your preferences within the Zan Image Printer user interface, the ini files are automatically modified and saved. The sections, keywords and values in the ini files used by Zan Image Printer are explained in detail in this document. Two programming models are available to developers including using the Win32 APIs to directly access and modify the INI setting files, and calling the provided command line utilities from their application. This document includes numerous VBScript, VB, Delphi, C/C++, VC.NET/CLI, VB.NET and C# code samples to help you get started quickly! Many users have asked us how to print documents to Zan Image Printer within their applications. Therefore, we have also included many VB, Delphi, C/C++, VC.NET/CLI, VB.NET and C# code examples demonstrating how to automate printing of Word documents, Excel sheets, HTML files and other shell printable documents programmatically. The provided command line utilities zvprtcfg and zvprtcfg_win32 even support some batch/script printing commands so you can automatically print your files (Excel, Word, HTML, PDF and other shell printable documents). There are also examples of how to print entire subfolders of documents which turns Zan Image Printer into a powerful batch document converter.
Zan Image Printer will add an uninstall registry entry under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\zvprt50 after it is installed. You can query this uninstall registry entry (value data is C:\Program Files\zvprt50\uninstall.exe, for example) to determine Zan Image Printer's installation folder. For the VB, Delphi, C/C++, VC.NET, VB.NET and C# code samples on how to determine the Zan Image Printer's installation folder, check the "programmatically call zvprtcfg_win32" code sample. It provides a function GetZanInstallFolder which demonstrates how to query Zan Image Printer's installation folder. Tip: The easiest way to see where the program files are located on your computer is to go to the Program Information page. All Zan Image Printer specific settings are saved in ini setting files stored in CSIDL_APPDATA\zvprt50\[printername] (or CSIDL_COMMON_APPDATA if all users share the same settings), where CSIDL_APPDATA(0x001a) identifies the file system directory that serves as a common repository for application-specific data. For example, if current user is administrator, and the printer name is Zan Image Printer(bw), a typical path to the ini setting files for this printer is C:\Documents and Settings\Administrator\Application Data\zvprt50\Zan Image Printer(bw), or C:\Documents and Settings\All Users\Application Data\zvprt50\Zan Image Printer(bw) if all users share the same settings. Tip: If you want all users to use the same printer settings, install Zan Image Printer with the "All users share the same settings" option enabled. The easiest way to see where the ini setting files are located on your computer is to go to the Program Information page. Running the command line utility zvprtcfg with -show switch will also display the current ini files folder (Configuration Directory): C:\Program Files\zvprt50>zvprtcfg zan image printer(bw) -show Build Datetime=May 1 2008, 08:49:23 File Version=5, 0, 4, 1 OS Name=Microsoft Windows XP Professional x64 Edition OS Version=5.02.3790 Service Pack 1 Windows Directory=C:\WINDOWS System Directory=C:\WINDOWS\system32 Printer Driver Directory=C:\WINDOWS\system32\spool\DRIVERS\x64 Configuration Directory=C:\Documents and Settings\Administrator\Application Data \zvprt50\zan image printer(bw) Printer GPD File=C:\WINDOWS\system32\spool\DRIVERS\x64\3\zvprt2.gpd Debug Logging=Disabled Windows environment variables: [%ALLUSERSPROFILE]=C:\Documents and Settings\All Users [%APPDATA]=C:\Documents and Settings\Administrator\Application Data [%TEMP]=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp [%TMP]=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp [%USERDOMAIN]=ZAN-PMLGRLABUJT [%USERNAME]=Administrator [%USERPROFILE]=C:\Documents and Settings\Administrator [%windir]=C:\WINDOWS Parameters(keyword-value pairs) for zan image printer(bw): save.folder=E:\test\ save.basefilename=[%DocName] save.filenameindex=1 save.filexistact=1 save.popupdialog=2 VB code sample:
Option Explicit
Private Declare Function SHGetFolderPath Lib "shell32" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
'Used CSIDL values.
'For the full list, search MSDN for "CSIDL Values"
Private Const CSIDL_APPDATA As Long = &H1A
Private Const CSIDL_PROGRAM_FILES As Long = &H26
Private Const CSIDL_COMMON_APPDATA As Long = &H23
Private Const SHGFP_TYPE_CURRENT = 0
Private Const S_OK As Long = 0
Private Const MAX_PATH = 260
Private Function GetZanPrinterFolder(csidl As Long) As String
Dim sPath As String * MAX_PATH
Dim SpecialFolderPath As String
Dim lResult As Long
sPath = Space$(MAX_PATH)
lResult = SHGetFolderPath(0, _
csidl, _
0, _
SHGFP_TYPE_CURRENT, _
sPath)
SpecialFolderPath = Left$(sPath, _
InStr(sPath, vbNullChar) - 1)
GetZanPrinterFolder = SpecialFolderPath
End Function
Public Sub Main()
Dim IniFileFolder As String
'Use CSIDL_COMMON_APPDATA instead if
'all users share the same settings
IniFileFolder = GetZanPrinterFolder(CSIDL_APPDATA)
If Right$(IniFileFolder, 1) <> "\" Then
IniFileFolder = IniFileFolder & "\"
End If
IniFileFolder=IniFileFolder & "zvprt50\Zan Image Printer(bw)"
End Sub
Delphi code sample: uses Windows, Messages, SysUtils, ShlObj, ShellAPI, SHFolder, Graphics; procedure GetZanPrinterFolder(var APath: String); implementation //get the zan INI setting files folder //for bw printer procedure GetZanPrinterFolder(var APath: String); begin SetLength(APath, MAX_PATH); FillChar(APath[1], MAX_PATH, 0); //Use CSIDL_COMMON_APPDATA instead if //all users share the same settings SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, PChar(APath)); APath := String (PChar (APath)); if (APath[Length(APath)] <> '\') then begin APath := APath + '\'; end; APath := APath + 'zvprt50\Zan Image Printer(bw)\'; end; C code sample: #include <windows.h> #include <shlobj.h> #include <shlwapi.h> #pragma comment(lib, "shlwapi.lib") char szPath[MAX_PATH]; HRESULT hr; //Use CSIDL_COMMON_APPDATA instead if //all users share the same settings hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath); PathAddBackslash(szPath); strcat(szPath, "zvprt50\\Zan Image Printer(bw)"); VC.NET code sample:
using namespace System;
String^ strPath;
//Use Environment::SpecialFolder::CommonApplicationData instead if
//all users share the same settings
//strPath = Environment::GetFolderPath
//(Environment::SpecialFolder::CommonApplicationData);
strPath = Environment::GetFolderPath
(Environment::SpecialFolder::ApplicationData);
if(!strPath->EndsWith(L"\\")) strPath = String::Concat(strPath, L"\\");
strPath = String::Concat(strPath, L"zvprt50\\Zan Image Printer(bw)");
VB.NET code sample:
Dim strPath As String
'Use Environment.SpecialFolder.CommonApplicationData instead if
'all users share the same settings
'strPath = Environment.GetFolderPath
'(Environment.SpecialFolder.CommonApplicationData)
strPath = Environment.GetFolderPath _
(Environment.SpecialFolder.ApplicationData)
If Not strPath.EndsWith("\") Then
strPath = String.Concat(strPath, "\")
End If
C# code sample:
string strPath;
//Use Environment::SpecialFolder::CommonApplicationData instead if
//all users share the same settings
//strPath = Environment::GetFolderPath
//(Environment::SpecialFolder::CommonApplicationData);
strPath = Environment::GetFolderPath
(Environment::SpecialFolder::ApplicationData);
if(!strPath->EndsWith(L"\\")) strPath = String::Concat(strPath, L"\\");
strPath = String::Concat(strPath,
L"zvprt50\\Zan Image Printer(bw)\\save.ini");
Similarly, Call SHGetFolderPath with CSIDL_COMMON_APPDATA(0x0023) and then append zvprt50\[printername] to obtain the ini setting files folder if all users share the same settings. Debug Logging for troubleshooting Zan Image Printer offers the capability of creating a detailed log file for troubleshooting purposes. For more details, see the Program Information page. multi-threaded printing To achieve multi-threaded printing, you can load balance the print jobs across multiple Zan Image Printer instances(e.g., submit the print job to the printer with the least amount of pending documents). This is because we want to have every Windows Spooler queue printing actively and independently, if all the print jobs went to the same Zan Image Printer, only one job at a time would actually be printed before moving to the next print job in the printer queue. default ini setting files The installation program copies the ini setting files of the first selected printer to your hard disk (the default location is C:\Program Files\zvprt50\default). When a user accesses Zan Image Printer for the first time, Zan Image Printer will copy an initial profile for this user from C:\Program Files\zvprt50\default. combine/merge multiple document types into a single TIFF/PDF file Zan Image Printer can combine/merge multiple document types into a single TIFF/PDF file. Use the following steps to accomplish this: 1. On the Save page, specify a fixed file name of your choice, such as document:
create faxable TIFF files A faxable file is a monochrome image file in TIFF format. Zan Image Printer can be setup to create faxable TIFF files. With this capability, anything you can print can be converted into a fax compatible file. Use the following steps to create faxable TIFF: 1. Review your faxing hardware and software's specification to determine the required TIFF parameters so that you can configure Zan Image Printer to match. If you have a sample TIFF file and wish to determine the values of the tags in the header, you can download AsTiffTagViewer, it is a free TIFF Tag Viewer for Windows. 2. During the setup, configure the selected printer to only support 204 x 196(204 x 98) DPI and A4(or Letter) paper size, set the default Color to Black & White mode. The TIFF Class F suggests that the <98, 100>, <196, 200>, <200, 204> DPI resolution values may be treated as being equivalent, so you can also set the supported DPI to 200 x 200(200 x 100) depending on your requirements. 3. After the Zan Image Printer is installed, on the Image->TIFF tab, set the "RowsPerStrip" to "Each page as a single strip". If your fax application requires LSB-to-MSB(FillOrder=2) bit order, check the "Reverse bit order" option. The vast majority of facsimile products store data LSB first (FillOrder=2, LSB-to-MSB). Use CCITT Group 4 compression whenever permitted by your faxing hardware and software, since CCITT Group 4 compression will usually offer a better compression ratio than CCITT Group 3.
Check the "Place Image File Directory (IFD) in front of image data" option if your fax application requires that the TIFF image file descriptor (IFD) header precede the actual TIFF data (e.g. Cisco fax-enabled routers).
All Zan Image Printer specific options are grouped in several ini files, you can edit ini files manually with any plain text editor(Notepad for example), developers can also call Win32 APIs(GetPrivateProfileString, GetPrivateProfileInt, WritePrivateProfileString) to read or write these ini files directly to control the printer's behavior programmatically. ini files:
Settings in save.ini The AppName specifies the name of the section containing the key name, AppName is the first parameter to be passed when calling the GetPrivateProfileString, GetPrivateProfileInt and WritePrivateProfileString Win32 APIs. KeyName specifies the name of the key whose associated string is to be retrieved. KeyName is the second parameter to be passed when calling the GetPrivateProfileString, GetPrivateProfileInt and WritePrivateProfileString Win32 APIs. All the data is stored either as a string or as a DWORD(32-bit integer). The fourth column "Command Line Utility KeyName" specifies the keyname used by the command line utilities zvprtcfg and zvprtcfg_win32. The table below lists all of the supported settings in save.ini.
The following code samples explain how you can retrieve the save folder and popup dialog option , and how to change the file name and when file exists option. VB code sample:
Option Explicit
Private Declare Function SHGetFolderPath Lib "shell32" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32.dll" _
Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Declare Function WritePrivateProfileString Lib "kernel32.dll" _
Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Integer
Private Declare Function GetPrivateProfileInt Lib "kernel32.dll" _
Alias "GetPrivateProfileIntA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal nDefault As Integer, _
ByVal lpFileName As String) As Integer
'Used CSIDL values.
'For the full list, search MSDN for "CSIDL Values"
Private Const CSIDL_APPDATA As Long = &H1A
Private Const CSIDL_PROGRAM_FILES As Long = &H26
Private Const CSIDL_COMMON_APPDATA As Long = &H23
Private Const SHGFP_TYPE_CURRENT = 0
Private Const S_OK As Long = 0
Private Const MAX_PATH = 260
Private Function GetZanPrinterFolder(csidl As Long) As String
Dim sPath As String * MAX_PATH
Dim SpecialFolderPath As String
Dim lResult As Long
sPath = Space$(MAX_PATH)
lResult = SHGetFolderPath(0, _
csidl, _
0, _
SHGFP_TYPE_CURRENT, _
sPath)
SpecialFolderPath = Left$(sPath, _
InStr(sPath, vbNullChar) - 1)
GetZanPrinterFolder = SpecialFolderPath
End Function
Public Sub Main()
Dim IniFileFolder As String
Dim SaveFolder As String * MAX_PATH
Dim lngLength As Long
Dim PopupDlgInd As Integer
'get the save.ini file full path.
'Use CSIDL_COMMON_APPDATA instead if
'all users share the same settings
IniFileFolder = GetZanPrinterFolder(CSIDL_APPDATA)
If Right$(IniFileFolder, 1) <> "\" Then
IniFileFolder = IniFileFolder & "\"
End If
IniFileFolder=IniFileFolder & "zvprt50\Zan Image Printer(bw)\save.ini"
lngLength = GetPrivateProfileString("save", "folder", "", _
SaveFolder, MAX_PATH, IniFileFolder)
WritePrivateProfileString "save", "basefilename", _
"[%DocName]_[%Page]", IniFileFolder
PopupDlgInd = GetPrivateProfileInt("save", "popupdialog", _
0, IniFileFolder)
WritePrivateProfileString "save", "filexistact", "1", _
IniFileFolder
End Sub
Delphi code sample:
uses
Windows, Messages, SysUtils, ShlObj, ShellAPI, SHFolder,
Graphics;
procedure GetZanPrinterFolder(var APath: String);
//save.ini read/write
procedure test_saveini();
implementation
//get the zan INI setting files folder
//for bw printer
procedure GetZanPrinterFolder(var APath: String);
begin
SetLength(APath, MAX_PATH);
FillChar(APath[1], MAX_PATH, 0);
//Use CSIDL_COMMON_APPDATA instead if
//all users share the same settings
SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, PChar(APath));
APath := String (PChar (APath));
if (APath[Length(APath)] <> '\') then
begin
APath := APath + '\';
end;
APath := APath + 'zvprt50\Zan Image Printer(bw)\';
end;
//save.ini read/write
procedure test_saveini();
var
saveinifilepath: String;
SaveFolder: String;
PopupDlgInd: Integer;
begin
SetLength(SaveFolder, MAX_PATH);
GetZanPrinterFolder(saveinifilepath);
saveinifilepath := saveinifilepath + 'save.ini';
GetPrivateProfileString('save','folder','',
PChar(SaveFolder),MAX_PATH, PChar(saveinifilepath));
WritePrivateProfileString('save', 'basefilename',
'[%DocName]_[%Page]', PChar(saveinifilepath));
PopupDlgInd := GetPrivateProfileInt('save','popupdialog',
0, PChar(saveinifilepath));
WritePrivateProfileString('save', 'filexistact', '1',
PChar(saveinifilepath));
//use SaveFolder, PopupDlgInd below
end;
C code sample:
#include <shlobj.h>
char szAppData[MAX_PATH];
char szValue[MAX_PATH];
HRESULT hr;
DWORD dwPopupDlg;
//Use CSIDL_COMMON_APPDATA instead if
//all users share the same settings
hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szAppData);
if(szAppData[strlen(szAppData) - 1] != '\\')
{
strcat(szAppData, "\\");
}
strcat(szAppData, "zvprt50\\Zan Image Printer(bw)");
strcat(szAppData, "\\save.ini");
GetPrivateProfileString("save", "folder", "", szValue,
MAX_PATH, szAppData);
WritePrivateProfileString("save", "basefilename",
"[%DocName]_[%Page]", szAppData);
dwPopupDlg = GetPrivateProfileInt("save", "popupdialog",
0, szAppData);
WritePrivateProfileString("save", "filexistact", "1",
szAppData);
VC.NET code sample:
using namespace System;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
// Declare the function that is exported from unmanaged dll:
[DllImport("KERNEL32.DLL")]
extern "C" int _cdecl GetPrivateProfileString(
String^ lpAppName,
String^ lpKeyName,
String^ lpDefault,
StringBuilder^ lpReturnedString,
int nSize,
String^ lpFileName);
[DllImport("KERNEL32.DLL")]
extern "C" bool _cdecl WritePrivateProfileString(
String^ lpAppName,
String^ lpKeyName,
String^ lpString,
String^ lpFileName);
[DllImport("KERNEL32.DLL")]
extern "C" int _cdecl GetPrivateProfileInt(
String^ lpAppName,
String^ lpKeyName,
int nDefault,
String^ lpFileName);
String^ strPath;
//Use Environment::SpecialFolder::CommonApplicationData instead if
//all users share the same settings
//strPath = Environment::GetFolderPath
//(Environment::SpecialFolder::CommonApplicationData);
strPath = Environment::GetFolderPath
(Environment::SpecialFolder::ApplicationData);
if(!strPath->EndsWith(L"\\")) strPath = String::Concat(strPath, L"\\");
strPath = String::Concat(strPath,
L"zvprt50\\Zan Image Printer(bw)\\save.ini");
String^ szValue;
StringBuilder^ tempstr = gcnew StringBuilder(256);
GetPrivateProfileString(L"save", L"folder", L"",
tempstr, tempstr->Capacity, strPath);
szValue = tempstr->ToString();
WritePrivateProfileString(L"save", L"basefilename",
L"[%DocName]_[%Page]", strPath);
int dwPopupDlg = GetPrivateProfileInt(L"save", L"popupdialog",
0, strPath);
WritePrivateProfileString(L"save", L"filexistact", L"1", strPath);
VB.NET code sample:
Imports System.Runtime.InteropServices
Imports System.Text
Imports System
Module Module1
Private Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringW" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As StringBuilder, _
ByVal nSize As Integer, _
ByVal lpFileName As String) As Integer
Private Declare Function GetPrivateProfileInt Lib "kernel32.dll" _
Alias "GetPrivateProfileIntA" _
(ByVal lpApplicationName _
As String, ByVal lpKeyName As String, ByVal nDefault As _
Integer, ByVal lpFileName As String) As Integer
Private Declare Function WritePrivateProfileString Lib "kernel32.dll" _
Alias "WritePrivateProfileStringA" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpString As String, _
ByVal lpFileName As String) As Boolean
Sub Main()
Dim strPath As String
'Use Environment.SpecialFolder.CommonApplicationData instead if
'all users share the same settings
'strPath = Environment.GetFolderPath
'(Environment.SpecialFolder.CommonApplicationData)
strPath = Environment.GetFolderPath _
(Environment.SpecialFolder.ApplicationData)
If Not strPath.EndsWith("\") Then
strPath = String.Concat(strPath, "\")
End If
strPath=String.Concat(strPath, "zvprt50\Zan Image Printer(bw)\save.ini")
Dim szValue As String
Dim tempstr As StringBuilder
tempstr = New StringBuilder(256)
GetPrivateProfileString("save", "folder", "", tempstr, _
tempstr.Capacity, strPath)
szValue = tempstr.ToString()
WritePrivateProfileString("save", "basefilename", _
"[%DocName]_[%Page]", strPath)
Dim PopupDlgInd As Integer
PopupDlgInd = GetPrivateProfileInt("save", "popupdialog", 0, strPath)
WritePrivateProfileString("save", "filexistact", "1", strPath)
End Sub
End Module
C# code sample:
using System.Runtime.InteropServices;
class Program
{
static void Main(string[] args)
{
string strPath;
//Use Environment.SpecialFolder.CommonApplicationData instead if
//all users share the same settings
//strPath = Environment.GetFolderPath
//(Environment.SpecialFolder.CommonApplicationData);
strPath = Environment.GetFolderPath
(Environment.SpecialFolder.ApplicationData);
if (!strPath.EndsWith("\\")) strPath = String.Concat(strPath, "\\");
strPath=String.Concat(strPath,"zvprt50\\Zan Image Printer(bw)\\save.ini");
String szValue;
StringBuilder tempstr = new StringBuilder(256);
GetPrivateProfileString("save", "folder", "",
tempstr, tempstr.Capacity, strPath);
szValue = tempstr.ToString();
WritePrivateProfileString("save", "basefilename",
"[%DocName]_[%Page]", strPath);
uint dwPopupDlg = GetPrivateProfileInt("save", "popupdialog",
0, strPath);
WritePrivateProfileString("save","filexistact","1",strPath);
}
[DllImport("kernel32.dll")]
static extern uint GetPrivateProfileString(string lpAppName,
string lpKeyName, string lpDefault,
StringBuilder lpReturnedString, int nSize, string lpFileName);
[DllImport("kernel32.dll")]
static extern bool WritePrivateProfileString(string lpAppName,
string lpKeyName,
string lpString, string lpFileName);
[DllImport("kernel32.dll")]
static extern uint GetPrivateProfileInt(string lpAppName,
string lpKeyName, int nDefault, string lpFileName);
}
The equivalent command line syntax to set the basefilename to [%DocName]_[%Page] is: zvprtcfg Zan Image Printer(bw) save.basefilename=[%DocName]_[%Page] or: zvprtcfg_win32 Zan Image Printer(bw) save.basefilename=[%DocName]_[%Page] The equivalent command line syntax to set the when file exists option to 1(Auto pick a unique name to prevent collision): zvprtcfg Zan Image Printer(bw) save.filexistact=1 or: zvprtcfg_win32 Zan Image Printer(bw) save.filexistact=1 Settings in image.ini The table below lists all of the supported settings in image.ini.
The following code samples show how to set the fileformat to 2(JPEG), the color type to 3(true color), and then obtain the current compression method. VB code sample:
Option Explicit
Private Declare Function SHGetFolderPath Lib "shell32" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32.dll" _
Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Declare Function WritePrivateProfileString Lib "kernel32.dll" _
Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Integer
Private Declare Function GetPrivateProfileInt Lib "kernel32.dll" _
Alias "GetPrivateProfileIntA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal nDefault As Integer, _
ByVal lpFileName As String) As Integer
'Used CSIDL values.
'For the full list, search MSDN for "CSIDL Values"
Private Const CSIDL_APPDATA As Long = &H1A
Private Const CSIDL_PROGRAM_FILES As Long = &H26
Private Const CSIDL_COMMON_APPDATA As Long = &H23
Private Const SHGFP_TYPE_CURRENT = 0
Private Const S_OK As Long = 0
Private Const MAX_PATH = 260
Private Function GetZanPrinterFolder(csidl As Long) As String
Dim sPath As String * MAX_PATH
Dim SpecialFolderPath As String
Dim lResult As Long
sPath = Space$(MAX_PATH)
lResult = SHGetFolderPath(0, _
csidl, _
0, _
SHGFP_TYPE_CURRENT, _
sPath)
SpecialFolderPath = Left$(sPath, _
InStr(sPath, vbNullChar) - 1)
GetZanPrinterFolder = SpecialFolderPath
End Function
Public Sub Main()
Dim IniFileFolder As String
Dim Compress As Integer
'get the image.ini file full path.
'Use CSIDL_COMMON_APPDATA instead if
'all users share the same settings
IniFileFolder = GetZanPrinterFolder(CSIDL_APPDATA)
If Right$(IniFileFolder, 1) <> "\" Then
IniFileFolder = IniFileFolder & "\"
End If
IniFileFolder=IniFileFolder & "zvprt50\Zan Image Printer(bw)\image.ini"
WritePrivateProfileString "image", "fileformat", "2", IniFileFolder
WritePrivateProfileString "image", "imagecolor", "3", IniFileFolder
Compress = GetPrivateProfileInt("image", "compression", _
0, IniFileFolder)
End Sub
Delphi code sample:
uses
Windows, Messages, SysUtils, ShlObj, ShellAPI, SHFolder,
Graphics;
procedure GetZanPrinterFolder(var APath: String);
//image.ini read/write
procedure test_imageini();
implementation
//get the zan INI setting files folder
//for bw printer
procedure GetZanPrinterFolder(var APath: String);
begin
SetLength(APath, MAX_PATH);
FillChar(APath[1], MAX_PATH, 0);
//Use CSIDL_COMMON_APPDATA instead if
//all users share the same settings
SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, PChar(APath));
APath := String (PChar (APath));
if (APath[Length(APath)] <> '\') then
begin
APath := APath + '\';
end;
APath := APath + 'zvprt50\Zan Image Printer(bw)\';
end;
//image.ini read/write
procedure test_imageini();
var
imginifilepath: String;
dwCompress: Integer;
begin
GetZanPrinterFolder(imginifilepath);
imginifilepath := imginifilepath + 'image.ini';
WritePrivateProfileString('image', 'fileformat',
'2', PChar(imginifilepath));
WritePrivateProfileString('image', 'imagecolor',
'3', PChar(imginifilepath));
dwCompress := GetPrivateProfileInt('image','compression',
0, PChar(imginifilepath));
//use dwCompress below
end;
C code sample:
#include <shlobj.h>
char szAppData[MAX_PATH];
HRESULT hr;
DWORD dwCompress;
//Use CSIDL_COMMON_APPDATA instead if
//all users share the same settings
hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szAppData);
if(szAppData[strlen(szAppData) - 1] != '\\')
{
strcat(szAppData, "\\");
}
strcat(szAppData, "zvprt50\\Zan Image Printer(bw)");
strcat(szAppData, "\\image.ini");
WritePrivateProfileString("image", "fileformat", "2", szAppData);
WritePrivateProfileString("image", "imagecolor", "3", szAppData);
dwCompress= GetPrivateProfileInt("image", "compression", 0, szAppData);
VC.NET code sample:
using namespace System;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
//Declare the function that is exported from unmanaged dll:
[DllImport("KERNEL32.DLL")]
extern "C" int _cdecl GetPrivateProfileString(
String^ lpAppName,
String^ lpKeyName,
String^ lpDefault,
StringBuilder^ lpReturnedString,
int nSize,
String^ lpFileName);
[DllImport("KERNEL32.DLL")]
extern "C" bool _cdecl WritePrivateProfileString(
String^ lpAppName,
String^ lpKeyName,
String^ lpString,
String^ lpFileName);
[DllImport("KERNEL32.DLL")]
extern "C" int _cdecl GetPrivateProfileInt(
String^ lpAppName,
String^ lpKeyName,
int nDefault,
String^ lpFileName);
String^ strPath;
//Use Environment::SpecialFolder::CommonApplicationData instead if
//all users share the same settings
//strPath = Environment::GetFolderPath
//(Environment::SpecialFolder::CommonApplicationData);
strPath = Environment::GetFolderPath
(Environment::SpecialFolder::ApplicationData);
if(!strPath->EndsWith(L"\\")) strPath = String::Concat(strPath, L"\\");
strPath=String::Concat(strPath,L"zvprt50\\Zan Image Printer(bw)\\image.ini");
WritePrivateProfileString(L"image", L"fileformat", L"2", strPath);
WritePrivateProfileString(L"image", L"imagecolor", L"3", strPath);
int dwCompress = GetPrivateProfileInt(L"image", L"compression",
0, strPath);
VB.NET code sample:
Imports System.Runtime.InteropServices
Imports System.Text
Imports System
Module Module1
Private Declare Function GetPrivateProfileInt Lib "kernel32.dll" _
Alias "GetPrivateProfileIntA" _
(ByVal lpApplicationName _
As String, ByVal lpKeyName As String, ByVal nDefault As _
Integer, ByVal lpFileName As String) As Integer
Private Declare Function WritePrivateProfileString Lib "kernel32.dll" _
Alias "WritePrivateProfileStringA" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpString As String, _
ByVal lpFileName As String) As Boolean
Sub Main()
Dim strPath As String
'Use Environment.SpecialFolder.CommonApplicationData instead if
'all users share the same settings
'strPath = Environment.GetFolderPath
'(Environment.SpecialFolder.CommonApplicationData)
strPath = Environment.GetFolderPath _
(Environment.SpecialFolder.ApplicationData)
If Not strPath.EndsWith("\") Then
strPath = String.Concat(strPath, "\")
End If
strPath = String.Concat(strPath, _
"zvprt50\Zan Image Printer(bw)\image.ini")
Dim dwCompress As Integer
WritePrivateProfileString("image", "fileformat", "2", strPath)
WritePrivateProfileString("image", "imagecolor", "3", strPath)
dwCompress = GetPrivateProfileInt("image", "compression", _
0, strPath)
End Sub
End Module
C# code sample:
using System.Runtime.InteropServices;
class Program
{
static void Main(string[] args)
{
string strPath;
//Use Environment.SpecialFolder.CommonApplicationData instead if
//all users share the same settings
//strPath = Environment.GetFolderPath
//(Environment.SpecialFolder.CommonApplicationData);
strPath = Environment.GetFolderPath
(Environment.SpecialFolder.ApplicationData);
if (!strPath.EndsWith("\\")) strPath = String.Concat(strPath, "\\");
strPath = String.Concat(strPath,
"zvprt50\\Zan Image Printer(bw)\\image.ini");
WritePrivateProfileString("image", "fileformat", "2", strPath);
WritePrivateProfileString("image", "imagecolor", "3", strPath);
uint dwCompress = GetPrivateProfileInt("image",
"compression", 0, strPath);
}
[DllImport("kernel32.dll")]
static extern bool WritePrivateProfileString(string lpAppName,
string lpKeyName,
string lpString,
string lpFileName);
[DllImport("kernel32.dll")]
static extern uint GetPrivateProfileInt(string lpAppName,
string lpKeyName,
int nDefault, string lpFileName);
}
zvprtcfg Zan Image Printer(bw) image.fileformat=2 or: zvprtcfg_win32 Zan Image Printer(bw) image.fileformat=2 The equivalent command line syntax to set the imagecolor to 3(True Color): zvprtcfg Zan Image Printer(bw) image.imagecolor=3 or: zvprtcfg_win32 Zan Image Printer(bw) image.imagecolor=3 Settings in general.ini The table below lists all of the supported settings in general.ini.
Settings in docuname.ini The table below lists all of the supported settings in docuname.ini.
Settings in advimage.ini The table below lists all of the supported settings in advimage.ini.
Settings in app.ini The table below lists all of the supported settings in app.ini.
Settings in text.ini The table below lists all of the supported settings in text.ini.
Settings in event.ini When the application wants printing to begin, it first calls the StartDoc function in the printer driver, which signals the beginning of a new document. The process ends when the application calls EndDoc. Each page itself is delimited by a call to StartPage to begin a page and EndPage to end the page. Zan Image Printer can be configured to send a notification to your application when these events occur during the printing process. All events must have unique name(e.g., "Zan Image Printer(bw) SignalPrintDone" or a GUID string such as "{66A568A9-EECE-4695-BE9F-0CF85135E702}"), so that their names won't conflict with any other Zan Image Printer or Windows application. The "Print files programmatically using the ShellExecute Print verb" section contains the VB, Delphi, C, VC.NET, VB.NET and C# code samples on how to wait for the EndDoc event to make sure the print is finished before submitting the next print job.
Settings in message.ini Zan Image Printer can be configured to send messages to your application when the following events occur during the printing process: StartDoc, EndDoc, StartPage, EndPage For a registered window message, the WPARAM value(or dwData in COPYDATASTRUCT structure of WM_COPYDATA message) tells you the printing process status: 100: StartDoc 101: EndDoc 102: StartPage 103: EndPage
Settings in orientation.ini The table below lists all of the supported settings in orientation.ini.
Settings in email.ini The table below lists all of the supported settings in email.ini.
Settings in watermark.ini The table below lists all of the supported settings in watermark.ini. In this table, N stands for a number from 1 to 10.
The command line syntax to add a watermark with the text "hello world" is as follows: zvprtcfg zan image printer(bw) watermark.enable=1 zvprtcfg zan image printer(bw) watermark.watermark_1.enable=1 zvprtcfg zan image printer(bw) watermark.watermark_1.displayname=watermark1 zvprtcfg zan image printer(bw) watermark.watermark_1.type=0 zvprtcfg zan image printer(bw) watermark.watermark_1.watermark=hello world zvprtcfg zan image printer(bw) watermark.watermark_1.size=24 zvprtcfg zan image printer(bw) watermark.watermark_1.position=4 Settings in printerredirection.ini The table below lists all of the supported settings in printerredirection.ini. In this table, N stands for a number from 1 to 10.
Settings in ftp.ini The table below lists all of the supported settings in ftp.ini.
change Paper Size and DPI In the past, we have observed the following problems: Some printing applications will include printer settings(DPI resolution, paper size, etc.) in the document itself and will ignore the current settings in Zan Image Printer; Some applications will always use the highest available DPI resolution for the selected printer, regardless of what is configured in Zan Image Printer; Some printing applications have their own printer settings function("Page Setup", for example) and will ignore the settings you set in Zan Image Printer. These issues are all caused by the printing application and not by Zan Image Printer. One solution to these issues is to restrict the supported DPI/paper size to those that will actually be used by your printing application. You can then print to a printer with only your desired paper size/DPI available. For example, if you need to print at 300 x 300 DPI on Letter paper size, during the setup, you can configure the selected printer to only support 300 x 300 DPI and Letter paper size. In this way, the printing application is forced(restricted) to use 300 x 300 DPI and Letter paper size, i.e., the printing application will not be able to switch from 300 x 300 DPI to 600 x 600 DPI and you will no longer have to worry about the printing application overriding or ignoring Zan Image Printer settings. After Zan Image Printer is installed, you can execute the gpd command provided by the command line utilities zvprtcfg and zvprtcfg_win32 to change the supported DPI and paper size settings. Command line utilities zvprtcfg and zvprtcfg_win32 Although you can call the GetPrivateProfileString, GetPrivateProfileInt and WritePrivateProfileString Win32 APIs to directly access the ini setting files to programmatically control all of the Zan Image Printer specific settings, if you want even easier programmatic control, you can choose to call the command line utilities in your application or script. zvprtcfg is a console mode application, zvprtcfg_win32 is a Win 32 application, but both of them have exactly the same command line syntax and same functionality. The only difference is that zvprtcfg_win32 produces no output and will execute the command silently without any windows appearing. If you want to programmatically control Zan Image Printer in your own application seamlessly, use zvprtcfg_win32. For automatic scripting, use zvprtcfg instead. Command line parameters and explanations: C:\Program Files\zvprt50>zvprtcfg Syntax: zvprtcfg printer keyword=value [-silent] Or: zvprtcfg -help Or: zvprtcfg -examples Or: zvprtcfg printer -show Or: zvprtcfg printer -setdefault Or: zvprtcfg -listprinters Where: printer: printer name. if no printer is specified, the most recently used printer name will be used. silent: do not print out any message on screen show: show the current parameters(keyword-value pairs) for the specified printer examples: show usage examples listprinters: show all installed printer instances setdefault: set the specified printer as the default printer Please note that you can also specify a non Zan Image Printer(FinePrint, or any real printer) for the setdefault keyword. For all other keywords, you must always specify a valid Zan Image Printer name. All the keywords supported by the command line utilities can be found in the fourth column "Command Line Utility KeyName" in the above ini file tables. For example, if you want to change the save folder for Zan Image Printer, from the save.ini table, you find the save.folder in the column "Command Line Utility KeyName", the command line to set the folder to c:\temp will therefore be(assume printer name is Zan Image Printer(bw)): zvprtcfg Zan Image Printer(bw) save.folder=c:\temp or: zvprtcfg_win32 Zan Image Printer(bw) save.folder=c:\temp To run zvprtcfg_win32 programmatically, call the CreateProcess Win32 API with the corresponding command line parameters. The following code samples illustrate how to set the save folder to c:\temp: VB code sample:
Option Explicit
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Declare Function CreateProcess Lib "kernel32" _
Alias "CreateProcessA" _
(ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
lpProcessAttributes As Any, _
lpThreadAttributes As Any, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
lpEnvironment As Any, _
ByVal lpCurrentDriectory As String, _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function SHGetFolderPath Lib "shell32" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const ERROR_SUCCESS = 0
Private Const STANDARD_RIGHTS_READ As Long = &H20000
Private Const KEY_QUERY_VALUE As Long = &H1
Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
Private Const KEY_NOTIFY As Long = &H10
Private Const SYNCHRONIZE As Long = &H100000
Private Const KEY_READ As Long = ((STANDARD_RIGHTS_READ Or _
KEY_QUERY_VALUE Or _
KEY_ENUMERATE_SUB_KEYS Or _
KEY_NOTIFY) And _
(Not SYNCHRONIZE))
Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
Alias "RegOpenKeyExA" _
(ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal ulOptions As Long, _
ByVal samDesired As Long, _
phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
Alias "RegQueryValueExA" (ByVal hKey As Long, _
ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long
'Used CSIDL values.
'For the full list, search MSDN for "CSIDL Values"
Private Const CSIDL_APPDATA As Long = &H1A
Private Const CSIDL_PROGRAM_FILES As Long = &H26
Private Const CSIDL_COMMON_APPDATA As Long = &H23
Private Const SHGFP_TYPE_CURRENT = 0
Private Const S_OK As Long = 0
Const NORMAL_PRIORITY_CLASS = &H20
Private Const MAX_PATH = 260
Function DirExists(ByVal DName As String) As Boolean
Dim sDummy As String
On Error Resume Next
If Right(DName, 1) <> "\" Then DName = DName & "\"
sDummy = Dir$(DName & "*.*", vbDirectory)
DirExists = Not (sDummy = "")
End Function
'Retrieve a file's path
Function GetFilePath(FileName As String) As String
Dim i As Long
For i = Len(FileName) To 1 Step -1
Select Case Mid$(FileName, i, 1)
Case ":"
GetFilePath = Left$(FileName, i)
Exit For
Case "\"
GetFilePath = Left$(FileName, i - 1)
Exit For
End Select
Next
End Function
'detect the zan image printer installation directory
Private Function GetZanInstallFolder() As String
Dim sPath As String
Dim szTmp As String * MAX_PATH
Dim lResult As Long
Dim hKey, dwSize As Long
szTmp = Space$(MAX_PATH)
dwSize = MAX_PATH
'uninstall entry
If RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
"\Software\Microsoft\Windows\CurrentVersion\Uninstall\zvprt50" _
, 0&, KEY_READ, hKey) = ERROR_SUCCESS Then
If RegQueryValueEx(hKey, "UninstallString", _
0&, 0&, ByVal szTmp, dwSize) = ERROR_SUCCESS Then
sPath = Left$(szTmp, _
InStr(szTmp, vbNullChar) - 1)
sPath = GetFilePath(sPath)
If DirExists(sPath) Then
GetZanInstallFolder = sPath
Exit Function
End If
End If
End If
'Assume \Program Files\zvprt50 folder:
lResult = SHGetFolderPath(0, _
CSIDL_PROGRAM_FILES, _
0, _
SHGFP_TYPE_CURRENT, _
sPath)
szTmp = Left$(sPath, _
InStr(sPath, vbNullChar) - 1)
If Right$(szTmp, 1) <> "\" Then
szTmp = szTmp & "\"
End If
szTmp = szTmp & "zvprt50"
GetZanInstallFolder = szTmp
End Function
'run application with given parameters
Private Sub util_CreateProcess(command_line As String)
Dim pInfo As PROCESS_INFORMATION
Dim sInfo As STARTUPINFO
Dim sNull As String
Dim lSuccess As Long
Dim lRetValue As Long
sInfo.cb = Len(sInfo)
lSuccess = CreateProcess(sNull, _
command_line, _
ByVal 0&, _
ByVal 0&, _
1&, _
NORMAL_PRIORITY_CLASS, _
ByVal 0&, _
sNull, _
sInfo, _
pInfo)
lRetValue = CloseHandle(pInfo.hThread)
lRetValue = CloseHandle(pInfo.hProcess)
End Sub
Public Sub Main()
Dim cmdline As String
cmdline = GetZanInstallFolder()
If Right$(cmdline, 1) <> "\" Then
cmdline = cmdline & "\"
End If
cmdline = cmdline & _
"zvprtcfg_win32 Zan Image Printer(bw) save.folder=c:\temp"
util_CreateProcess cmdline
End Sub
Delphi code sample:
uses
Windows, Messages, SysUtils, ShlObj,
ShellAPI, SHFolder, Registry;
procedure util_CreateProcess(ProgramName:String);
procedure GetZanInstallFolder(var APath: String);
procedure zvprtvfg_test();
implementation
//run application with given parameters
procedure util_CreateProcess(ProgramName:String);
var
StartInfo : TStartupInfo;
ProcInfo : TProcessInformation;
CreateOK : Boolean;
begin
FillChar(StartInfo,SizeOf(TStartupInfo),#0);
FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);
CreateOK := CreateProcess(nil,PChar(ProgramName),nil,nil,False,
CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
nil, nil, StartInfo, ProcInfo);
if CreateOK then
begin
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
end
end;
//detect the zan image printer installation directory
procedure GetZanInstallFolder(var APath: String);
var
hkeyStartup: HKEY;
dwSize: DWORD;
begin
dwSize := MAX_PATH;
SetLength(APath, MAX_PATH);
//uninstall entry
if RegOpenKeyEx(HKEY_LOCAL_MACHINE,
'\Software\Microsoft\Windows\CurrentVersion\Uninstall\zvprt50',
0,
KEY_READ,
hkeyStartup) = ERROR_SUCCESS then
begin
if RegQueryValueEx(hkeyStartup,
'UninstallString', nil, nil,
PBYTE(Pchar(APath)),
@dwSize) = ERROR_SUCCESS then
begin
APath := String (PChar(APath));
APath := ExtractFilePath(APath);
end;
//Close the Key, we won't be needing it anymore
RegCloseKey(hkeyStartup);
if DirectoryExists(APath) then Exit;
end;
//Assume \Program Files\zvprt50 folder:
SHGetFolderPath(0, CSIDL_PROGRAM_FILES, 0, 0,
PChar(APath));
APath := String (PChar (APath));
if (APath[Length(APath)] <> '\')
then APath := APath + '\';
APath := APath + 'zvprt50';
end;
procedure zvprtvfg_test();
var
szCmdLine: String;
begin
GetZanInstallFolder(szCmdLine);
if (szCmdLine[Length(szCmdLine)] <> '\')
then szCmdLine := szCmdLine + '\';
szCmdLine := szCmdLine +
'zvprtcfg_win32 Zan Image Printer(bw) save.folder=c:\temp';
util_CreateProcess(szCmdLine);
end;
C code sample:
#include <windows.h>
#include <winspool.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <shellapi.h>
#pragma comment(lib, "shlwapi.lib")
//check if folder exists
BOOL IsFolderExists(char *lpDirectoryName)
{
if(strlen(lpDirectoryName) == 0)
{
return FALSE;
}
DWORD dwFileAttr = GetFileAttributes(lpDirectoryName);
if((dwFileAttr != 0xFFFFFFFF) &&
(dwFileAttr & FILE_ATTRIBUTE_DIRECTORY))
{
return TRUE;
}
else
{
return FALSE;
}
}
//detect the zan image printer installation directory
void GetZanInstallFolder(char *installfolder)
{
/*first, search the registry uninstall key*/
HKEY hkeyStartup;
//uninstall entry
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\zvprt50",
0,
KEY_READ,
&hkeyStartup) == ERROR_SUCCESS)
{
DWORD dwSize = MAX_PATH;
if(RegQueryValueEx(hkeyStartup,
"UninstallString",
NULL,
NULL,
(LPBYTE)installfolder,
&dwSize) == ERROR_SUCCESS)
{
PathRemoveFileSpec(installfolder);
PathAddBackslash(installfolder);
}
/*Close the Key, we won't be needing it anymore*/
RegCloseKey(hkeyStartup);
if(IsFolderExists(installfolder))
{
return;
}
}
//Assume \Program Files\zvprt50 folder:
SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, installfolder);
PathAddBackslash(installfolder);
strcat(installfolder,"zvprt50");
}
BOOL util_CreateProcess(char* command_line)
{
PROCESS_INFORMATION pInfo;
STARTUPINFO sInfo;
ZeroMemory(&sInfo, sizeof(STARTUPINFO));
sInfo.cb = sizeof(STARTUPINFO);
sInfo.lpReserved = NULL;
sInfo.lpReserved2 = NULL;
sInfo.cbReserved2 = 0;
sInfo.lpDesktop = NULL;
sInfo.lpTitle = NULL;
sInfo.dwFlags = 0;
sInfo.dwX = 0;
sInfo.dwY = 0;
sInfo.dwFillAttribute = 0;
sInfo.wShowWindow = SW_SHOW;
BOOL bret = CreateProcess(NULL, command_line, NULL, NULL,
FALSE, 0, NULL, NULL, &sInfo, &pInfo);
CloseHandle(pInfo.hProcess);
CloseHandle(pInfo.hThread);
return bret;
}
char szCmdLine[MAX_PATH];
GetZanInstallFolder(szCmdLine);
PathAddBackslash(szCmdLine);
strcat(szCmdLine,"zvprtcfg_win32 Zan Image Printer(bw) save.folder=c:\\temp");
util_CreateProcess(szCmdLine);
VC.NET code sample:
using namespace System;
using namespace Microsoft::Win32;
using namespace System::IO;
using namespace System::Diagnostics;
//detect the zan image printer installation directory
String^ GetZanInstallFolder(void)
{
String^ installfolder = String::Empty;
RegistryKey ^ rkTest;
//first, search the registry uninstall key:
rkTest = Registry::LocalMachine->OpenSubKey(
L"\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\zvprt50");
if(rkTest)
{
installfolder = rkTest->GetValue(L"UninstallString")->ToString();
rkTest->Close();
if(installfolder->Length)
{
installfolder = Path::GetDirectoryName(installfolder);
DirectoryInfo^ installdir1=gcnew DirectoryInfo(installfolder);
if(installdir1->Exists)
{
return installfolder;
}
}
}
//Assume \Program Files\zvprt50 folder:
installfolder = Environment::GetFolderPath
(Environment::SpecialFolder::ProgramFiles);
if(!installfolder->EndsWith(L"\\"))
installfolder = String::Concat(installfolder, L"\\");
installfolder=String::Concat(installfolder, L"zvprt50");
return installfolder;
}
String^ apppath;
apppath = GetZanInstallFolder();
if(!apppath->EndsWith(L"\\"))
apppath = String::Concat(apppath, L"\\");
apppath=String::Concat(apppath, L"zvprtcfg_win32");
Process::Start(apppath,
L" Zan Image Printer(bw) save.folder=c:\\temp");
VB.NET code sample:
Imports System
Imports Microsoft.Win32
Imports System.IO
Imports System.Diagnostics
Module Module1
'detect the zan image printer installation directory
Function GetZanInstallFolder() As String
Dim installfolder As String
Dim rkTest As RegistryKey
'first, search the registry uninstall key:
rkTest = Registry.LocalMachine.OpenSubKey _
("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\zvprt50")
If Not (rkTest Is Nothing) Then
installfolder = rkTest.GetValue _
("UninstallString").ToString()
rkTest.Close()
If (installfolder.Length > 0) Then
installfolder = Path.GetDirectoryName(installfolder)
Dim installdir1 As DirectoryInfo = _
New DirectoryInfo(installfolder)
If installdir1.Exists Then
Return installfolder
End If
End If
End If
'Assume \Program Files\zvprt50 folder:
installfolder = Environment.GetFolderPath _
(Environment.SpecialFolder.ProgramFiles)
If Not installfolder.EndsWith("\") Then
installfolder = String.Concat(installfolder, "\")
End If
installfolder = String.Concat(installfolder, "zvprt50")
Return installfolder
End Function
Sub Main()
Dim apppath As String
apppath = GetZanInstallFolder()
If Not apppath.EndsWith("\") Then
apppath = String.Concat(apppath, "\")
End If
apppath = String.Concat(apppath, "zvprtcfg_win32")
Process.Start(apppath, _
" Zan Image Printer(bw) save.folder=c:\temp")
End Sub
End Module
C# code sample:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Microsoft.Win32;
using System.IO;
class Program
{
//detect the zan image printer installation directory
static string GetZanInstallFolder()
{
string installfolder = string.Empty;
RegistryKey rkTest;
//first, search the registry uninstall key:
rkTest = Registry.LocalMachine.OpenSubKey(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\zvprt50");
if (rkTest != null)
{
installfolder = rkTest.GetValue("UninstallString").ToString();
rkTest.Close();
if(installfolder.Length > 0)
{
installfolder = Path.GetDirectoryName(installfolder);
DirectoryInfo installdir1=new DirectoryInfo(installfolder);
if (installdir1.Exists)
{
return installfolder;
}
}
}
//Assume \Program Files\zvprt50 folder:
installfolder = Environment.GetFolderPath
(Environment.SpecialFolder.ProgramFiles);
if (!installfolder.EndsWith("\\"))
installfolder = String.Concat(installfolder, "\\");
installfolder=String.Concat(installfolder,"zvprt50");
return installfolder;
}
static void Main(string[] args)
{
string apppath;
apppath = GetZanInstallFolder();
if (!apppath.EndsWith("\\"))
apppath = String.Concat(apppath, "\\");
apppath = String.Concat(apppath, "zvprtcfg_win32");
Process.Start(apppath,
" Zan Image Printer(bw) save.folder=c:\\temp");
}
}
The command line utilities also allow you to change the standard printer settings(paper size, DPI resolution/print quality, orientation, color) in the associated printer GPD(Generic Printer Description) file. You can open the associated GPD file by double clicking the Printer GPD File item in the Program Information dialog. Zan Image Printer is Microsoft Unidrv(Universal printer driver / Unidriver) based. Unidrv allows the creation of a printer-specific minidriver in the form of a GPD file. A GPD file is a text-based file that contains information about the printer features(supported paper size, dpi, orientation, color, etc.) that Unidrv will present in the user interface to allow the user to configure the printer. You can execute the gpd command provided by the command line utilities zvprtcfg and zvprtcfg_win32 to manipulate the printer gpd file. Note that you cannot have a vendor defined paper size(A0, A1, B0(ISO), B0(JIS), B1(ISO), B1(JIS), B2(ISO), B2(JIS), B3(ISO), B3(JIS), B4(JIS), B5(JIS), B6(ISO), F Sheet, Square, etc.) as the only paper size in the GPD file. You need to specify at least one standard paper size such as Letter, A4, Legal, etc. You also need to set the standard paper size as the default.
Some gpd command usage examples: Restrict the supported paper size to Letter and A4, and set the default paper size to Letter: zvprtcfg "Zan Image Printer(bw)" gpd.papersize=Letter,A4:Letter Use default paper size list, and set the default paper size to A4: zvprtcfg "Zan Image Printer(bw)" gpd.papersize=default:A4 Restrict the supported DPI to 200 x 200 and 200 x 100, and set default DPI to 200 x 200: zvprtcfg Zan Image Printer(bw) gpd.dpi=200,200x100:200 Use all group 1 DPI resolutions, and set the default DPI to 300 x 300: zvprtcfg Zan Image Printer(bw) gpd.dpi=group1:300x300 Setprinter- a Windows Server 2003 Resource Kit command line utility Since zvprtcfg and zvprtcfg_win32 only provide limited support of the standard printer settings, you can download Windows Server 2003 Resource Kit and install it on Windows XP/2003. The setprinter.exe(spooler configuration tool) command line utility in this tool kit allows more advanced control over the standard printer settings. Setprinter can run on Windows 2000/XP/2003, after you have installed Windows Server 2003 Resource Kit on XP or 2003, you can copy setprinter.exe to your Windows 2000 system. Running setprinter -show "Zan Image Printer(bw)" 9 from the command prompt will display the following message:
pDevMode=...
dmDeviceName="Zan Image Printer(bw)"
dmSpecVersion=0x0401
dmDriverVersion=0x0500
dmSize=220
dmDriverExtra=592
dmFields="orientation papersize copies defaultsource printquality
lor yresolution ttoption collate formname nup icmmethod icmintent dithertype"
dmOrientation=2
dmPaperSize=90
dmCopies=1
dmDefaultSource=15
dmPrintQuality=300
dmColor=2
dmYResolution=300
dmTTOption=2
dmCollate=1
dmFormName="12x11"
dmNup=1
dmICMMethod=1
dmICMIntent=2
dmDitherType=4294967295
...User interface customization, private labeling The dialog box templates and other resources(bitmap, string table etc) used by Zan Image Printer are stored in zvprtres.dll. By modifying this resource dll, developers can customize the appearance of Zan Image Printer. Developers can customize the user interface by following the steps below: 1. Open the Printers folder(Start > Printers and Faxes), right click on the printer, and click Properties. 2. On the General tab, change the text in the Location/Comment box to your desired text. 3. Download a free resource editor called Resource Hacker. It is only a few hundred kilobytes and does not require installation. Start Resource Hacker by running the ResHacker.exe file, use the File menu to open zvprtres.dll. Select the resources you want to edit from the tree control on the left listing, and edit/view all the text, icons, dialogs and all of the other resources on the right panel. When you are done, Resource Hacker should ask if you want to compile this script(save your changes), answer yes. After you are finished, click Save from the File menu and quit Resource Hacker. If you have installed Microsoft Visual Studio, you can also open zvprtres.dll as a resource file and then edit it: From Visual Studio, choose File/Open, select zvprtres.dll, choose "Open as: Resources" before clicking Open. Extract text from PDF files Zan Image Printer is able to extract text from most documents, but the extracted text from PDF documents will usually be just long strings of '?' instead of the textual data. This may be caused by the following possible reasons: One possible solution is using pdftotext from the xpdf package to directly extract the text from your PDF documents. pdftotext is a command line program that can convert entire PDF documents or individual pages to plain text while maintaining layout. The extracted text can be converted to a wide choice of standard encodings including UTF-8 and ASCII. To install pdftotext: 1. Make a folder on your computer, for example c:\xpdf 2. Go to http://www.foolabs.com/xpdf/download.html, scroll down to "Precompiled binaries" and you will see a paragraph starting with "x86, DOS/Win32", click the Win32 download link in that paragraph and download the file to c:\xpdf, then unzip all the files. Examples (read the accompanying pdftotext.txt file for more usage information): pdftotext filename.pdf, this usage produces a text file (filename.txt) with the same name as the input file. pdftotext filename.pdf -layout layout.txt, this usage produces a text file layout.txt and maintains original physical layout. pdftotext filename.pdf -enc UTF-8, this usage produces a text file in UTF-8 encoding format. Generate a sentinel file after printing finishes The "Generate a sentinel file after printing finishes" option on the Settings->General tab specifies whether or not a sentinel file should be generated. The sentinel file is deleted at the start of each print session, and is recreated in the same folder as the image file after printing is finished. The sentinel file is generated according to the template. The purpose of the sentinel file is to give a printing done(finished) signal to other applications or scripts. This feature is useful for batch processing, a user application can choose to delete the sentinel file before calling Zan Image Printer, then wait for the sentinel file to be generated before starting the next print. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||