原創|使用教程|編輯:王香|2017-11-27 10:41:01.000|閱讀 3941 次
概述:Spire.PDF 是一個專業的PDF組件,能夠獨立地創建、編寫、編輯、操作和閱讀PDF文件,支持 .NET、WPF和Silverlight三個版本,本文介紹了如何在C#中顯示PDF文件的打印預覽。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文演示如何使用Spire.PDF和c#在Windows窗體應用程序中顯示PDF文件的打印預覽。
在使用下面的代碼之前,我們需要創建一個Windows窗體應用程序,在窗體中添加一個PrintPreviewControl控件,并將Spire.Pdf.dll引用到應用程序中。
using System; using System.Windows.Forms; using Spire.Pdf; namespace PreviewPDF { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void printPreviewControl1_Click(object sender, EventArgs e) { //Load PDF file PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile("New Zealand.pdf"); //Set the PrintPreviewControl.Rows and PrintPreviewControl.Columns properties to show multiple pages this.printPreviewControl1.Rows = 2; this.printPreviewControl1.Columns = 2; //Preview the pdf file pdf.Preview(this.printPreviewControl1); } } }
截圖:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn