Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1900,8 +1900,8 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
nonlocal char_scale, space_scale, _space_width, TL, font_size, cmap
nonlocal orientations, rtl_dir, visitor_text, output, text, _actual_str_size

check_crlf_space: bool = False
str_widths: float = 0.0

# Table 5.4 page 405
if operator == b"BT":
tm_matrix = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
Expand All @@ -1919,6 +1919,7 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
text = ""
memo_cm = cm_matrix.copy()
memo_tm = tm_matrix.copy()

# Table 4.7 "Graphics state operators", page 219
# cm_matrix calculation is reserved for later
elif operator == b"q":
Expand Down Expand Up @@ -1957,6 +1958,7 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
)
memo_cm = cm_matrix.copy()
memo_tm = tm_matrix.copy()

# Table 5.2 page 398
elif operator == b"Tz":
char_scale = float(operands[0]) / 100 if operands else 1.0
Expand Down Expand Up @@ -2005,7 +2007,6 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
pass # keep previous size
# Table 5.5 page 406
elif operator == b"Td":
check_crlf_space = True
# A special case is a translating only tm:
# tm = [1, 0, 0, 1, e, f]
# i.e. tm[4] += tx, tm[5] += ty.
Expand All @@ -2015,18 +2016,15 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
str_widths = compute_str_widths(_actual_str_size["str_widths"])
_actual_str_size["str_widths"] = 0.0
elif operator == b"Tm":
check_crlf_space = True
tm_matrix = [float(operand) for operand in operands[:6]]
str_widths = compute_str_widths(_actual_str_size["str_widths"])
_actual_str_size["str_widths"] = 0.0
elif operator == b"T*":
check_crlf_space = True
tm_matrix[4] -= TL * tm_matrix[2]
tm_matrix[5] -= TL * tm_matrix[3]
str_widths = compute_str_widths(_actual_str_size["str_widths"])
_actual_str_size["str_widths"] = 0.0
elif operator == b"Tj":
check_crlf_space = True
text, rtl_dir, _actual_str_size = self._handle_tj(
text,
operands,
Expand All @@ -2043,7 +2041,7 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
else:
return

if check_crlf_space:
if operator in ( b"Td", b"Tm", b"T*", b"Tj"):
try:
text, output, cm_prev, tm_prev = crlf_space_check(
text,
Expand Down
Loading