MATLAB Answers

Java error to read pdf file

7 ビュー (過去 30 日間)
Adriano
Adriano 2017 年 5 月 26 日
回答済み: J Philps 2017 年 5 月 31 日
I'm trying to open a PDF file in matlab through java. The code is:
clear java
javaaddpath('C:\Users\AURYN BASE 1\Downloads\pdfbox-2.0.6.jar')
javaaddpath('C:\Users\AURYN BASE 1\Downloads\fontbox-2.0.6.jar')
pdfdoc = org.apache.pdfbox.pdmodel.PDDocument;
reader = org.apache.pdfbox.text.PDFTextStripper;
pdfdoc = pdfdoc.load('efa.pdf');
Then, I recive the error:
No method 'load' with matching signature found for class 'org.apache.pdfbox.pdmodel.PDDocument'.
I see that code in many websites but I can't execute it. Any suggestions? Many thanks!

  1 件のコメント

Adriano
Adriano 2017 年 5 月 26 日
I recive the same error also with earlier versions of pdfbox!

サインインしてコメントする。

回答 (1 件)

J Philps
J Philps 2017 年 5 月 31 日
Overall that error message seems to be indicating that load is not a valid method name (or the input is not in the expected format) for objects of type org.apache.pdfbox.pdmodel.PDDocument. Maybe it expects a string in double quotes?
Also, I am not sure what your use case is, but if you are extracting text from the pdf document, then this File Exchange post may be useful:
https://www.mathworks.com/matlabcentral/fileexchange/19798-extract-text-from-a-pdf-document

  0 件のコメント

サインインしてコメントする。

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by