I want to read the text of 16000 pdf files in an R dataframe. Most of the pdfs are no Problem, pdf_text("link") gives the right output. The problem is that some PDFS have no copyable text. With them I get a following (sample) output:
"0123145456789 20ÿ\016\017ÿ\020\021\022ÿ\023\024\020\024\025\022ÿ\026\023ÿ\027\026\016\022\020\025\030ÿ\031\026\032\033\034\030ÿÿ\035\026\036\022\025\016\026\025ÿ\035 \037\025\033\022\032ÿ !\021\032\026\024\023\r\n ()*+ÿ-./.0012ÿ34ÿ5656ÿ7M9^.C=19ÿO=CDÿ-_`MQÿ-19GEHFC=19ÿ\.GW:CG7\r\n ()5+ÿ8.9:2ÿ;4ÿ5656ÿ7N10=@=:GÿJ1>ÿCD:ÿa>:.Cÿa01V.0ÿ<DECA1O9ÿ.9Aÿ\:K19A7\r\n ())+ÿ<:=0:>2ÿ5656ÿ7-1/=AÿY@191H=@Gbÿ̀:CC:Aÿ.9Aÿ>:.0cC=H:ÿF.F:>G7\r\n"
The solution is of course a. Do not read out all these texts b. Read the texts by OCR
But since this method either excludes many texts or is very time-consuming, I would like to recognize the problematic texts beforehand. Is there an easy way to do this in R?
text_raw<-pdf_text("link")
if(text_raw is nonsense){
text<-pdf_ocr_text(text_raw)
}else{
text<-text_raw
}