Home > Net >  C # PDF problem printing directly
C # PDF problem printing directly

Time:09-30

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";

StartInfo. CreateNoWindow=true;
StartInfo. WindowStyle=ProcessWindowStyle. Hidden;
StartInfo. UseShellExecute=true;
StartInfo. FileName=filePath;
StartInfo. Verb="print";

String sysPrintName=pd. PrinterSettings. PrinterName;

String printName="Send To OneNote 2016";
StartInfo. The Arguments=@/p/h \ "" +" \ "" "+ + filePath printName +" \ "";

//startInfo. The Arguments=@ "/p/h " + filePath + "" \ "" + pd PrinterSettings. PrinterName +" \ "";


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";

ProcessStartInfo startInfo=new ProcessStartInfo ();
StartInfo. FileName=appPath;

String argument="/h/t " D: \ \ Projects \ \ 11111. PDF \ "" Send To OneNote 2016 \ "";

StartInfo. The Arguments=argument;///h/t \ "" D: \ \ Projects \ \ 11111. PDF " \ "Send To OneNote 2016 " ";

StartInfo. CreateNoWindow=true;
StartInfo. WindowStyle=ProcessWindowStyle. Hidden;
StartInfo. UseShellExecute=true;

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,

Thank you,

CodePudding user response:

Try aspose. PDF printing

CodePudding user response:

reference 1/f, chu smile sama reply:
try aspose. PDF print
thank you belong to the third party controls

CodePudding user response:

The recently released Spire. There is a relatively new 5.4.1 PDF version, the improvement and optimization on the printing speed, you can try this version or and its version of the above

CodePudding user response:

reference qq_36492588 reply: 3/f
recently released Spire. There is a relatively new 5.4.1 PDF version and do the improvement and optimization on the printing speed, you can try this version or and over version of
I only saw the 5.1 version, please download this version of how to charge

CodePudding user response:

Mupdf the search on the net, c # encapsulation, themselves to a single page rendering PDF documents into the picture, then use Graphics drawing to the printer,
C # using the mupdf method, have friends online blogs can refer to,
Printing speed optimization, you need to modify the rendering PDF page content into image dpi, appropriate down speed will be faster,
Advantages: no need to install adobe reader in the client,
Spire. PDF this third-party components, I remember is how much do you charge for it, is the free version will have restrictions, such as only print within 10 page content?

CodePudding user response:

Pdfium know

The best, actually foxit is too expensive

CodePudding user response:

reference 4 floor LangKe416 response:
Quote: refer to the third floor qq_36492588 response:
recently released Spire. There is a relatively new 5.4.1 PDF version and do the improvement and optimization on the printing speed, you can try this version or and over version of
I only saw the 5.1 version, please download this version of how to charge this?
you try 5.4.9 version, this is the charge, you can email to ask them after a temporary authorization certificate, functionality is no restrictions

CodePudding user response:

Aspose is charging but can get authorization code

CodePudding user response:

refer to the second floor qq_36492588 response:
Quote: refer to 4th floor LangKe416 response:

Quote: refer to the third floor qq_36492588 response:
recently released Spire. There is a relatively new 5.4.1 PDF version, the improvement and optimization on the printing speed, you can try this version or and over version of
I only saw the 5.1 version, please download this version of how to charge this?
you try 5.4.9 version, this is the charge, you can email to ask them after a temporary authorization certificate, functionality is entirely without
https://www.e-iceblue.cn/Downloads/Spire-PDF-NET.html

CodePudding user response:

refer to 6th floor assky124 response:
Pdfium know

The best, actually foxit is too expensive
well ok thank you

CodePudding user response:

refer to the eighth floor m0_37608957 response:
aspose's fees but could get authorization code
company with free is better but still thank you

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C #
  • Related