Geeks With Blogs
Path Notes of a Kodefu Master blog

If you've ever needed to host a PDF in a windows form application, the easiest way to do so is by using the ActiveX control provided by Adobe Acrobat. Accessing it is easy: Right click the toolbox, select Choose Items, select COM Components, then check Adobe PDF Reader.

The Adobe PDF Reader control now shows up in your toolbox under the General tab. You can move this to a different tab by dragging and dropping.

If you drag this to your Windows Form, it now acts like a regular control. Its default name is axAcroPDF1.

The typical way to display a pdf in the control is by using the LoadFile method. Unfortunately this method does not work for loading from a url. Instead, there is property to set for that: src.

axAcroPDF1.src = url;

However, you may have another reason for storing the pdf on the disk before displaying it. Here's the code that will help you in that situation. Note that WebClient is located in the System.Net namespace.

string fileName = Path.GetTempFileName();
WebClient client = new WebClient();
client.DownloadFile(url, fileName);
axAcroPDF1.LoadFile(fileName);
Posted on Wednesday, June 3, 2009 5:52 PM Kodefu | Back to top


Comments on this post: PDF From Web in AxAcroPDF

# re: PDF From Web in AxAcroPDF
Requesting Gravatar...
Great, easy and important to know thanks for sharing this point with others
Left by web development company on Aug 17, 2009 9:32 AM

Your comment:
 (will show your gravatar)


Copyright © Chris Eargle | Powered by: GeeksWithBlogs.net