如何更改打印机原始数据类型的页面大小. [英] how to change page size for raw data type for a printer.
本文介绍了如何更改打印机原始数据类型的页面大小.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过更新打印机的DEVMODE来更改页面宽度和高度吗?
Can i change the page width and height updating the DEVMODE of a printer.
推荐答案
在调用PrintDlg()时,必须用所需的纸张尺寸填充devmode.或CreateDC().我认为此后无法修改devmode.
如果您以RAW(TEXT)模式进行打印,则可以将devmode传递给OpenPrinter()并进入StartDocPrinter->. StartPagePrinter
想知道为什么要在打印过程中更改页面大小吗?
You must fill the devmode with desired paper sizes on calls to PrintDlg() or CreateDC(). I think there''s no way to modify devmode after this.
In case if you are printing in RAW (TEXT) mode , you can pass in the devmode to OpenPrinter() and proceed to StartDocPrinter -> StartPagePrinter
Wonder why you wish to change page sizes in the middle of printing?
要在打印作业期间更改DEVMODE设置(例如不同的纸盒,纸张尺寸等),您需要重新创建DC,传递不同的DEVMODE结构.如果使用MFC,下面的代码片段可能会给您一些想法:
To change DEVMODE settings during a print job (such as different paper bin, paper size, etc), you need to recreate the DC, passing a different DEVMODE struct. If using MFC, below is a snippet that may give you some ideas:
memcpy(pNewDevMode,pCurDevMode,pCurDevMode->dmSize+pCurDevMode->dmDriverExtra);
pNewDevMode->dmFields = pDevMode->dmFields;
pNewDevMode->dmOrientation = pDevMode->dmOrientation;
pNewDevMode->dmPaperSize = pDevMode->dmPaperSize;
pNewDevMode->dmPaperLength = pDevMode->dmPaperLength;
pNewDevMode->dmPaperWidth = pDevMode->dmPaperWidth;
pNewDevMode->dmScale = pDevMode->dmScale;
pNewDevMode->dmCopies = pInfo->m_pPD->GetCopies();
pNewDevMode->dmDefaultSource = pDevMode->dmDefaultSource;
CString cDevice = pInfo->m_pPD->GetDeviceName();
CString cDriver = pInfo->m_pPD->GetDriverName();
CString cPort = pInfo->m_pPD->GetPortName();
HDC hDC = ::CreateDC((LPCSTR)((const char *)cDriver),
(LPCSTR)((const char *)cDevice),
(LPCSTR)((const char *)cPort),
<big>pNewDevMode</big>);
if (hDC)
{
pDC->EndDoc();
HDC hOldDC = pDC->Detach();
if (hOldDC)
::DeleteDC(hOldDC);
pDC->Attach(hDC);
pDC->SetAbortProc(PrintAbortProc);
DOCINFO docInfo;
ZeroMemory(&docInfo, sizeof(DOCINFO));
docInfo.cbSize = sizeof(DOCINFO);
char caName[31];
strcpy(caName,((const char *)pDoc->GetTitle().Left(30)));
docInfo.lpszDocName = (LPCSTR)caName;
docInfo.lpszOutput = NULL;
if (pDC->StartDoc(&docInfo) == SP_ERROR)
这篇关于如何更改打印机原始数据类型的页面大小.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文