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

熱點內容
卡爾曼濾波演算法書籍 瀏覽:768
安卓手機怎麼用愛思助手傳文件進蘋果手機上 瀏覽:843
安卓怎麼下載60秒生存 瀏覽:802
外向式文件夾 瀏覽:235
dospdf 瀏覽:430
怎麼修改騰訊雲伺服器ip 瀏覽:387
pdftoeps 瀏覽:492
為什麼鴻蒙那麼像安卓 瀏覽:735
安卓手機怎麼拍自媒體視頻 瀏覽:185
單片機各個中斷的初始化 瀏覽:723
python怎麼集合元素 瀏覽:480
python逐條解讀 瀏覽:832
基於單片機的濕度控制 瀏覽:498
ios如何使用安卓的帳號 瀏覽:882
程序員公園采訪 瀏覽:811
程序員實戰教程要多長時間 瀏覽:974
企業數據加密技巧 瀏覽:134
租雲伺服器開發 瀏覽:813
程序員告白媽媽不同意 瀏覽:335
攻城掠地怎麼查看伺服器 瀏覽:600