I'm using windows spooler API in order to print a simple picture.
In "TEXT" mode, my printer prints the picture as a text like it converts its data to char. So I've to use the "RAW" mode but nothing append in this case.
Here is the code :
void camgl::printShoot() {
HANDLE print_handle;
DOC_INFO_1 docinfo1;
DWORD bytes_written;
docinfo1.pDocName = (LPTSTR)L"Shot.jpg";
docinfo1.pOutputFile = NULL;
docinfo1.pDatatype = (LPTSTR)L"RAW";
BOOL bool1, bool2, bool3, bool4;
bool1 = OpenPrinter((LPTSTR)L"Canon MG6300 series Printer", &print_handle, NULL);
bool2 = StartDocPrinter(print_handle, 1, (LPBYTE)&docinfo1);
bool3 = StartPagePrinter(print_handle);
bool4 = WritePrinter(print_handle, (LPVOID)image->imageData, (DWORD)image->imageSize, &bytes_written);
EndPagePrinter(print_handle);
EndDocPrinter(print_handle);
ClosePrinter(print_handle);
}
The variable "image" is defined like this :
where IplImage is an OpenCV type of image.
I've tried to send a form-feed character to the printer but with no success:
int iFF = 0x0c;
WritePrinter(print_handle, (LPVOID)&iFF, (DWORD)sizeof(iFF), &bytes_written);
In both cases, the print queue displays a job that correspond to the printShoot() method, then the queue is cleared with no error and nothing is print by the printer.
==============
I add this article i've just found :
http://www.codeproject.com/Articles/8916/Printing-Architecture
WritePrinter only supports GDI printing.
Printing JPEG image requires more code. IF it is urgent, you can try to call Command line MS Paint to print the JPEG image
C:\Windows\System32\mspaint.exe C:\image.jpg /p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With