I use the following codes to print text(raw data) using writeprinter API function.I can open the printer using open printer method but startDocPrinter returns zero.
Please guide me to print raw data.Thanks in advance
Coding:
HANDLE hPrinter;
DOC_INFO_1 DocInfo;
QString e="RAW";
wchar_t *we = new wchar_t[e.size()+1];
e.toWCharArray(we);
QString d="D:/prabha.txt";
wchar_t *wd = new wchar_t[d.size()+1];
d.toWCharArray(wd);
DocInfo.pDatatype = we;
DocInfo.pDocName = wd;
DocInfo.pOutputFile = NULL;
DWORD written = 0;
QString p="Epson";
wchar_t *wp = new wchar_t[p.size()+1];
p.toWCharArray(wp);
LPTSTR PrinterName=wp;
LPBYTE lpData;
bool bStatus=OpenPrinter(PrinterName,&hPrinter,NULL);
if(bStatus==true)
QMessageBox::about(0,"","status=true");
int ret=StartDocPrinter(hPrinter,1,(LPBYTE)&DocInfo);
QMessageBox::about(0,"ret=",QString::number(ret));
StartPagePrinter(hPrinter);
WritePrinter(hPrinter,lpData,10,&written);
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
ClosePrinter(hPrinter);
Bookmarks