• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert BufferedReader to File  RSS feed

 
Thomas Greene
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet which returns a PDF document to the requesting user. When it is called from a browser, the PDF document is automatically downloaded.
Now I need to call this servlet from Java (standalone code, not server side). Once this Java code gets the PDF document, it needs to convert it to images using Apache PDF Box API.

This is how my Java code looks like. It writes bytes to the screen.

      

and this is how the code to convert it to Images looks like



Now I need to combine these two so that the PDF file that is downloaded (in memory, would prefer not to write it to Filesystem) is converted to JPG. So, instead of passing a hardcoded filename, I somehow need to convert the BufferedReader object to File object and pass it as an input to PDDocument.

I am not able to make out how this conversion would happen.

Thank you.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is PDDocument?
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thomas Greene wrote:Now I need to combine these two so that the PDF file that is downloaded (in memory, would prefer not to write it to Filesystem)...


Well, unfortunately File objects refer to things in the file system (if they refer to anything at all). However I believe Dave is suggesting you look for overloaded versions of the PDDocument.load() method which read from some less restrictive object, like maybe an InputStream or a Reader or a URL.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!