導航:首頁 > 文檔加密 > 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相關的資料

熱點內容
什麼是伺服器辨認不了 瀏覽:126
java如何調用類方法 瀏覽:481
管理孩子的app叫什麼 瀏覽:544
壓縮活動軌跡 瀏覽:672
6米梁加密筋 瀏覽:77
怎麼學好ps如何學好編程 瀏覽:298
c編譯器廠商 瀏覽:112
簡述編譯程序以及解釋程序 瀏覽:1
linux升級kernel 瀏覽:176
入侵伺服器挖礦是什麼罪 瀏覽:47
房屋解壓資料丟了怎麼辦 瀏覽:808
java文件行讀寫 瀏覽:544
影城網上售票系統源碼 瀏覽:634
防疫就是命令歌曲 瀏覽:204
滴滴號碼加密怎麼解除 瀏覽:844
模具編程的職責 瀏覽:944
華為ssh改加密演算法 瀏覽:149
文件夾空白合同 瀏覽:763
pythonwebpy開發 瀏覽:671
不是c編譯器的有 瀏覽:662