Winform 打印本地PDF文件

需要下载O2S.Components的dll文件

url="C:/Users/Administrator/Desktop/test.pdf";
 private int printShow1(string url)
 {
     int isOK = 0;
     PDFFile file = PDFFile.Open(url);
     PrinterSettings settings = new PrinterSettings();
     System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
     settings.PrinterName = printname;
     settings.PrintToFile = false;
     //设置纸张??(可以不设置,取默认设置)3.90 in,  8.65 in
     System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize("test", 4, 9);
     ps.RawKind = 9; //如果是?定义纸张,就要?于118,(A4值为9,详细纸张类型与值的对照请看http://msdn.microsoft.com/zh-tw/library/system.drawing.pri
     // O2S.Components.PDFRender4NET.Printing.PDFPrintSettings pdfPrintSettings = new O2S.Components.PDFRender4NET.Printing.PDFPrintSettings(settin              pdfPrintSettings.PaperSize = ps;
     O2S.Components.PDFRender4NET.Printing.PDFPrintSettings pdfPrintSettings = new O2S.Components.PDFRender4NET.Printing.PDFPrintSettings(settings);
     pdfPrintSettings.PaperSize = ps;
     pdfPrintSettings.PageScaling = O2S.Components.PDFRender4NET.Printing.PageScaling.FitToPrinterMarginsProportional;
     pdfPrintSettings.PrinterSettings.Copies = 1;
     try
     {
         file.Print(pdfPrintSettings);
         isOK = 1;
     }
     catch (Exception)
     {
         isOK = -1;
         throw;
     }
     finally
     {
         file.Dispose();
     }
     return isOK;
 }