pdf에서 txt로 변환 1[pdfminer]
소개
아래와 같은 영어로 쓰여진 복사할 수 없는 pdf 파일 20장을 번역할 필요가 있었으므로,
텍스트를 추출하여 google 번역 등에 적용하고 싶습니다.,
목적
pdf 파일에서 텍스트를 추출합니다.
사용한 것
이번에는 pdfminer를 사용했다.
htps : // 기주 b. 코 m / pdf f r / pdf f r. x
또, 이하의 기사도 참고로 했다.
htps : // 이 m/mc↑↑/있어 ms/894110558fb890c930b5
처리 흐름
1.Please input pdf path : 다음에 pdf 파일명 입력
2. 입력 파일 이름의 확장자를 .txt로 변경하고 텍스트 파일 작성
3. 그것에 결과 산출
같은 간단한 동작이다.
결과
방금 전의 pdf 파일을 지정해 본 결과가 이하이다.
하나의 화살표 만 출력되었습니다. 재미,
다른 pdf 파일로 확인하기 위해, word로 작성한 이하의 pdf를 지정해 본다.
결과는 다음과 같다.
또 방금 전의 화살표가 출력되고 있지만, 영어도 일본어도 잘 출력되고 있다.
프로그램이 문제가 아닌 것 같습니다.
pdf의 보호에 의한 문제라고 생각해 「pdf에 인쇄」로 보호를 해제해 보았지만,
또한 하나의 화살표 만 출력되었습니다.
고찰
pdfminer 자체가 잘 동작하고 있음을 확인할 수 있었기 때문에 문제는 pdf 파일에 있다고 생각된다.
대상의 pdf 파일이 스캔된 것인지, 화질이 거친 것이 원인이라고 생각한다.
프로그램
pdfminer가 너무 편리하기 때문에 매우 짧은 프로그램이되었습니다.
pdf2text.pyfrom pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
input_path = input("Please input pdf path : ")
output_path,ext = input_path.split(".")
output_path += ".txt"
manager = PDFResourceManager()
with open(output_path, "wb") as output:
with open(input_path, 'rb') as input:
with TextConverter(manager, output, codec='utf-8', laparams=LAParams()) as conv:
interpreter = PDFPageInterpreter(manager, conv)
for page in PDFPage.get_pages(input):
interpreter.process_page(page)
Reference
이 문제에 관하여(pdf에서 txt로 변환 1[pdfminer]), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ptxyasu/items/4180035bd0ccd789c858
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
pdf 파일에서 텍스트를 추출합니다.
사용한 것
이번에는 pdfminer를 사용했다.
htps : // 기주 b. 코 m / pdf f r / pdf f r. x
또, 이하의 기사도 참고로 했다.
htps : // 이 m/mc↑↑/있어 ms/894110558fb890c930b5
처리 흐름
1.Please input pdf path : 다음에 pdf 파일명 입력
2. 입력 파일 이름의 확장자를 .txt로 변경하고 텍스트 파일 작성
3. 그것에 결과 산출
같은 간단한 동작이다.
결과
방금 전의 pdf 파일을 지정해 본 결과가 이하이다.
하나의 화살표 만 출력되었습니다. 재미,
다른 pdf 파일로 확인하기 위해, word로 작성한 이하의 pdf를 지정해 본다.
결과는 다음과 같다.
또 방금 전의 화살표가 출력되고 있지만, 영어도 일본어도 잘 출력되고 있다.
프로그램이 문제가 아닌 것 같습니다.
pdf의 보호에 의한 문제라고 생각해 「pdf에 인쇄」로 보호를 해제해 보았지만,
또한 하나의 화살표 만 출력되었습니다.
고찰
pdfminer 자체가 잘 동작하고 있음을 확인할 수 있었기 때문에 문제는 pdf 파일에 있다고 생각된다.
대상의 pdf 파일이 스캔된 것인지, 화질이 거친 것이 원인이라고 생각한다.
프로그램
pdfminer가 너무 편리하기 때문에 매우 짧은 프로그램이되었습니다.
pdf2text.pyfrom pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
input_path = input("Please input pdf path : ")
output_path,ext = input_path.split(".")
output_path += ".txt"
manager = PDFResourceManager()
with open(output_path, "wb") as output:
with open(input_path, 'rb') as input:
with TextConverter(manager, output, codec='utf-8', laparams=LAParams()) as conv:
interpreter = PDFPageInterpreter(manager, conv)
for page in PDFPage.get_pages(input):
interpreter.process_page(page)
Reference
이 문제에 관하여(pdf에서 txt로 변환 1[pdfminer]), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ptxyasu/items/4180035bd0ccd789c858
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
1.Please input pdf path : 다음에 pdf 파일명 입력
2. 입력 파일 이름의 확장자를 .txt로 변경하고 텍스트 파일 작성
3. 그것에 결과 산출
같은 간단한 동작이다.
결과
방금 전의 pdf 파일을 지정해 본 결과가 이하이다.
하나의 화살표 만 출력되었습니다. 재미,
다른 pdf 파일로 확인하기 위해, word로 작성한 이하의 pdf를 지정해 본다.
결과는 다음과 같다.
또 방금 전의 화살표가 출력되고 있지만, 영어도 일본어도 잘 출력되고 있다.
프로그램이 문제가 아닌 것 같습니다.
pdf의 보호에 의한 문제라고 생각해 「pdf에 인쇄」로 보호를 해제해 보았지만,
또한 하나의 화살표 만 출력되었습니다.
고찰
pdfminer 자체가 잘 동작하고 있음을 확인할 수 있었기 때문에 문제는 pdf 파일에 있다고 생각된다.
대상의 pdf 파일이 스캔된 것인지, 화질이 거친 것이 원인이라고 생각한다.
프로그램
pdfminer가 너무 편리하기 때문에 매우 짧은 프로그램이되었습니다.
pdf2text.pyfrom pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
input_path = input("Please input pdf path : ")
output_path,ext = input_path.split(".")
output_path += ".txt"
manager = PDFResourceManager()
with open(output_path, "wb") as output:
with open(input_path, 'rb') as input:
with TextConverter(manager, output, codec='utf-8', laparams=LAParams()) as conv:
interpreter = PDFPageInterpreter(manager, conv)
for page in PDFPage.get_pages(input):
interpreter.process_page(page)
Reference
이 문제에 관하여(pdf에서 txt로 변환 1[pdfminer]), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ptxyasu/items/4180035bd0ccd789c858
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
pdfminer 자체가 잘 동작하고 있음을 확인할 수 있었기 때문에 문제는 pdf 파일에 있다고 생각된다.
대상의 pdf 파일이 스캔된 것인지, 화질이 거친 것이 원인이라고 생각한다.
프로그램
pdfminer가 너무 편리하기 때문에 매우 짧은 프로그램이되었습니다.
pdf2text.pyfrom pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
input_path = input("Please input pdf path : ")
output_path,ext = input_path.split(".")
output_path += ".txt"
manager = PDFResourceManager()
with open(output_path, "wb") as output:
with open(input_path, 'rb') as input:
with TextConverter(manager, output, codec='utf-8', laparams=LAParams()) as conv:
interpreter = PDFPageInterpreter(manager, conv)
for page in PDFPage.get_pages(input):
interpreter.process_page(page)
Reference
이 문제에 관하여(pdf에서 txt로 변환 1[pdfminer]), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ptxyasu/items/4180035bd0ccd789c858
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
input_path = input("Please input pdf path : ")
output_path,ext = input_path.split(".")
output_path += ".txt"
manager = PDFResourceManager()
with open(output_path, "wb") as output:
with open(input_path, 'rb') as input:
with TextConverter(manager, output, codec='utf-8', laparams=LAParams()) as conv:
interpreter = PDFPageInterpreter(manager, conv)
for page in PDFPage.get_pages(input):
interpreter.process_page(page)
Reference
이 문제에 관하여(pdf에서 txt로 변환 1[pdfminer]), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ptxyasu/items/4180035bd0ccd789c858텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)