()
| 981 | archive = pymupdf.Archive(p) |
| 982 | |
| 983 | def test_3140(): |
| 984 | css2 = '' |
| 985 | path = os.path.abspath(f'{__file__}/../../tests/resources/2.pdf') |
| 986 | oldfile = os.path.abspath(f'{__file__}/../../tests/test_3140_old.pdf') |
| 987 | newfile = os.path.abspath(f'{__file__}/../../tests/test_3140_new.pdf') |
| 988 | import shutil |
| 989 | shutil.copy2(path, oldfile) |
| 990 | def next_fd(): |
| 991 | fd = os.open(path, os.O_RDONLY) |
| 992 | os.close(fd) |
| 993 | return fd |
| 994 | fd1 = next_fd() |
| 995 | with pymupdf.open(oldfile) as doc: # open document |
| 996 | page = doc[0] |
| 997 | rect = pymupdf.Rect(130, 400, 430, 600) |
| 998 | CELLS = pymupdf.make_table(rect, cols=3, rows=5) |
| 999 | shape = page.new_shape() # create Shape |
| 1000 | for i in range(5): |
| 1001 | for j in range(3): |
| 1002 | qtext = "<b>" + "Ques #" + str(i*3+j+1) + ": " + "</b>" # codespell:ignore |
| 1003 | atext = "<b>" + "Ans:" + "</b>" # codespell:ignore |
| 1004 | qtext = qtext + '<br>' + atext |
| 1005 | shape.draw_rect(CELLS[i][j]) # draw rectangle |
| 1006 | page.insert_htmlbox(CELLS[i][j], qtext, css=css2, scale_low=0) |
| 1007 | shape.finish(width=2.5, color=pymupdf.pdfcolor["blue"], ) |
| 1008 | shape.commit() # write all stuff to the page |
| 1009 | doc.subset_fonts() |
| 1010 | doc.ez_save(newfile) |
| 1011 | fd2 = next_fd() |
| 1012 | assert fd2 == fd1, f'{fd1=} {fd2=}' |
| 1013 | os.remove(oldfile) |
| 1014 | |
| 1015 | def test_cli(): |
| 1016 | if os.environ.get('PYODIDE_ROOT'): |
nothing calls this directly
no test coverage detected
searching dependent graphs…