diff --git a/changes.txt b/changes.txt index 6b064bf4a..7d5f1a97d 100644 --- a/changes.txt +++ b/changes.txt @@ -2,6 +2,67 @@ Change Log ========== + +**Changes in version** + +Fixed issues: + +* **Fixed** `4484 `_: set_toc does not correctly set y-positions +* **Fixed** `5175 `_: find_tables(lines_strict): opaque white fill+stroke rectangle creates a phantom row +* **Fixed** `5185 `_: pymupdf4llm: table cells drop the second letter of a ligature when quad corrections are unset +* **Fixed** `5198 `_: 2.0: Table.extract() moves the decimal point out of numbers ("0.74" comes back as "0 74", newline, ".") \u2014 regression from 1.28.2 +* **Fixed** `5238 `_: JM_new_lineart_device_Device.__init__ omits call parentheses on use_virtual_*_text, disabling SWIG director text callbacks +* **Fixed** `5239 `_: Document.set_toc_item() crashes on point-like tuple/list coordinates (AttributeError) and inverts dest_dict['to'] via in-place mutation +* **Fixed** `5240 `_: Document.delete_pages() raises ValueError: bad page number(s) on negative page numbers passed as two positional arguments +* **Fixed** `5241 `_: Table.to_pandas() permanently mutates Table.header.names in-place, corrupting column names and downstream exports #5241 +* **Fixed** `5280 `_: remove_rotation() stretches Square and Circle annotations #5280 + + +New features + +* Add extended FormFields Support. + + +Other: + +* Various small correctness fixes. + + - Archive.add(): fix broken assert (missing comma turned the error + message into part of the boolean expression, disabling the empty-name + check for binary content). + - Annot.file_info: avoid UnboundLocalError when a crafted/malformed + attachment's /FS dict has neither /UF nor /F. + - Page.set_language(): call pdfpage.obj() instead of passing the bound + method itself, which broke every call that actually sets a language. + - Widget.on_state(): skip None entries from button_states() instead of + raising TypeError. + - Pixmap.tobytes(): add missing f-string prefix so the alpha error + message actually includes the format name. + - JM_matrix_from_py(): fix copy-paste bug returning FzRect() instead of + FzMatrix() on the float-conversion failure path. + - utils.get_text(): remove a bare assert that made the documented + "misspelled option falls back to text" behavior unreachable. + - utils.get_label_pno(): return "" (as documented) instead of raising + IndexError when no label rule applies to the given page number. + - utils.get_sorted_text(): guard against ZeroDivisionError for + zero-width glyph bboxes. + - _apply_pages.py (method='fork'): send the actual page numbers to + workers instead of plain list indices, which silently processed the + wrong pages for any non-contiguous/non-zero-based `pages` list. + - table.chars_in_rect(): compare against c["top"]/c["bottom"] (top-down, + matching the rect from page.get_drawings()) instead of c["y0"]/c["y1"] + (PDF-native bottom-up space), fixing table detection for frames drawn + as filled rectangles. +* get_text: fail on unrecognized option instead of silently defaulting +* apply_pages(): Fix keyword forwarding in single-process page extraction, +* Fixed sysinstall of mupdf. +* Fix Document.convert_to_pdf() for page ranges that do not start at page 0 +* Some fixes for windows-x32. +* Preserve line breaks and hyphens in clean table Markdown +* Fix table header boldness checks to use page coordinates +* Continue letter page labels with AA, BB, ... after Z, as the PDF spec says + + **Changes in version 2.1** (2026-11-02) Fixed issues: diff --git a/tests/resources/test_4484.pdf b/tests/resources/test_4484.pdf new file mode 100644 index 000000000..fd89e1131 Binary files /dev/null and b/tests/resources/test_4484.pdf differ diff --git a/tests/test_tables.py b/tests/test_tables.py index d03bb9df3..96acfcef5 100644 --- a/tests/test_tables.py +++ b/tests/test_tables.py @@ -2004,3 +2004,18 @@ def test_5241(): names_after = list(tab.header.names) assert names_before == names_after, "Column headers changed by to_pandas()" + + +def test_5198(): + doc = pymupdf.open() + page = doc.new_page(width=595, height=842) + x0, y0, x1, y1, xm, ym = 72, 72, 472, 152, 272, 112 + for a, b in [((x0, y0), (x1, y0)), ((x0, ym), (x1, ym)), ((x0, y1), (x1, y1)), + ((x0, y0), (x0, y1)), ((xm, y0), (xm, y1)), ((x1, y0), (x1, y1))]: + page.draw_line(a, b) + for text, point in [("P for interaction", (80, 100)), ("Cooking fuel type", (280, 100)), + ("0.74", (80, 140)), ("12.5 mg", (280, 140))]: + page.insert_text(point, text, fontsize=11) + + print(pymupdf.__version__, [t.extract() for t in page.find_tables().tables]) + print([w[4] for w in page.get_text("words")]) diff --git a/tests/test_toc.py b/tests/test_toc.py index 65311a4f5..093342827 100644 --- a/tests/test_toc.py +++ b/tests/test_toc.py @@ -340,3 +340,14 @@ def test_5239(): link_dict = toc[0][-1] assert link_dict["to"] == p + +def test_4484(): + path = os.path.normpath(f'{__file__}/../../tests/resources/test_4484.pdf') + doc = pymupdf.open(path) + toc = [[1, 'Engine Fire In Flight', 0, 304.6222839355469]] + doc.set_toc(toc) + read_toc = doc.get_toc(simple=False) + desired_y_position = toc[0][3] + actual_y_position = read_toc[0][3]["to"][1] + dy = abs(actual_y_position - desired_y_position) + assert dy < 0.01, f'dy too large: {desired_y_position=} {actual_y_position=} {dy=}'