473,614 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading a PDF from web page using URL (.NET)

1 New Member
Hello all,

This isn't rocket science to most, but I had a hard time figuring out how to read a PDF via URL and saving it to disk. You can use the PDFBox dll for this, but for those who want to use pure .NET, here's some code:
Expand|Select|Wrap|Line Numbers
  1. The namespaces:
  2.  
  3. using System.Text;
  4. using System.IO;
  5.  
the script:
Expand|Select|Wrap|Line Numbers
  1. //sends the request, converts response to s stream
  2. HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(pdfURL);
  3. HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
  4. Stream reqStr = webResponse.GetResponseStream();
  5.  
  6. //reads the response stream
  7. StreamReader sr = new StreamReader (reqStr,System.Text.Encoding.Unicode);
  8.  
  9. //writes stream to a PDF file
  10. StreamWriter sw = new StreamWriter(savePathPDF, false, System.Text.Encoding.Unicode);
  11. sw.Write(sr.ReadToEnd());
  12. sw.Close();
Hopes this helps.
Aug 14 '09 #1
0 11063

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1631
by: Brett | last post by:
I am writing a program that will allow a user to enter a webpage address into a form. Then it will download and display the webpage below the current one. example ---------------------------------------------------- | _____________ | | _____________enter web address | Load Button | | | -------------- | |___________________________________________________
8
1289
by: Chad A. Beckner | last post by:
Does anyone know how to read the page title the executing page, using ASP.NET? I thought that this could be accessed using the Controls collection, but I can't seem to figure it out. Thanks! Chad
0
864
by: David C | last post by:
Hi, I know that when calling a Webservice, the "Underlying Connection Was Closed" error message occurs intermittenly. This issue is addressed here http://support.microsoft.com/kb/819450 My problem is, using an ASP.NET client, I am sending and receiving XML to ASP pages, not a .NET web service. And I get the error message intermittenly.
2
1637
by: Tod Birdsall | last post by:
Hi All, I am trying to secure non-ASP.NET files (i.e. .html, .pdf) in an application running on IIS 6.0, Win2K3 using the .NET Framework 2.0. What has worked in the past using .NET Framework 1.1 on IIS 6.0 is the following : 1. Open IIS 2. Right click website, choose Properties. 3. Click "Home Directory" tab.
2
1751
by: deepukutty | last post by:
Hi all, I know tht we can do tracing in two ways.one in application level and the other is at Page level. I am able to see the details of trace either on the page itself or .../trace.axd page. I want to use maximum out of the available trace details . or let me put it like this.... tell me the actual scenario's where these trace details will be use ful and
3
1696
by: ABC | last post by:
How to create a web page class for inhert web page using ASP.NET 1.1 and 2.0?
4
2952
by: Praveen Chandra | last post by:
Hi, I just wanted to put down the issue with more detailed information so that you can help us get to the right Microsoft resource for a solution! Here is the problem description... Our intent: Accept the COM or COM+ class name, function-name and input parameter (fixed string parameter) as string inputs and execute(invoke) the function at run time.
0
1159
by: manishoz | last post by:
How can I print Windows test page using .NET code for eg. in c#. I need this without going throught the windows PrintDialog popup. Thanks
2
4226
by: Sasquatch | last post by:
I'm having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight forward, but it won't work for me. Here's what I did. 1. Created a new folder named "testlogin" 2. Turned that folder into an application using the IIS properties 3. Created two new web form pages, /testlogin/default.aspx and /testlogin/login.aspx...
2
1806
by: Mittalswati | last post by:
Hi All I am getting the below mentioned error while accessing the page which uses VB.Net Dll ,Please look in to the matter and suggest some solution Unable to cast COM object of type 'Scripting.DictionaryClass' to interface type 'Scripting.IDictionary'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{42C642C1-97E1-11CF-978F-00A02463E06F}' failed due to the following error: No...
0
8124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8576
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8272
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8427
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6087
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4049
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1712
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1421
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.