how to use PintDialog control with a PDF file in my path in c#

theophile kapapa 6 Reputation points
2021-06-12T11:22:31.477+00:00

I have a Pdf document stored in my directory is it possible to print it while using the PrintDialog control in order to select the printer to use.

Developer technologies C#
{count} vote

1 answer

Sort by: Most helpful
  1. Castorix31 90,521 Reputation points
    2021-06-13T08:35:50.343+00:00

    You can use "printto" verb, but the AcroRd32.exe process remains at end
    (you can add a timer or a thread to kill the process after the printing is done...)

    Test without killing AcroRd32 process =>

    PrintDialog printDialog1 = new PrintDialog();
    if (printDialog1.ShowDialog() == DialogResult.OK)
    {   
        Process p = new Process();
        p.StartInfo.FileName = "e:\\test.pdf";
        p.StartInfo.Verb = "printto";                  
        p.StartInfo.Arguments = "\"" + printDialog1.PrinterSettings.PrinterName + "\"";                    
        p.Start();                
    }
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.