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

本文演示如何使用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);  
        }             
    }
}

截图:

图片1

转载于:https://my.oschina.net/u/3006003/blog/1580212

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值