How to extract data from pdf file in matlab?

조회 수: 420 (최근 30일)
azizullah khan
azizullah khan 2014년 9월 19일
댓글: Yue Zhao 2019년 6월 30일
I am in search of such algorithm that will extract data from pdf file.For example in the pdf file a sentence is present i.e: Account# 29 . I want to extract 29 from pdf file.If it is possible by fopen() function ,please share it with me.I have tried pdftotext but doesn't succeed. Now if it is possible to extract data from pdf with the help of fopen(), it will be better.I also tried fopen() but leads to failure.Please share you experience with me..Thanks.
  댓글 수: 6
José-Luis
José-Luis 2014년 9월 19일
Yes, I have seen it and it doesn't work. In principle, it might work for trivial purposes like changing the font type, but I have no idea what kind of data you are trying to extract.
Writing a robust algorithm is a tall order.
azizullah khan
azizullah khan 2014년 9월 20일
편집: azizullah khan 2014년 9월 20일
Sir,Just give a clue that how it is possible: let suppose Pdf file contain:
Account# 345
i want to capture 345 from it..for example i can use regexp() to extract numbers only...Please help me...I have spend lots of my time on it..but doesn't succeed..Almost i have wasted a month for it....Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2014년 9월 21일
Assume you have a PDF file, which is displayed containing the string "Account# 345". Now different details impede the extraction of this string:
  • The contents can be compressed and/or encrypted, such that the string cannot be found in clear text inside the file.
  • Even without encryption or compression, the text need not be stored continously, but in a valid PDF each character can be stored with its paper position, such that the order does not matter.
In consequence searching a string in a PDF is not reliable. Therefore some OCR software is applied frequently to add an additional layer containing the contents as searchable strings. But as long as you do not specify any details of your PDF we cannot guess if they contain such strings.
Please notice, that your problem is not well defined and suggesting solutions is still based on guessing, although you've posted several corresponding questions in this forum. Finally the main problem is, that somebody decided to store data in PDF files, which is not sufficient for the later extraction of strings. Creating a large and complicatd workaround afterwards is an inefficient way. It would be more stable and faster to obtain the data in a more suitable format as a text file.
  댓글 수: 5
Noam Greenboim
Noam Greenboim 2015년 5월 25일
A possible workaround is to convert the PDF to an Excel file, and then import that XLS file to Matlab. This is a relatively good solution for PDF's that contain tables of data.
If you take a look first at the Excel file, you might find ideas how to access the data you're interested in.
Yue Zhao
Yue Zhao 2019년 6월 30일
We will get a matrix if we use imread for a picture. How do we get the matrix of the PDF?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

mizuki
mizuki 2018년 4월 25일
From R2017b, we have extractFileText for reading text data from PDF files.

Walter Roberson
Walter Roberson 2015년 5월 25일

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by