Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Mar 27, 2023 9:50 am

Hello,

I am using Spire.PDF 9.3.4 and am testing the product for my company to see if it has the requirements for our application.
I want to use a Print Preview Control to show the pdf before printing it.

Code: Select all
private void printPreviewControl1_Click(object sender, EventArgs e)
{
    PdfDocument pdf = new PdfDocument();
    pdf.LoadFromFile(@"pdffile.pdf");

    this.printPreviewControl1.Rows = 2;
    this.printPreviewControl1.Columns = 2;

    pdf.Preview(this.printPreviewControl1);
}


Visual Studio does not recognize the pdf.Preview line in the code.
This is directly copied from your tutorials, is there something I did wrong?

Thanks in advance!
Daan

DaanDesloovere
 
Posts: 2
Joined: Mon Mar 27, 2023 9:41 am

Tue Mar 28, 2023 8:05 am

Hi

Thank you for your message.
Kindly note that the print preview function is only available in Windows Forms application. As mentioned in this tutorial, you need to create a windows forms application, add a PrintPreviewControl control to the form and reference Spire.Pdf.dll into the application. If there is any other issues, just feel free to write back.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Tue Mar 28, 2023 8:33 am

Hi,

Thanks for the quick reply!
I am using a windows forms application, added the PrintPreviewControl.
The only thing I did different is I added Spire.Pdf using the Nuget package manager.

Does that also work?

Best Regards,
Daan

DaanDesloovere
 
Posts: 2
Joined: Mon Mar 27, 2023 9:41 am

Tue Mar 28, 2023 9:23 am

Hi ,

Thank you for your message.
Certainly. You can use the Nuget package manager to add Spire.PDF, or you can download the Spire.PDF installation package on our official website and import the project. No matter what questions you encounter, welcome to ask.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Return to Spire.PDF

cron