.Net → C# – View PDF In Windows Form
Here is a quick tutorial on how to view a PDF file in a Windows Form application.
I downloaded PDFSharp (free). While it is a third-party application, it will still require the PC to have Adobe Reader (or better) installed.
And here is the small piece of code needed to display a PDF in a Windows Form:
string helpFile = "C:\HelpFile.pdf"; // the pdfAcroViewer is a control from PDFSharp // You can add the control to the Toolbox in Visual Studio // then drag it onto the form. pdfAcroViewer.LoadFile(helpFile); pdfAcroViewer.ShowToolbar = false; pdfAcroViewer.SetPageMode(PdfSharp.Pdf.PdfPageMode.FullScreen);
EDITED: After a number of questions in the comments, I decided to download the latest version and see if I could find the file. The file itself is not in the latest version. When I did this more than a year ago, the latest version was version 1.0.898. That version is still for download on sourceforge.
(screenshot below)

If you download that version, there will be directory located at “\PDFSharp\PdfViewer\PdfSharp.Viewing”. In that directory, you will see a Visual Studio project with the name “PdfSharp.Viewing.csproj”. Open the project in Visual Studio, and build the project in Release mode. After building, you will have created a “bin\release” folder in that same directory. You will need all of the .dlls in that directory(should be 6 of them). One of them will be the “PdfSharp.Viewing.dll” which should contain the PdfAcroViewer control from the code above.
Post in the comments if this works for you.
Tags: C#, pdf, PDFSharp, windows forms
October 27th, 2009 at 7:33 AM
Thanks for the tutorial, but which file in the PDFSharp download contains the pdfAcroViewer control (the one to be added to the VS Toolbox)?
Greatful for help!
October 27th, 2009 at 12:53 PM
It should be the PDFSharp.Viewing.dll.
November 11th, 2009 at 10:31 AM
I downloaded all latest Pdfsharp zip files. But I could not find PDFSharp.Viewing.dll anywhere. WHere it could be?
Thanks a lot.
November 17th, 2009 at 10:58 AM
Ok, so I went looking for the file, and it’s no longer there. I did this a while back(probably more than a year ago). I used version 1.0.898. I just downloaded that version, and it wasn’t there either. However, there was a project for PDFSharp.Viewing. So I opened the project and built it, and it built the PDFSharp.Viewing.dll.
So this is probably what you will need to do. In the bin directory where the .dll is created, there will be a number of other .dll files. You will also need those. I have updated the blog post.
March 5th, 2010 at 2:49 PM
Hello,
I was able to download PDFSharp.Viewing.dll and get the pdfAcroViewer control working. My problem is with the deployment. I am using the clickonce with VS2008.
When starting the application with the referce link that clickonce created the pdfAcroViewer control is not displayed and a null object reference error comes up. But when I start the appication by double clicking the application exe directly the control is displayed and no error.
Thanks!
Arnel
March 5th, 2010 at 7:13 PM
@Arnel
Are you including the .dll in the ClickOnce deployment?
March 5th, 2010 at 8:00 PM
Yes, all the dll’s are there. It works fine when I start the application by going directly to the install folder and double clicking on the exe.
March 5th, 2010 at 8:10 PM
Could it be something with the manifest of the dll’s?
March 5th, 2010 at 9:19 PM
I don’t deal with ClickOnce that much. Is Adobe installed on the PC?
March 8th, 2010 at 1:21 PM
Yes, Adobe is installed.
April 16th, 2010 at 5:03 PM
I have the same problem! when I publish it’s not works. only work in dev enviroment.
April 19th, 2010 at 10:38 AM
@Neperz
Adobe Acrobat needs to be installed on the client.
August 10th, 2010 at 7:24 PM
Hi,
is it possible to hide the navigation toolbar in the pdf while in the runtime environment mode?
November 8th, 2011 at 10:24 AM
Adding Embedded Code to a Report
You’ve been kicked (a good thing) – Trackback from DotNetKicks.com
November 10th, 2011 at 12:25 PM
Is there any way to load the PDF from a Stream or byte array?
January 27th, 2012 at 4:10 AM
Man! It is like you understand my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you can do with some images to drive the content home a bit, besides that, this is helpful blog post. A great read. I’ll certainly revisit again.