我正在用c#编写打印应用程序。在我的应用程序中,我完成了以下步骤
完成所有这些步骤后,打印不会受到影响。我想问一下印刷应该是自己的 在所有这些步骤之后还是我需要通过其他方法触发它?
以下是源代码,其中CardPrinterLib是我导入gdi32.dll并映射其功能的类
IntPtr hdc = IntPtr.Zero;
hdc = CardPrinterLib.CreateDC(null, ps.PrinterName, null, IntPtr.Zero);
CardPrinterLib.DOCINFO docinfo = new CardPrinterLib.DOCINFO();
docinfo.cbSize = Marshal.SizeOf(docinfo);
docinfo.pDocName = "PrinterTest";
docinfo.pOutputFile = null;
docinfo.pDataType = null;
docinfo.fwType = 0;
if (CardPrinterLib.StartDoc(hdc, ref docinfo) > 0)
{
if (CardPrinterLib.StartPage(hdc) > 0)
{
Bitmap bmpFrontCard = (Bitmap)imgFrontCard;
Graphics grFrontCard = this.CreateGraphics();
IntPtr dcFrontCard = grFrontCard.GetHdc();
IntPtr chdcFrontCard = CardPrinterLib.CreateCompatibleDC(dcFrontCard);
CardPrinterLib.SelectObject(chdcFrontCard, bmpFrontCard.GetHbitmap());
Graphics ghdcFrontCard = Graphics.FromHdc(chdcFrontCard);
grFrontCard.ReleaseHdc(dcFrontCard);
IntPtr hhdcFrontCard = ghdcFrontCard.GetHdc();
bool resultFrontCard = CardPrinterLib.BitBlt(hdc, 0, 0, 994, 624, hhdcFrontCard, 0, 0, 13369376);
CardPrinterLib.EndPage(hdc);
}
CardPrinterLib.EndDoc(hdc);
CardPrinterLib.DeleteDC(hdc);