[英]VB.net - print pdf file with printer with paper size
I'm building an application which main function is printing .pdf files. 我正在构建一个应用程序,其主要功能是打印.pdf文件。 I searched a lot, and can't find the thing I need, so here is my question.
我搜索了很多东西,却找不到我需要的东西,所以这是我的问题。
I would like to create a method that prints a .pdf file with a selected printer and paper size. 我想创建一种使用所选打印机和纸张尺寸打印.pdf文件的方法。 ( we have a plotter that goes from A0 - A3 drawings ) so a great range off different sizes could be in the batch.
(我们有一个绘图仪来自A0-A3图纸),因此可以批量生产不同尺寸的产品。
Public Sub print_pdf(byval document as string, byval printer as string, byval size as string)
I found this similar post, but.. it's written in c#
and I can't read it.. I'm only familiar with vb.net. 我发现了类似的帖子,但是..它是用
c#
编写的,我看不懂..我只对vb.net熟悉。
All our PC's are equipped with acrobat reader, but if there is a better method for printing? 我们所有的PC都装有acrobat阅读器,但是是否有更好的打印方法? I'm open to suggestions!
我愿意提出建议!
Please help.. i'm stuck!! 请帮助..我被卡住了!!
I found also this sample code in c#
我也在
c#
找到了此示例代码
string path = "" <- your path here.
if (path.EndsWith(".pdf"))
{
if (File.Exists(path))
{
ProcessStartInfo info = new ProcessStartInfo();
info.Verb = "print";
info.FileName = path;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process p = new Process();
p.StartInfo = info;
p.Start();
p.WaitForInputIdle();
System.Threading.Thread.Sleep(3000);
if (false == p.CloseMainWindow())
p.Kill();
}
}
From this post. 从这篇文章。 Is there a way to idle untill the print queue is done?
有没有办法让空闲直到打印队列完成? and then print a kill the process?
然后打印一个杀死进程?
you can use the Default PDF reader such as Acrobat or FoxitReader , Open your File then Print it, it's simple. 您可以使用默认的PDF阅读器,例如Acrobat或FoxitReader,打开文件然后打印,非常简单。 This is C# code :
这是C#代码:
get the full path for your PDF File : 获取您的PDF文件的完整路径:
String fullpath =System.IO.Path.GetFullPath(@FilePath);
Open it using the Default PDF Reader : 使用默认的PDF Reader打开它:
Process.Start(@fullpath);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.