Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Render PDF in Windows Forms with .NET

Question

Can I Use Quick PDF to open a PDF and show it on Windows Forms in .NET? If so, do you have some sample code that I could see? I'd be extremely interested in purchasing the library if it can do that.

Answer

Yes, you can use Quick PDF Library to render a PDF in your Windows Form using .NET.

Here is some C# sample source code that shows you how to render the PDF in the picture box on your form.

private void Form1_Load(object sender, EventArgs e)
{
QuickPDFAX0718.PDFLibrary pdf = new QuickPDFAX0718.PDFLibrary();

qp.UnlockKey("......Licence Key......");

// Open PDF File
int Handle = qp.DAOpenFile("C:\\sample.pdf", null);

// Get Total Number of Pages in a PDF File
int PageCount = qp.DAGetPageCount(Handle);

int PageNo = 1;

// It will get Reference of page 1 from PDF file
int PageRefNo = qp.DAFindPage(Handle, PageNo);

// You can change this parameter for Zoom In/Zoom Out purpose
int Zoom = 76;
double pageWidth = qp.DAGetPageWidth(Handle, PageRefNo) / Zoom;
double pageHeight = qp.DAGetPageHeight(Handle, PageRefNo) / Zoom;

// DPI use for rendering the page. Increase DPI will increate quality of image
int dpi = 92;

// Calculate Dimension of final output image
Bitmap b = new Bitmap(Convert.ToInt32(pageWidth * dpi), Convert.ToInt32(pageHeight * dpi));

// This will Draw render image on GDI
using (Graphics g = Graphics.FromImage(b))
{
IntPtr dc = g.GetHdc();
qp.DARenderPageToDC(Handle, PageRefNo, dpi, (int)dc);
g.ReleaseHdc(dc);
}

// Assigne rendered image to PictureBox Control which will display PDF on Windows Form.
pictureBox1.Image = b;
pictureBox1.BorderStyle = BorderStyle.Fixed3D;
}

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum