PDF From Web in AxAcroPDF

by KodefuGuru 3. June 2009 17:25

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);

Tags: , ,

Kodefu

Comments

6/3/2009 5:48:34 PM #

trackback

Trackback from DotNetKicks.com

PDF From Web in AxAcroPDF

DotNetKicks.com

6/4/2009 3:24:44 AM #

trackback

Trackback from Sanjeev Agarwal

Daily Tech Links - June 4, 2009

Sanjeev Agarwal

6/12/2009 11:59:03 PM #

trackback

Trackback from DotNetShoutout

PDF From Web in AxAcroPDF

DotNetShoutout

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen

Whois KodefuGuru

Chris Eargle

Chris Eargle
.NET Community Champion

LinkedIn Twitter Technorati Facebook

MVP - Visual C#

 

INETA Community Champions
Friend of RedGate
Telerik .NET Ninja
Community blogs & blog posts

I am a #52er


World Map

RecentComments

Comment RSS

Tag cloud

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010