Click here to Skip to main content
13,151,815 members (60,701 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi :)

I have a folder with 10 pdfs, and, I whant to know how I can print this 10 pdfs without show the printdialog, for all pdfs, something like this:

public void PrintAllDocuments()
        {
            string[] AllFiles = Directory.GetFiles(@"C:\PDF\", "*.pdf", SearchOption.AllDirectories);
 
            for (int i = 0; i < AllFiles.Length; i++)
            {
                PrintFile pf = new PrintFile(AllFiles[i]);
                pf.printerName = "HP ???";
                pf.paper = "A4";
                pf.Print();
            }
        }


of course, that is some a sample... but, How I can configure the printer and print the document, witout use the PrintDialog... to open the PDF and print the PDF, how I can do this ??? :(

Thanks for help. :)
Posted 3-Jan-13 2:26am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

add a printDocument control to your form and use that e.g.
this.printDocument1.DocumentName = @"c:\document1.pdf";
this.printDocument1.Print();

See also http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(VS.71).aspx[^] for more details

Ok - everything above here is fine but not for Adobe products - i.e. PDFs.

The following links will be more useful...
Printing pdf files with c#[^]

or
http://bytes.com/topic/c-sharp/answers/247935-pdf-printing-c[^]

and I'm off to have a better look at http://itextpdf.com/[^]
  Permalink  
v2
Comments
URVISHSUTHAR 3-Jan-13 9:23am
   
yeah, above should work proper
Alexandre Bencz 3-Jan-13 9:40am
   
It's simple, but, when I do this, the printer just put out one blank paper... :(
CHill60 3-Jan-13 10:08am
   
It's just done the same for me when I use a different printer ... give me a moment or two and I'll try to find out what I've missed out
CHill60 3-Jan-13 10:19am
   
I've just updated the solution with some other links - seems it's not that simple to print PDFs!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.170924.2 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100