0
votes

I'm building an application which main function is printing .pdf files. 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. ( we have a plotter that goes from A0 - A3 drawings ) so a great range off different sizes could be in the batch.

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.

Link to post

All our PC's are equipped with acrobat reader, but if there is a better method for printing? I'm open to suggestions!

Please help.. i'm stuck!!


I found also this sample code in 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?

1

1 Answers

0
votes

you can use the Default PDF reader such as Acrobat or FoxitReader , Open your File then Print it, it's simple. This is C# code :

  1. get the full path for your PDF File :

     String fullpath =System.IO.Path.GetFullPath(@FilePath);
    
  2. Open it using the Default PDF Reader :

    Process.Start(@fullpath);