0

I Need to print a pdf file to a selected printer.

I have tried using the code below, but it opens adobe and prints to the default printer. Does itext 7 have the ability to print directly to a selected printer using the print dialog box.

I am using visual basic.net

    Dim proc As Process = New Process
        proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        proc.StartInfo.Verb = "print"
        'Define location of adobe reader/command line
        'switches to launch adobe in "print" mode
        proc.StartInfo.FileName = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
        proc.StartInfo.Arguments = "/p /h "" " & item & ""
        proc.StartInfo.UseShellExecute = False
        proc.StartInfo.CreateNoWindow = False
        proc.Start()
        proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal
        If (proc.HasExited = False) Then
            proc.WaitForExit(10000)
        End If

        proc.EnableRaisingEvents = True
        proc.Close()
        killProcess("AcroRd32")
Michael
  • 1
  • 5

1 Answers1

0

You could enable LPD printing in your environment. Enable LPD

Then call LPR when using Process (example is in C# but you should under stand it)

var command = @"lpr -S IPorServername -P PRINT_QUEUE -J name in_printserver_queue filename_with_full_path";

ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/C " + command);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.RedirectStandardError = true;
procStartInfo.CreateNoWindow = true;
// start process
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();
Kiki Risager
  • 86
  • 1
  • 3