The Following C++ code demonstrates how to change the printer driver setting before printing for File Format, Output directory, and to load a predefined profile.
// Required header files
#include "BlackIceDEVMODE.h"
#include "devmode.h"
// Make sure the right lib is linked, according to your platform (Win32 or x64)
#pragma comment(lib, "BlackIceDEVMODE.lib")
// This function changes a file format and output directory setting of the printer in the specified printer driver
void ChangeSettings(LPCTSTR szPrinterName)
{
// Create a new BlackIceDEVMODE structure and load current printing settings
BlackIceDEVMODE* pDevMode = LoadBlackIceDEVMODE((LPTSTR)szPrinterName);
// Set filename generation method to "Document Name" and set the output directory
SetFileGenerationMethod(FILENAME_DOCUMENT_NAME, pDevMode);
SetOutputDirectory(_T("<<USERPROFILE>>\\Documents"), pDevMode);
// Set output file format to "Vector PDF"
SetFileFormat(FFR_VECTOR_PDF, pDevMode);
// Apply the new settings and release the BlackICeDEVMODE structure
SaveBlackIceDEVMODE((LPTSTR)szPrinterName, pDevMode);
ReleaseBlackIceDEVMODE(pDevMode);
}
// This function loads a profile into the specified printer
void LoadProfile(LPCTSTR szPrinterName, LPCTSTR szProfileName)
{
// Create a new BlackIceDEVMODE structure and load current printing settings
BlackIceDEVMODE* pDevMode = LoadBlackIceDEVMODE((LPTSTR)szPrinterName);
// Load a printer driver profile.
// Settings that are stored in the registry get applied immediately,
// settings that are stored in the BlackIceDEVMODE structure get loaded to pDevMode
// and get applied when we call SaveBlackIceDEVMODE
ApplyProfile(szPrinterName, szProfileName, pDevMode);
// Apply the new settings and release the BlackICeDEVMODE structure
SaveBlackIceDEVMODE((LPTSTR)szPrinterName, pDevMode);
ReleaseBlackIceDEVMODE(pDevMode);
}
// Change some of the printer settings.
ChangeSettings(_T("Black Ice ColorPlus"));
// Or load one of the profiles.
// To load a printer profile, the sample must be compiled to the same
// platform as the printer driver, so for 64 bit systems, set the platform to x64
LoadProfile(_T("Black Ice ColorPlus"), _T("Documents PDF"));