Get PDF File in Java Action

0
I want to read PDF file from Java Action using PDFBox jar and process further. So I am passing PDF File to Action. How can I get the PDF File/ File Location and its contents from Java in eclipse?
asked
2 answers
0

See API docs of version 4

static InputStream  getFileDocumentContent (IContext context, IMendixObject fileDocument)
static File         getFileDocumentContentAsFile (IContext context, IMendixObject fileDocument)
static void         storeFileDocumentContent (IContext context, IMendixObject fileDocument, String fileName, InputStream inputStream)
static void         storeFileDocumentContent (IContext context, IMendixObject fileDocument, InputStream inputStream)
static void         storeImageDocumentContent (IContext context, IMendixObject imageDocument, InputStream inputStream, int thumbnailWidth, int thumbnailHeight)
static InputStream  getImage (IContext context, IMendixObject imageDocument, boolean retrieveThumbnail)
answered
0

Hi , Thanks for your reply. As suggested I have used InputStream inputStream = Core.getFileDocumentContent(getContext(), __PDFObeject); to get Input Stream. I have used BufferedReader to read the lines in PDF. But it displaying junk values. How can I get the values present in PDF. ?
Below Code I have used :

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 1); String line = null; StringBuilder inputStringBuilder = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { inputStringBuilder.append(line); inputStringBuilder.append('\n'); line = bufferedReader.readLine(); System.out.println("Values in PDF are ::: "+line); }

And Also when I used BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( new FileInputStream(PDFObeject.getName()), "UTF8")); Its showing access denied. Where I need to give access to this file ? Thanks.

answered