打印文档转到状态为打印的打印后台打印,但它不使用原始打印 nuget 包 C# 打印文档



>我正在使用 rawprint nuget 包 C# 实现没有打印对话框的打印文档

当我使用打印对话框打印word文档时,它会添加到状态为"正在打印"的打印队列中并成功 打印文档。

当我使用 rawprint nuget 包 C# 打印带有"打印机名称"和 FilePath 的 PDF 文档时,它会添加到状态为"正在打印"但打印机没有打印输出的打印队列中。

我的代码示例在下面给出

public void printPDF(string printerName)
{
// Absolute path to your PDF to print (with filename)
string combinedPdf = new UrlHelper(System.Web.HttpContext.Current.Request.RequestContext).Content("~/temp/") + "conbined_5248422286163515789.pdf";
// The name of the PDF that will be printed (just to be shown in the print queue)
string Filepath = System.Web.HttpContext.Current.Server.MapPath(combinedPdf);
if (System.IO.File.Exists(Filepath))
{
string Filename = "conbined_5248422286163515789.pdf";
// The name of the printer that you want to use
// Note: Check step 1 from the B alternative to see how to list
// the names of all the available printers with C#
string PrinterName = printerName;
// Create an instance of the Printer
IPrinter printer = new Printer();
// Print the file
printer.PrintRawFile(PrinterName, Filepath, Filename);
}
}

请帮助和建议。

string Filepath = @"\YOURSERVERPATHPath" + Label1.Text + "-" + label2.Text + ".pdf";
string Filename = label1.Text + "-" + Label2.Text + ".pdf";
string PrinterName = @"\server01Print-11"; //Adress of the Printer with name!
// Create an instance of the Printer
IPrinter printer = new Printer();
// Print the file:
printer.PrintRawFile(PrinterName, Filepath, Filename);

最新更新