Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

load PDF file from website

 
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: 25669
69
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.
 
Rancher
Posts: 4607
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.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic