我尝试打印到XPS打印机(它不是我的默认打印机),但程序打开了一个对话框。 我可以跳过对话吗?这是代码:
pSettings = new PrinterSettings();
pSettings.PrintFileName = "test.xps";
RawPrinterHelper.SendStringToPrinter(pSettings.PrinterName, toSend);
spcn = new StandardPrintController();
printDocument1.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
printDocument1.PrintController = spcn;
printDocument1.PrintPage +=
new PrintPageEventHandler(printDocument1_PrintPage);
printDocument1.Print();
答案 0 :(得分:3)
您可以使用Aspose API在没有对话框的情况下将PDF打印到XPS Aspose API
//Create PdfViewer object and bind PDF file
PdfViewer pdfViewer = new PdfViewer();
pdfViewer.OpenPdfFile("input.pdf");
//Set PrinterSettings and PageSettings
System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();
printerSetttings.Copies = 1;
printerSetttings.PrinterName = "Microsoft XPS Document Writer";
//Set output file name and PrintToFile attribute
printerSetttings.PrintFileName = "C:\\tempfiles\\printoutput.xps";
printerSetttings.PrintToFile = true;
**//Disable print page dialog**
**pdfViewer.PrintPageDialog = false;**
//Pass printer settings object to the method
pdfViewer.PrintDocumentWithSettings(printerSetttings);
pdfViewer.ClosePdfFile();