Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

load PDF file from website  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

I am writing a program that reads from PDF files. It runs sucessfully when I read from PDF files that are on the local system. However, the goal of this is to read PDFs from a http or https site.
I keep getting this message:



I am using the PDFBox from apache.
Here's a little code that doesn't work with the http url but works with the system path:



Any ideas?

thanks,
Andrew
 
Andrew Cho
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry,

really simple fix. I just needed to replace

with


Andrew
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this and it didn't work.  Hopefully someone is still around to help

My goal is to read a PDF from a URL.

HEre's my code

         PDDocument doc = PDDocument.load(new File("https://spstest.mckesson.com/iPledgeUI/rems/pdf/resources/iPledge_REMS_Non_Compliance_Action_Policy.pdf"));


This is the error

https:/spstest.mckesson.com/iPledgeUI/rems/pdf/resources/iPledge_REMS_Non_Compliance_Action_Policy.pdf (No such file or directory)

When I change the FILE to URL I get error in IDE

CAN NOT RESOLVE METHOD load(java.net.URL)

I'm using IntelliJ


 
Marshal
Posts: 24461
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harry, welcome to the Ranch!

I guess you're asking about the PDDocument class in the PDFBox project, am I right?

If so then it looks like you should use the version of the load method which uses an InputStream. You can get one from a URL by following this tutorial: Reading Directly from a URL.
 
Master Rancher
Posts: 4072
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew Cho's second post shows the way to do it, by using a URL.
That was the solution to his issue.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!