At some point, we may want to display a PDF file as it will appear when printed. This article demonstrates how to show print preview of a PDF file in Windows Forms application using Spire.PDF and c#.
Before using the following code, we need to create a windows forms application, add a PrintPreviewControl control to the form and reference Spire.Pdf.dll into the application.
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);
}
}
}
Screenshot:

