Hello everyone,
I am looking for the appropriate version "PDFBOX-APP-X.X.X"
I use for compilation B4J Version: 10.00, Java version: 8.
In my B4J project I use two Java functions: (DHQIPARSEPDF and Convertpdftoimages)
I am looking for the right version "PDFBOX-APP-X.X.X" so that I can do the correct compilation of the project.
If I add the 'PDFBOX-APP-2.0.26' version to the project,
I get a complication error for the "DHQIPARSEPDF" function (see Example 1):
Example 1:
javac 1.8.0_441
src\b4j\html_editorwrapper\pdfmanager.java:11: error: cannot find symbol
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
^
symbol: class RandomAccessReadBufferedFile
location: package org.apache.pdfbox.io
Note: src\b4j\html_editorwrapper\dialogsfx.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
If I exchange it for the version 'PDFBOX-APP-3.0.4' in the same project,
I get a complication error for "Convertpdftoimages" (see Example 2):
Compilation of the generated Java code. Error
B4J line: 59
End Sub
javac 1.8.0_441
src\b4j\html_editorwrapper\pdfmanager.java:1163: error: cannot find symbol
PDDocument document = PDDocument.load(new File(pdfPath));
^
symbol: method load(File)
location: class PDDocument
Example 2:
I will gladly accept every clue, thank you.
I am looking for the appropriate version "PDFBOX-APP-X.X.X"
I use for compilation B4J Version: 10.00, Java version: 8.
In my B4J project I use two Java functions: (DHQIPARSEPDF and Convertpdftoimages)
I am looking for the right version "PDFBOX-APP-X.X.X" so that I can do the correct compilation of the project.
If I add the 'PDFBOX-APP-2.0.26' version to the project,
I get a complication error for the "DHQIPARSEPDF" function (see Example 1):
Example 1:
Compilation of the generated Java code. Error#AdditionalJar: pdfbox-app-2.0.26
#if java
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
import org.apache.pdfbox.Loader;
import java.io.IOException;
public static String DHQIParsePDF(String inputPdfPath){
try {
PDDocument documents = Loader.loadPDF(new RandomAccessReadBufferedFile(inputPdfPath));
PDFTextStripper stripper = new PDFTextStripper();
String text = stripper.getText(documents);
documents.close(); // Important: Close the document
System.out.println("PDF converted to text successfully");
return text;
} catch (IOException e) {
System.err.println("Error during PDF processing: " + e.getMessage());
e.printStackTrace(); // Print the full stack trace For debugging
return "--";
}
}
#end if
javac 1.8.0_441
src\b4j\html_editorwrapper\pdfmanager.java:11: error: cannot find symbol
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
^
symbol: class RandomAccessReadBufferedFile
location: package org.apache.pdfbox.io
Note: src\b4j\html_editorwrapper\dialogsfx.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
If I exchange it for the version 'PDFBOX-APP-3.0.4' in the same project,
I get a complication error for "Convertpdftoimages" (see Example 2):
Compilation of the generated Java code. Error
B4J line: 59
End Sub
javac 1.8.0_441
src\b4j\html_editorwrapper\pdfmanager.java:1163: error: cannot find symbol
PDDocument document = PDDocument.load(new File(pdfPath));
^
symbol: method load(File)
location: class PDDocument
Example 2:
#AdditionalJar: pdfbox-app-3.0.4
#if java
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public static void convertPDFToImages(String pdfPath, String outputFolder) throws IOException {
try {
PDDocument document = PDDocument.load(new File(pdfPath));
PDFRenderer renderer = new PDFRenderer(document);
for (int pageNumber = 0; pageNumber < document.getNumberOfPages(); pageNumber++) {
BufferedImage image = renderer.renderImageWithDPI(pageNumber, 300); // DPI (dots per inch)
// Salva a imagem em formato JPG
File outputImage = new File(outputFolder + File.separator + "pagina_" + (pageNumber + 1) + ".jpg");
ImageIO.write(image, "jpg", outputImage);
}
} catch (Exception e) {
e.printStackTrace();
}
}
#End If
I will gladly accept every clue, thank you.
Attachments
Last edited: