[英]C++ Printing: Printer jams, what am I doing wrong?
I have a problem with printing in C++. 我在C ++中打印时遇到问题。 As far as I know, this code used to work on my previous printer, but ever since I got another one (an HP C7280) it started giving problems.
据我所知,该代码曾经可以在我以前的打印机上使用,但是自从我买到另一台(HP C7280)以来,它开始出现问题。 Whenever I try to print anything, even an empty page, the page JAMS the printer.
每当我尝试打印任何内容(甚至是空白页)时,该页面都会干扰打印机。 I have to manualy remove the page from the printer.
我必须手动从打印机上删除页面。 I have no clue why this is happening.
我不知道为什么会这样。 Am I doing something wrong, is it a driver problem, are there better ways to print in C++?
我做错什么了吗,这是驱动程序问题,是否有更好的C ++打印方式? I am using Windows 7 64 bit, but this problem also presented itself when I was using Windows Vista 64 bit.
我使用Windows 7 64位,但是当我使用Windows Vista 64位时,也会出现此问题。 I use the following code:
我使用以下代码:
PRINTDLG pd;
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hwndOwner = mainWindow;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
pd.nCopies = 1;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
if (PrintDlg(&pd)==TRUE)
{
DOCINFO di;
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "Rumitec en Roblaco Print";
di.lpszOutput = (LPTSTR)NULL;
di.fwType = 0;
// Start printing
StartDoc(pd.hDC, &di);
StartPage(pd.hDC);
initPrinter(pd.hDC);
// ...
// Do some drawing
// ...
// End printing
EndPage(pd.hDC);
EndDoc(pd.hDC);
DeleteDC(pd.hDC);
}
Am I doing something wrong? 难道我做错了什么? Alternatively, is there a better, easier, more modern way to do it?
或者,是否有更好,更轻松,更现代的方式来做到这一点?
EDIT: I can print from ANY other application without paper jams. 编辑:我可以从任何其他应用程序打印而不会卡纸。 Notepad, Word, etc, every other application can print just fine.
记事本,Word等,其他所有应用程序都可以正常打印。
I think that you CAN cause a printer jam with software. 我认为您可能会导致打印机卡纸。 Just print right to the edges - which not many apps do - and you could easily uncover a printer hardware/driver issue where printing near an edge cause the head to jam into the paper.
只需直接打印到边缘即可-很少有应用程序会这样做-您可以轻松发现打印机硬件/驱动程序问题,其中边缘附近的打印会导致打印头卡在纸张中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.