• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

download a pdf from a website - Vb.net

I am working on a program that visits a website, log's that websites login page which takes it to a pdf document that i need to download automatically with a preset path, then move on to the next link.

The only way i can make this function currently is using the axwebbrowser, calling this command:
Then sending keys with the path and hitting enter....
as the dontpromtuser call does not work. (this has been discussed elsewhere in the forum)

I have also tried the sysem.net.webclient

Dim getfile As System.Net.WebClient
getfile = New System.Net.WebClient

getfile.DownloadFile("https://ecf.ohsd.uscourts.gov/cgi-bin/show_case_doc?pdf_header=2&magic_num=" & MAGIC_NUM & "&case_id=" & CASE_ID & "&doc_num=" & DOC_NUMBER & "&att_num=" & i & "&got_receipt=1", "C:\testthispdf.pdf")

However, the file that is downloaded is currupt and will not open.

If anyone can provide an alternitive method, or possibly something i am doing wrong with either of these two, i would greatly appreciate it.

Thank you,
  • 2
1 Solution
you should be using the System.Net.HttpWebRequest and System.Net.HttpWebResponse objects to build your spider.
check out http://msdn.microsoft.com/msdnmag/issues/02/10/spiderinnet/ for more info

just treat the pdf as you would any binary file (meaning you don't want to interpret it) and stream it to a destination file.

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now