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

熱點內容
什麼app能看明星演唱會 瀏覽:493
ug刀柄放到哪個文件夾 瀏覽:321
eclipse編寫php 瀏覽:673
php抓取網頁內容的代碼 瀏覽:867
什麼是萌鴨app 瀏覽:861
變數的數字如何變化python 瀏覽:794
整數壓縮 瀏覽:993
最優停止策略問題演算法 瀏覽:716
pdf圖片背景 瀏覽:766
app的圖標有什麼風格 瀏覽:28
python代碼運行編譯器 瀏覽:936
魔鬼訓練程序員 瀏覽:686
php上傳大文件失敗 瀏覽:602
sw伺服器指定埠怎麼填 瀏覽:189
java有哪些數組 瀏覽:984
程序員戴手錶影響工作嗎 瀏覽:235
游戲皇後解壓視頻 瀏覽:367
c語言怎麼打開文件編譯 瀏覽:436
手機上什麼app可以設計logo 瀏覽:800
pid演算法單片機 瀏覽:375