@@ -44,6 +44,10 @@ pub struct ConverterOptions {
4444 /// proper Latin word spacing) or `"ch"` (the multilingual
4545 /// docling-conformance model). Formats that never OCR ignore it.
4646 pub ocr_lang : Option < String > ,
47+ /// OCR every PDF page even when it carries an embedded text layer
48+ /// (docling's `force_full_page_ocr`) — for text layers that exist but lie.
49+ /// Default `false`.
50+ pub force_full_page_ocr : Option < bool > ,
4751 /// Emit cleaner, more conformant Markdown (code-fence languages preserved,
4852 /// no inline-run spacing artifacts) instead of docling's byte-for-byte
4953 /// legacy output. Markdown only. Default `false`.
@@ -86,6 +90,9 @@ pub struct ConvertOptions {
8690 pub pages : Option < String > ,
8791 /// OCR recognition language for scanned pages: `"en"` (default) | `"ch"`.
8892 pub ocr_lang : Option < String > ,
93+ /// OCR every PDF page even when it carries a text layer (docling's
94+ /// `force_full_page_ocr`). Default `false`.
95+ pub force_full_page_ocr : Option < bool > ,
8996 pub allowed_formats : Option < Vec < String > > ,
9097 pub to : Option < String > ,
9198 pub image_mode : Option < String > ,
@@ -142,6 +149,7 @@ struct ConvertConfig {
142149 video_frames : Option < usize > ,
143150 page_range : Option < ( usize , usize ) > ,
144151 ocr_lang : Option < String > ,
152+ force_full_page_ocr : bool ,
145153 allowed_formats : Option < Vec < InputFormat > > ,
146154 to : OutputKind ,
147155 image_mode : ImageMode ,
@@ -201,6 +209,7 @@ fn build_config(o: ConvertOptions) -> Result<ConvertConfig> {
201209 video_frames : o. video_frames . map ( |n| n as usize ) ,
202210 page_range : parse_pages ( o. pages . as_deref ( ) ) ?,
203211 ocr_lang : parse_ocr_lang ( o. ocr_lang ) ?,
212+ force_full_page_ocr : o. force_full_page_ocr . unwrap_or ( false ) ,
204213 allowed_formats : allowed,
205214 to : parse_output_kind ( o. to . as_deref ( ) ) ?,
206215 image_mode : parse_image_mode ( o. image_mode . as_deref ( ) ) ?,
@@ -231,6 +240,7 @@ fn build_converter(cfg: &ConvertConfig) -> RsConverter {
231240 let base = base
232241 . strict ( cfg. strict )
233242 . fetch_images ( cfg. fetch_images )
243+ . force_full_page_ocr ( cfg. force_full_page_ocr )
234244 . asr_model ( cfg. asr_model . clone ( ) ) ;
235245 let base = match cfg. video_frames {
236246 Some ( max) => base. video_frames ( max) ,
@@ -416,6 +426,7 @@ pub struct DocumentConverter {
416426 video_frames : Option < usize > ,
417427 page_range : Option < ( usize , usize ) > ,
418428 ocr_lang : Option < String > ,
429+ force_full_page_ocr : bool ,
419430 allowed_formats : Option < Vec < InputFormat > > ,
420431}
421432
@@ -439,6 +450,7 @@ impl DocumentConverter {
439450 video_frames : o. video_frames . map ( |n| n as usize ) ,
440451 page_range : parse_pages ( o. pages . as_deref ( ) ) ?,
441452 ocr_lang : parse_ocr_lang ( o. ocr_lang . clone ( ) ) ?,
453+ force_full_page_ocr : o. force_full_page_ocr . unwrap_or ( false ) ,
442454 allowed_formats : allowed,
443455 } )
444456 }
@@ -452,6 +464,7 @@ impl DocumentConverter {
452464 video_frames : self . video_frames ,
453465 page_range : self . page_range ,
454466 ocr_lang : self . ocr_lang . clone ( ) ,
467+ force_full_page_ocr : self . force_full_page_ocr ,
455468 allowed_formats : self . allowed_formats . clone ( ) ,
456469 to : parse_output_kind ( out. to . as_deref ( ) ) ?,
457470 image_mode : parse_image_mode ( out. image_mode . as_deref ( ) ) ?,
@@ -865,6 +878,7 @@ fn output_config(out: Option<OutputOptions>, strict: bool) -> Result<ConvertConf
865878 asr_model : None ,
866879 video_frames : None ,
867880 page_range : None ,
881+ force_full_page_ocr : false ,
868882 ocr_lang : None ,
869883 allowed_formats : None ,
870884 to : parse_output_kind ( out. to . as_deref ( ) ) ?,
0 commit comments