2013-02-07 102 views
1

所以,我使用的是PDFSharp库,并且我想双面打印pdf。 我的打印机是hp2055dn我试过了所有东西... btw .. 。我的代码是:双方打印pdf

using PdfSharp.Pdf.Printing; 
using System; 
using System.Collections.Generic; 
using System.Drawing.Printing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 

namespace impressao 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      PdfFilePrinter.AdobeReaderPath = @"C:\Program Files (x86)\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe"; 
      //PdfFilePrinter.AdobeReaderPath = @"C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe"; 

      PrinterSettings settings = new PrinterSettings(); 
      settings.Collate = false; 
      settings.Duplex = Duplex.Vertical; 

      PrintDialog printerDialog = new PrintDialog(); 
      printerDialog.AllowSomePages = false; 
      printerDialog.ShowHelp = false; 
      printerDialog.PrinterSettings = settings; 
      printerDialog.AllowPrintToFile = true; 
      printerDialog.PrinterSettings.PrintToFile = true; 
      DialogResult result = printerDialog.ShowDialog(); 

      if (result == DialogResult.OK) 
      { 
       PdfFilePrinter printer = new PdfFilePrinter("0.pdf", settings.PrinterName); 

       try 
       { 
        printer.Print(); 
       } 
       catch (Exception ex) 
       { 
        Console.WriteLine("Error: " + ex.Message); 
       } 
      } 
     } 
    } 
} 

如果有另一种方式来使这个,另一个lib中,或者其他设置,或另一个DLL ......请告诉我,如果 可能是在C再拍一部程序或C++和我只是通过参数打印...我不知道...

我需要很多它,并迫切:(

感谢 亚历山大

+1

当然,这是一台打印机设置,不是你要控制在代码中? – Digbyswift

回答

1

我找到了解决办法,我创建了一个新的打印机和seted与两侧打印默认值...