From e8b89f66c64973c813ba999504a4357406873a61 Mon Sep 17 00:00:00 2001 From: Thomas Beyer Date: Mon, 20 Mar 2023 08:56:23 +0100 Subject: [PATCH] RED-4875 - add possibility to call if with pdfdoc-object --- .../red/pdftronlogic/commons/PdfTextExtraction.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iqser/red/pdftronlogic/commons/PdfTextExtraction.java b/src/main/java/com/iqser/red/pdftronlogic/commons/PdfTextExtraction.java index d489edf..06d0ea4 100644 --- a/src/main/java/com/iqser/red/pdftronlogic/commons/PdfTextExtraction.java +++ b/src/main/java/com/iqser/red/pdftronlogic/commons/PdfTextExtraction.java @@ -14,9 +14,7 @@ import com.pdftron.pdf.TextExtractor; public class PdfTextExtraction { - public static String extractAllTextFromDocument(InputStream fileStream) throws IOException, PDFNetException { - - PDFDoc pdfDoc = new PDFDoc(fileStream); + private static String execute(PDFDoc pdfDoc) throws IOException, PDFNetException{ TextExtractor extractor = new TextExtractor(); List texts = new ArrayList<>(); @@ -32,4 +30,13 @@ public class PdfTextExtraction { return String.join("\n", texts); } + public static String extractAllTextFromDocument(InputStream fileStream) throws IOException, PDFNetException { + PDFDoc pdfDoc = new PDFDoc(fileStream); + return execute(pdfDoc); + } + + public static String extractAllTextFromDocument(PDFDoc pdfDoc) throws IOException, PDFNetException { + return execute(pdfDoc); + } + }