Hi Friends,
We have a requirement to read pdf text in ensemble object script code. As object script doesn't have direct solution , i tried to implement python code , but
iris 2020 , there is no support for python in object script.
so I have found one java utill using pdfbox api.
Now I have created jar and want to register into iris and want to make a call to mymethod to read pdf text.
please help me to way forward to achieve it.
java code:
============
package org.optimus.utils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import java.io.File;
import java.io.IOException;
public class PdfToText {
public static String getText(String filepath) {
// Load the PDF file
String text="";
File pdfFile = new File(filepath); // Replace with your PDF file's path
PDDocument document = null;
try {
document = PDDocument.load(pdfFile);
// Create a PDFTextStripper object
PDFTextStripper textStripper = new PDFTextStripper();
// Get the text from the PDF document
text = textStripper.getText(document);
// Close the PDF document
document.close();
}catch (IOException e) {
e.printStackTrace();
}
return text;
}
}