【教程】PDF组件Spire.PDF 教程:在C#中显示PDF文件的打印预览

女爷i 2022-06-05 11:52 1565阅读 0赞

本文演示如何使用Spire.PDF和c#在Windows窗体应用程序中显示PDF文件的打印预览。

在使用下面的代码之前,我们需要创建一个Windows窗体应用程序,在窗体中添加一个PrintPreviewControl控件,并将Spire.Pdf.dll引用到应用程序中。

  1. using System;
  2. using System.Windows.Forms;
  3. using Spire.Pdf;
  4. namespace PreviewPDF
  5. {
  6. public partial class Form1 : Form
  7. {
  8. public Form1()
  9. {
  10. InitializeComponent();
  11. }
  12. private void printPreviewControl1_Click(object sender, EventArgs e)
  13. {
  14. //Load PDF file
  15. PdfDocument pdf = new PdfDocument();
  16. pdf.LoadFromFile("New Zealand.pdf");
  17. //Set the PrintPreviewControl.Rows and PrintPreviewControl.Columns properties to show multiple pages
  18. this.printPreviewControl1.Rows = 2;
  19. this.printPreviewControl1.Columns = 2;
  20. //Preview the pdf file
  21. pdf.Preview(this.printPreviewControl1);
  22. }
  23. }
  24. }

截图:

图片1

发表评论

表情:
评论列表 (有 0 条评论,1565人围观)

还没有评论,来说两句吧...

相关阅读

    相关 pdf

    > 首先下载pdf.js插件,放到项目里面 > > 官网下载地址:[http://mozilla.github.io/pdf.js/getting\_started/\dow