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

熱點內容
資料庫查詢系統源碼 瀏覽:614
php5314 瀏覽:354
完美國際安裝到哪個文件夾 瀏覽:666
什麼app可以掃一掃做題 瀏覽:537
程序員編碼論壇 瀏覽:923
淘點是什麼app 瀏覽:658
中國高等植物pdf 瀏覽:453
51單片機時間 瀏覽:181
後台如何獲取伺服器ip 瀏覽:264
單片機流水燈程序c語言 瀏覽:232
程序員第二職業掙錢 瀏覽:237
運行里怎麼輸入伺服器路徑 瀏覽:837
pythonstepwise 瀏覽:508
劉一男詞彙速記指南pdf 瀏覽:61
php認證級別 瀏覽:366
方舟編譯啥時候推送 瀏覽:1009
php手機驗證碼生成 瀏覽:674
哲學思維pdf 瀏覽:14
凌達壓縮機有限公司招聘 瀏覽:533
weblogic命令部署 瀏覽:35