C# 使用不同的打印机托盘打印PDF c
是否有方法打印PDF并选择要以编程方式使用的纸盘 我愿意接受一些建议,比如将PDF转换成不同的格式并从中打印出来 我可以使用PaperSource和PrintDocument打印到正确的纸盘是否可以将PDF转换为这些功能可以理解的格式C# 使用不同的打印机托盘打印PDF c,c#,pdf,printing,C#,Pdf,Printing,是否有方法打印PDF并选择要以编程方式使用的纸盘 我愿意接受一些建议,比如将PDF转换成不同的格式并从中打印出来 我可以使用PaperSource和PrintDocument打印到正确的纸盘是否可以将PDF转换为这些功能可以理解的格式 谢谢。基于从以下内容获取纸盘PaperSource,如果您不介意使用,这应该适合您: public void PrintPdf(string filePath, string printQueueName, PaperSource paperTray) {
谢谢。基于从以下内容获取纸盘PaperSource,如果您不介意使用,这应该适合您:
public void PrintPdf(string filePath, string printQueueName, PaperSource paperTray)
{
using (ManualResetEvent done = new ManualResetEvent(false))
using (PrintDocument document = new PrintDocument())
{
document.DocumentName = "My PDF";
document.PrinterSettings.PrinterName = printQueueName;
document.DefaultPageSettings.PaperSize = new PaperSize("Letter", 850, 1100);
document.DefaultPageSettings.PaperSource = paperTray;
document.OriginAtMargins = false;
using (var rasterizer = new GhostscriptRasterizer())
{
var lastInstalledVersion =
GhostscriptVersionInfo.GetLastInstalledVersion(
GhostscriptLicense.GPL | GhostscriptLicense.AFPL,
GhostscriptLicense.GPL);
rasterizer.Open(filePath, lastInstalledVersion, false);
int xDpi = 96, yDpi = 96, pageNumber = 0;
document.PrintPage += (o, p) =>
{
pageNumber++;
p.Graphics.DrawImageUnscaledAndClipped(
rasterizer.GetPage(xDpi, yDpi, pageNumber),
new Rectangle(0, 0, 850, 1100));
p.HasMorePages = pageNumber < rasterizer.PageCount;
};
document.EndPrint += (o, p) =>
{
done.Set();
};
document.Print();
done.WaitOne();
}
}
}
您是否尝试过在不同的纸张大小上生成PDF文档?您现在使用什么代码生成PDF?您的打印机能理解哪些脚本?我正在使用PDF表单,并使用iTextSharp编辑它,然后保存为PDF,不确定打印机能理解哪些脚本。我认为您需要什么脚本,或者类似的脚本。我怀疑使用正确的打印机脚本工具,您可以通过文件名提取确定要使用的纸盒。例如,“Filename\u big.pdf”和“Filename\u little.pdf”谢谢,我会看看的!你到底想做什么还不清楚,但是如果你使用表单从其他人那里获取输入,那么谷歌表单推到谷歌应用程序脚本是非常棒的。