Click here to Skip to main content
14,669,072 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Blum Blum Shub Pin
David Crow7-Oct-20 7:31
MemberDavid Crow7-Oct-20 7:31 
GeneralRe: Blum Blum Shub Pin
Member 149564757-Oct-20 7:39
MemberMember 149564757-Oct-20 7:39 
GeneralRe: Blum Blum Shub Pin
David Crow7-Oct-20 7:55
MemberDavid Crow7-Oct-20 7:55 
AnswerRe: Blum Blum Shub Pin
Member 149564758-Oct-20 1:36
MemberMember 149564758-Oct-20 1:36 
GeneralRe: Blum Blum Shub Pin
Richard MacCutchan8-Oct-20 2:27
mveRichard MacCutchan8-Oct-20 2:27 
QuestionWritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 6:52
professionalsandford_j29-Sep-20 6:52 
QuestionRe: WritePrinter Fails to Print on Inkjet Printer Pin
David Crow29-Sep-20 16:44
MemberDavid Crow29-Sep-20 16:44 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 22:16
professionalsandford_j29-Sep-20 22:16 
Hi David,

Font selection, font size and condensed printing work with dot matrix printer that support Esc/P.
Unpredictable problems occur when trying to print on Inkjet printers such as:
1. The printer ignores the font type, font size and condensed printing.
2. Both Epson WF-7611 and HP OfficeJet Pro do not accept "RAW" for the data type in "StartDocPrinter" parameter. Epson WF-7611 will only accept "Text", while HP OfficeJet Pro only accept "XPS_XPSS". This means I have to detect what printer to print before assigning the data type.
3. The Win32 Printing API says that calling "EndPagePrinter" will end the current page, but it doesn't work that way.

Thank you.
Sandford


Please refer to the code below:

BOOL testPrint (char dataToPrint []) {
char pName [1024];
DWORD level,
sizeof_pName;
HANDLE hPrinter;
DOC_INFO_1 DocInfo;
DWORD dwJob;
DWORD dwBytesToPrint,
dwBytesPrinted;

sizeof_pName = sizeof(pName);
memset (pName, 0, sizeof(pName));
if (!GetDefaultPrinter(pName, &sizeof_pName)) {
printf ("Fail to GetDefaultPrinter. ");
return FALSE;
}

if(!OpenPrinter (pName, &hPrinter, NULL)) {
printf ("Fail to OpenPrinter [%s]. ", pName);
return FALSE;
}

level = 1;
DocInfo.pDocName = "My Document";
DocInfo.pOutputFile = NULL;
DocInfo.pDatatype = "TEXT";
if((dwJob = StartDocPrinter(hPrinter, level, (LPSTR)&DocInfo)) == 0) {
ClosePrinter (hPrinter);
printf ("Fail to StartDocPrinter [%s]. ", pName);
return FALSE;
}

if(!StartPagePrinter (hPrinter)) {
EndDocPrinter (hPrinter);
ClosePrinter (hPrinter);
printf ("Fail to StartPagePrinter [%s]. ", pName;
return FALSE;
}

dwBytesToPrint = strlen(dataToPrint);
if(!WritePrinter (hPrinter, dataToPrint, dwBytesToPrint, &dwBytesPrinted)) {
EndPagePrinter (hPrinter);
EndDocPrinter (hPrinter);
ClosePrinter (hPrinter);
printf ("Fail to WritePrinter [%s]. ", pName);
return FALSE;
}

if(!EndPagePrinter (hPrinter)) {
EndDocPrinter (hPrinter);
ClosePrinter (hPrinter);
printf ("Fail to EndPagePrinter [%s]. ", pName);
return FALSE;
}

if(dwBytesPrinted != dwBytesToPrint) {
printf ("Fail to print [%s] to [%s]. ", dataToPrint, pName);
return FALSE;
}

if(!EndDocPrinter(hPrinter)) {
ClosePrinter(hPrinter);
printf ("Fail to EndDocPrinter [%s]. ", pName);
return FALSE;
}

ClosePrinter(hPrinter);

return TRUE;
}
QuestionRe: WritePrinter Fails to Print on Inkjet Printer Pin
David Crow30-Sep-20 2:01
MemberDavid Crow30-Sep-20 2:01 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j30-Sep-20 4:54
professionalsandford_j30-Sep-20 4:54 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
Gerry Schmitz29-Sep-20 18:33
mveGerry Schmitz29-Sep-20 18:33 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 22:23
professionalsandford_j29-Sep-20 22:23 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
mo149230-Sep-20 8:55
Membermo149230-Sep-20 8:55 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j30-Sep-20 12:05
professionalsandford_j30-Sep-20 12:05 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
mo14921-Oct-20 1:18
Membermo14921-Oct-20 1:18 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j1-Oct-20 2:53
professionalsandford_j1-Oct-20 2:53 
QuestionCopying to ClipBoard By using SendInput, Failure....[Solved] Pin
EuiyongYun28-Sep-20 14:37
MemberEuiyongYun28-Sep-20 14:37 
AnswerRe: Copying to ClipBoard By using SendInput, Failure.... Pin
Victor Nijegorodov28-Sep-20 22:59
MemberVictor Nijegorodov28-Sep-20 22:59 
GeneralRe: Copying to ClipBoard By using SendInput, Failure.... Pin
EuiyongYun29-Sep-20 2:50
MemberEuiyongYun29-Sep-20 2:50 
GeneralRe: Copying to ClipBoard By using SendInput, Failure.... Pin
Victor Nijegorodov29-Sep-20 7:22
MemberVictor Nijegorodov29-Sep-20 7:22 
QuestionHow do I convert my C++ function pointer to a C function pointer? Pin
arnold_w28-Sep-20 5:06
Memberarnold_w28-Sep-20 5:06 
AnswerRe: How do I convert my C++ function pointer to a C function pointer? Pin
Richard MacCutchan28-Sep-20 5:54
mveRichard MacCutchan28-Sep-20 5:54 
AnswerRe: How do I convert my C++ function pointer to a C function pointer? Pin
CPallini28-Sep-20 6:07
mveCPallini28-Sep-20 6:07 
GeneralRe: How do I convert my C++ function pointer to a C function pointer? Pin
arnold_w28-Sep-20 7:33
Memberarnold_w28-Sep-20 7:33 
AnswerRe: How do I convert my C++ function pointer to a C function pointer? Pin
Mircea Neacsu28-Sep-20 6:14
MemberMircea Neacsu28-Sep-20 6:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.