Skip to content

Commit 2c643d8

Browse files
committed
Reduce diff
1 parent 9608900 commit 2c643d8

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

pypdf/_text_extraction/_text_extractor.py

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -480,46 +480,6 @@ def _handle_position_change(self, str_widths: float) -> None:
480480
except OrientationNotFoundError:
481481
return
482482

483-
def _handle_tj(
484-
self,
485-
text: str,
486-
operands: List[Union[str, TextStringObject]],
487-
cm_matrix: List[float],
488-
tm_matrix: List[float],
489-
cmap: Tuple[Union[str, Dict[int, str]], Dict[str, str], str, Optional[DictionaryObject]],
490-
orientations: Tuple[int, ...],
491-
font_size: float,
492-
rtl_dir: bool,
493-
visitor_text: Optional[Callable[[Any, Any, Any, Any, Any], None]],
494-
space_width: float,
495-
actual_str_size: Dict[str, float],
496-
) -> Tuple[str, bool, Dict[str, float]]:
497-
"""Handle text showing operations."""
498-
text_operands, is_str_operands = get_text_operands(operands, cm_matrix, tm_matrix, cmap, orientations)
499-
if is_str_operands:
500-
text += text_operands
501-
else:
502-
text, rtl_dir = get_display_str(
503-
text,
504-
cm_matrix,
505-
tm_matrix, # text matrix
506-
cmap,
507-
text_operands,
508-
font_size,
509-
rtl_dir,
510-
visitor_text,
511-
)
512-
513-
font_widths, actual_str_size["space_width"], actual_str_size["str_height"] = self._get_actual_font_widths(
514-
cmap,
515-
text_operands,
516-
font_size,
517-
space_width,
518-
)
519-
actual_str_size["str_widths"] += font_widths
520-
521-
return text, rtl_dir, actual_str_size
522-
523483
def _get_actual_font_widths(
524484
self,
525485
cmap: Tuple[Union[str, Dict[int, str]], Dict[str, str], str, Optional[DictionaryObject]],
@@ -559,3 +519,44 @@ def _get_actual_font_widths(
559519

560520
return (font_widths * font_size, space_width * font_size, font_size)
561521

522+
523+
524+
def _handle_tj(
525+
self,
526+
text: str,
527+
operands: List[Union[str, TextStringObject]],
528+
cm_matrix: List[float],
529+
tm_matrix: List[float],
530+
cmap: Tuple[Union[str, Dict[int, str]], Dict[str, str], str, Optional[DictionaryObject]],
531+
orientations: Tuple[int, ...],
532+
font_size: float,
533+
rtl_dir: bool,
534+
visitor_text: Optional[Callable[[Any, Any, Any, Any, Any], None]],
535+
space_width: float,
536+
actual_str_size: Dict[str, float],
537+
) -> Tuple[str, bool, Dict[str, float]]:
538+
"""Handle text showing operations."""
539+
text_operands, is_str_operands = get_text_operands(operands, cm_matrix, tm_matrix, cmap, orientations)
540+
if is_str_operands:
541+
text += text_operands
542+
else:
543+
text, rtl_dir = get_display_str(
544+
text,
545+
cm_matrix,
546+
tm_matrix, # text matrix
547+
cmap,
548+
text_operands,
549+
font_size,
550+
rtl_dir,
551+
visitor_text,
552+
)
553+
554+
font_widths, actual_str_size["space_width"], actual_str_size["str_height"] = self._get_actual_font_widths(
555+
cmap,
556+
text_operands,
557+
font_size,
558+
space_width,
559+
)
560+
actual_str_size["str_widths"] += font_widths
561+
562+
return text, rtl_dir, actual_str_size

0 commit comments

Comments
 (0)