These two days have been studying the direct print PDF files, find three kind of good way to print, but each have each problem,
Method one: use PrintDocument kind print Advantages: fast printing Disadvantages: 1. The need to install Adobe Reader 2. Not manually choose printer, even if you want to set the printer, will use the default printer to print 3. Print, the Adobe Reader will open the PDF file, sometimes can be automatically shut down, sometimes close not to drop, Code is as follows: Private static void printPDF2 (string filePath) { PrintDocument pd=new PrintDocument (); Process p=new Process(); ProcessStartInfo startInfo=new ProcessStartInfo ();
Pd. PrinterSettings. PrinterName="Send To OneNote 2016";
P. tartInfo=startInfo; P. tart (); P.W aitForExit (); }
Method 2: use AcroRd32. Exe print Advantages: 1. The printing speed 2. You can choose the printer Faults: automatically using Adobe Reader to open the file, and then turn off automatically occasionally about out Code is as follows: Private static void printPDF3 (string filePath) { Process p=new Process();
String appPath=@ "C: \ Program Files \ (x86) Adobe Acrobat Reader DC \ Reader \ AcroRd32 exe";
P. tartInfo=startInfo; P. tart (); P.W aitForExit (); }
Method 3: use the Spire. PDF for the.net type Advantages: 1. The printing, printing, completely silent won't pop up Adobe Reader program, open and close the PDF file 2. You can choose the printer Disadvantages: slower print The code is in the home, so they don't, roughly as follows: (looking for online)
Using Spire. Pdf; PdfDocument doc=new PdfDocument (); Doc. LoadFromFile (@ "C: \ XXX. PDF, FileFormat. PDF); Console. WriteLine (doc. UsedFonts); PrintDocument printDoc=doc. PrintDocument; PrintDoc. PrintController=new StandardPrintController (); PrintDoc. Print (); Doc. The Close (); The print mode, feeling is originally very small PDF documents, to regenerate, and then sent to the printer, from the perspective of the size of the printer, several times larger than my original file, 30 pages of documents, took 40 seconds to send out, the former two ways, almost spent only a few seconds,
Excuse me each great god, is there a better way to solve the above problem, only to solve one, also be grateful,