我正在使用PrintDocument Library打印收据在Windows服务中,但它显示打印机并且无法正常工作或打印任何内容, 但如果我在控制台应用程序中使用相同的代码,它的工作正常没有任何问题 这是我的代码:
public void PrintReceiptForTransaction()
{
PrintDocument recordDoc = new PrintDocument();
recordDoc.DocumentName = "Customer Receipt";
recordDoc.PrintPage += new PrintPageEventHandler(PrintReceiptPage); // function below
recordDoc.PrintController = new StandardPrintController(); // hides status dialog popup
// Comment if debugging
PrinterSettings ps = new PrinterSettings();
recordDoc.PrinterSettings = ps;
recordDoc.Print();
recordDoc.Dispose();
}