Develop Printer Driver which can Read file and Write extra data

375 views Asked by At

I need to develop a printer driver which can:-

  1. Read the printed file (knowing the data inside the file)
  2. Write extra information to the end of printed file. (eg. bar-code or QR code)

I plan to use V4 printer driver as template for me to start my development. I already tried to built this V4 printer driver in Visual Studio.

V4 printer driver solution explorer

Understanding the architecture of V4 printer driver may need lot of times. Besides that, I am still new in driver development, so it is hard for me to understand the document provided by Microsoft.

Can anyone suggest where should I start to code and recommend me any useful method/function or library. It will be useful if anyone can recommend some useful related reading material and what basic knowledge should I know.

1

There are 1 answers

0
amirfg On

See the Microsoft sample code here.

Create a "Render Filter" project (C++ project) in your "V4 Printer Driver" solution and add the sample code in "StartOperation_throws" method of newly created Render Filter.

Then use following sample code to add a custom content to your file:

XPS_COLOR testColor;

testColor.value.sRGB.alpha=0xFF;
testColor.value.sRGB.red=0xFF;
testColor.value.sRGB.green=0xFF;
testColor.value.sRGB.blue=0xFF;
testColor.colorType = XPS_COLOR_TYPE_SRGB;

FLOAT Font_Size = 14;
XPS_POINT OrgPoint = {123,123};
LPCWSTR TestStr = _T("Sample Text");
LPCWSTR Name_fnt = _T("SampleFontFile.TTF");

at the end, call "AddCustomTextToXpsDoc" using above parameters to add your text in printable xps file.