File tree Expand file tree Collapse file tree 5 files changed +46
-14
lines changed
Expand file tree Collapse file tree 5 files changed +46
-14
lines changed Original file line number Diff line number Diff line change 7979 $ ( '#run-button' )
8080 . addClass ( 'disabled' )
8181 . attr ( 'disabled' , true )
82+
83+ } else if ( response . file_info . has_text ) {
84+
85+ $ ( '#run-button' ) . hide ( ) ;
86+ $ ( '#upload-has-text' ) . show ( ) ;
87+
8288 } else {
8389 $ ( '#run-button' )
8490 . removeClass ( 'disabled' )
8591 . attr ( 'disabled' , false )
92+ . show ( )
8693 }
8794 } ;
8895 } ,
164171 $ ( document ) . ready ( function ( ) {
165172 upload_in_progress = false ;
166173 $ ( '.button-box' ) . hide ( ) ;
174+ $ ( '#upload-has-text' ) . hide ( ) ;
167175 $ ( '#in-progress' ) . hide ( ) ;
168- $ ( '#pdf-file' ) . attr ( 'disabled' , false ) ;
176+
177+ $ ( '#pdf-file' )
178+ . attr ( 'disabled' , false )
179+ . val ( '' )
180+
169181 $ ( '#progress-bar-inner' ) . css ( 'width' , '0%' ) ;
170182 $ ( '#pdf-file' )
171183 . attr ( 'disabled' , false )
Original file line number Diff line number Diff line change 8080 color : red;
8181 }
8282
83+ .success-msg {
84+ padding-top : 1em ;
85+ color : green;
86+ }
87+
88+ .black-text {
89+ color : # 000 ;
90+ }
91+
8392 .button-box {
8493 display : flex;
8594 flex : 1 ;
245254 Add text to an image PDF.
246255 </ div >
247256
248- < form id ="param-form " action ="/ocr/upload/ " method ="POST " enctype ="multipart/form-data ">
257+ < form id ="param-form " action ="/ocr/upload/ " method ="POST " autocomplete =" off " enctype ="multipart/form-data ">
249258
250259 < div class ="option-box ">
251260 </ div >
@@ -288,19 +297,27 @@ <h3 id="filename"></h3>
288297 < i class ="fa fa-upload "> </ i >
289298 Run OCR
290299 </ div >
291-
292- < div id ="run-force " class ="button " style ="width: 8em " onclick ="runOCR(true) ">
293- < i class ="fa fa-upload "> </ i >
294- Force OCR
295- </ div >
296- < div class ="help-label ">
297- < i class ="fa fa-question-circle " title ="Forcing OCR will replace any existing text with OCRd text. If there is a question, it's likely better to try 'Run OCR' first. "> </ i >
298- </ div >
299300 </ div >
300301
301302 < div id ="upload-error " class ="small error " style ="display: none; ">
302303 </ div >
303304
305+ < div id ="upload-has-text " class ="small success-msg " style ="display: none; ">
306+ < span style ="font-size: 1.2em ">
307+ < i class ="fa fa-check "> </ i >
308+ </ span >
309+ This document already has selectable text and is most likely ready to use for annotations.
310+ < br > < br >
311+ If the quality of the current OCR'd text is not acceptable you can redo the OCR process which may give better results.
312+ < br >
313+ (This process will take some time and in rare instances will not be successful, depending on the qualities of the uploaded document).
314+ < br > < br >
315+ < div id ="run-force " class ="button black-text " style ="width: 8em " onclick ="runOCR(true) ">
316+ < i class ="fa fa-upload "> </ i >
317+ Redo OCR
318+ </ div >
319+ </ div >
320+
304321 </ div >
305322
306323 </ form >
Original file line number Diff line number Diff line change 162162 OCR in progress. Started at < span id ="time-start "> </ span >
163163 </ p >
164164 < p >
165- Large files can sometimes take several minutes, or up to five or ten if the Force OCR option is used .
165+ Large files can sometimes take several minutes, or up to five or ten if the OCR is a redo with existing text .
166166 </ p >
167167 < p >
168168 A clickable download link will appear when processing is complete.
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ def upload(request):
7070
7171 #already_has_text?
7272 if check_pdf_has_text (new_filename ):
73- processing_error = 'This PDF already has text. Use the "Force OCR" button to overwrite text with a fresh OCR if desired. If file was OCRd on previous upload those results will be provided'
73+ #processing_error = 'This PDF already has text. Use the "Force OCR" button to overwrite text with a fresh OCR if desired. If file was OCRd on previous upload those results will be provided'
74+ has_text = True
75+ else :
76+ has_text = False
7477
7578
7679 if not existing_name :
@@ -114,7 +117,7 @@ def upload(request):
114117 data = {'file_info' : {'filename' : filename , 'size' : file_ .size ,
115118 'new_filename' : new_filename , 'processing_error' : processing_error ,
116119 'tempfile_path' : tempfile_path , 'already_exists' : already_exists ,
117- 'md5_hash' : md5_hash }}
120+ 'md5_hash' : md5_hash , 'has_text' : has_text }}
118121
119122 return JsonResponse (data )
120123
Original file line number Diff line number Diff line change 55
66from django .conf import settings
77
8- app = Celery ('financial_planning_app ' , broker = settings .BROKER_URL )
8+ app = Celery ('droppdf_app ' , broker = settings .BROKER_URL )
99
1010app .config_from_object ('django.conf:settings' , namespace = 'CELERY' )
1111app .autodiscover_tasks (lambda : settings .INSTALLED_APPS )
You can’t perform that action at this time.
0 commit comments