導航:首頁 > 文檔加密 > printdocumentpdf

printdocumentpdf

發布時間:2024-12-07 03:47:27

① .net列印pdf文件

方法一(web):window.print()

    print()方法是瀏覽器列印功能的一種程序調用。print方法用於列印當前窗口的內容。

列印當前頁:

function printPage(){

    window.print();

}

列印局部頁面:

        前端頁面:<iframe style="width:100%;height:100%;" id="fileId" src="文件路徑">

        </iframe>

        <input type="button" name="print" id="print" value="列印" />

        js:$("#print").click(function () {

        var iframe = document.getElementById("fileId");

        iframe.contentWindow.print();

    });

方法二:調用系統API(得保證本地裝有相關的軟體)

PrintDocument pd = new PrintDocument();

            pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";

            Process p = new Process

            {

                StartInfo = new ProcessStartInfo

                {

                    CreateNoWindow = false,

                    WindowStyle = ProcessWindowStyle.Hidden,

                    UseShellExecute = true,

                    FileName = filePath,//文件路徑

                    Verb = "print",

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

                }

            };

            p.Start();

            p.WaitForExit();

方法三:spire列印方式(收費)下面是簡單的使用例子

 var pdf = new PdfDocument(filePath);

//設置列印機

pdf.PrintSettings.PrinterName = "Microsoft Print to PDF";

pdf.print();

方法四:安裝RawPrint

var printer = new Printer();

var file = File.Open(filePath, FileMode.Open);

byte[] array = new byte[file.Length];

file.Read(array, 0, array.Length);

printer.PrintRawStream(printerName, file, "列印機上顯示的任務名");

file.Close();

printer.PrintRawFile(printerName, fileFullPath, "列印機上顯示的任務名");

這個測試時虛擬列印機上正常,使用公司列印機時出現亂碼問題以及列印任務不停的問題

閱讀全文

與printdocumentpdf相關的資料

熱點內容
如何判斷伺服器ip地址和版本號 瀏覽:962
python獲取html內容 瀏覽:767
北歐大神程序員 瀏覽:204
安卓手機怎麼拍出照片的質感 瀏覽:832
編譯後的病毒長什麼樣子 瀏覽:20
圍棋與程序員 瀏覽:260
加密和解密的單詞 瀏覽:980
我的世界td伺服器怎麼注冊 瀏覽:412
編譯器的堆空間 瀏覽:598
雲引擎雲伺服器 瀏覽:906
解壓視頻聲控吃冰義大利 瀏覽:405
渦旋壓縮機動渦盤 瀏覽:878
手機郵件發文件夾 瀏覽:448
魔獸世界懷舊服tbc薩滿宏命令 瀏覽:549
linuxsvn手冊 瀏覽:268
程序員圖鑒 瀏覽:539
東營程序員 瀏覽:716
發票上傳參數沒置伺服器地址 瀏覽:47
程序員網上接單能掙多少錢 瀏覽:179
稀有傳奇手游源碼 瀏覽:553