Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send pdf file to a printer - print pdf [duplicate]

Tags:

c#

printing

pdf

I'm programming a web application with Visual Studio 2010 (C#). I want to send a PDF (saved in my computer) to a printer when I click a button.

To create the PDF I used iTextSharp. I tried this, but it just opens Adobe Reader:

               proc.StartInfo.FileName = @"C:\Archivos de programa\Adobe\Reader10.0\Reader\AcroRd32.exe";
               proc.StartInfo.Arguments = String.Format(@"/p /h {0}", pdfFileName);
               proc.StartInfo.UseShellExecute = false;
               proc.StartInfo.CreateNoWindow = true;

               proc.Start();

Thank you in advance!!!

like image 218
Alsan Avatar asked Jul 03 '13 12:07

Alsan


People also ask

How do you prevent a PDF from being duplicated?

The "Permissions" setting controls restrictions that can be placed on the PDF file. To prevent the text and graphics from being copied from the PDF file, uncheck the "Allow text and graphics to be copied" option. You must always enter a master password when security options are enabled.

How do I save a copy of a PDF to Print?

Open your PDF document. From the menu bar select File and choose Save As. icon to save the document. Within the Save PDF Document as dialog box, enter a name and select Save to create the new document.


1 Answers

this has already been asked and answered here: How can I send a file document to the printer and have it print?

The code that was used:

private void SendToPrinter()
    {
        ProcessStartInfo info = new ProcessStartInfo();
        info.Verb = "print";
        info.FileName = @"c:\output.pdf";
        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();
    }

it basicly opens a "hidden" pdf-reader, tells it to print, waits for it to finish then close it down

like image 122
Johan Hjalmarsson Avatar answered Oct 16 '22 10:10

Johan Hjalmarsson