我有一个 C# .NET Framework 控制台应用程序,可以将 PDF 文档发送到指定打印机。 我主要打印到A4打印机和热敏打印机。
这是打印过程的代码片段:
// PdfiumViewer
var pdfViewer = new PdfViewer
{
Document = PdfDocument.Load(filename)
};
// Create the printer settings for our printer
var printerSettings = new PrinterSettings
{
PrinterName = printer,
Copies = (short)1,
};
// Create our page settings with the paper size as the document size.
var pageSettings = new PageSettings(printerSettings)
{
Margins = new Margins(0, 0, 0, 0), // No margins
Color = false,
PaperSize = new PaperSize("Custom PDF Size", pdfViewer.Document.PageSizes[0].Width, pdfViewer.Document.PageSizes[0].Height)
};
// Proceed to print
// Now print the PDF document
using (var document = PdfDocument.Load(filename))
{
using (var printDocument = document.CreatePrintDocument())
{
printDocument.PrinterSettings = printerSettings;
printDocument.DefaultPageSettings = pageSettings;
printDocument.PrintController = new StandardPrintController();
// Print the document
printDocument.Print();
}
}
我只打印单页文档。打印到 A4 打印机效果很好。 打印到热敏打印机 (Star TSP100) 总是会产生不清晰/模糊的收据。您可以在下面看到文档和打印输出之间的差异。
PDF 文档的页面尺寸为 3.78 x 7.92 英寸。
使用 A4 打印机打印相同的 PDF 会生成非常清晰的文档。
我只是想知道为什么收据不清楚。有什么可能的修复方法吗?
我尝试将 PDF 转换为收据位图,然后打印 - 结果更糟。输出更不清楚