双面打印pdf

时间:2013-02-07 11:39:13

标签: c# pdf printing pdfsharp

所以,我正在使用PDFSharp lib,而且,我想在双方打印pdf .... 我的打印机是hp2055dn我已经尝试了所有的东西......顺便说一句......我的代码就是:

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 个答案:

答案 0 :(得分:1)

我找到了解决方案,我创建了一台新打印机,并在默认设置下打印了两面...