如何通过预览将pdf文件发送到所需的打印机 [英] How to send pdf file to desired printer with preview

查看:142
本文介绍了如何通过预览将pdf文件发送到所需的打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打印带有文档预览和打印对话框的pdf文件,以便按以下顺序为用户选择可用的打印机:



1>使用adobe reader打开pdf或在visual studio中使用printPreviewDialog组件

这样用户可以一眼看看他/她将要打印的内容



2>然后一个printDialog组件自动显示并让用户有机会选择他/她所需的打印机(而不是默认打印机)进行打印过程



3>自动打印后关闭adobe reader或预览组件如果可能





关于任何帮助的问候



我尝试过:



我的代码是:

System.Diagnostics .Process.Start(file);

printDocument1 = new PrintDocument();

printDocument1.DocumentName = file;



printDialog1.Document = printDocument1;

printDialog1.ShowDialog();

i want to print a pdf file with document preview and print dialog box so that gives selection of available printers to user in following order:

1 > open pdf with adobe reader or "printPreviewDialog" component in visual studio
so user can have a glance of what he/she is gonna print

2 > then a "printDialog" component automatically shows up and give user the chance of
selecting his/her desired printer(instead of default printer) for printing process

3 > closing adobe reader or preview component after print automatically "IF POSSIBLE"


regards for any help

What I have tried:

my code is :
System.Diagnostics.Process.Start(file);
printDocument1 = new PrintDocument();
printDocument1.DocumentName = file;

printDialog1.Document = printDocument1;
printDialog1.ShowDialog();

推荐答案

你将不得不寻找和使用第三方库进行打印。 .NET Framework中内置的打印工具对您没有任何帮助,因为它们依赖于您提供呈现每个页面的代码。除非您计划编写自己的PDF解析器和渲染器,否则PrintDocument对您没有任何好处。



您所做的所有代码都是在任何已注册的应用程序中启动PDF文件PDF文件,通常是Acrobat Reader。然后你新推了一个PrintDocument,它与打印PDF文档没什么关系。
You're going to have to find and use a 3rd party library to do the printing. The printing facilities built into the .NET Framework will not do you any good because they rely on YOU to provide the code to render each page. Unless you plan on writing your own PDF parser and renderer PrintDocument will do you no good.

All your code did was launch the PDF file in whatever application is registered to open PDF files, usually Acrobat Reader. Then you new'd up a PrintDocument that has nothing whatsoever to do with printing that PDF document.


这是一个类似的帖子:如何打印文件(到特定打印机)

示例使用一些第三方服务:

用C#打印PDF文件 [ ^ ]

从任何地方渲染和打印PDF文件。 NET应用程序 [ ^ ]
Here is a similar post: How To Print Files (To Specific Printers)
Sample use some 3rd party services:
Print PDF file in C# [^]
Render and print PDF files from any .NET application[^]


这篇关于如何通过预览将pdf文件发送到所需的打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆