()
| 2056 | |
| 2057 | |
| 2058 | def test_4590(): |
| 2059 | |
| 2060 | # Create test PDF. |
| 2061 | path = os.path.normpath(f'{__file__}/../../tests/test_4590.pdf') |
| 2062 | with pymupdf.open() as document: |
| 2063 | page = document.new_page() |
| 2064 | |
| 2065 | # Add some text |
| 2066 | text = 'This PDF contains a file attachment annotation.' |
| 2067 | page.insert_text((72, 72), text, fontsize=12) |
| 2068 | |
| 2069 | # Create a sample file. |
| 2070 | path_sample = os.path.normpath(f'{__file__}/../../tests/test_4590_annotation_sample.txt') |
| 2071 | with open(path_sample, 'w') as f: |
| 2072 | f.write('This is a sample attachment file.') |
| 2073 | |
| 2074 | # Read file as bytes |
| 2075 | with open(path_sample, 'rb') as f: |
| 2076 | sample = f.read() |
| 2077 | |
| 2078 | # Define annotation position (rect or point) |
| 2079 | annot_pos = pymupdf.Rect(72, 100, 92, 120) # PushPin icon rectangle |
| 2080 | |
| 2081 | # Add the file attachment annotation |
| 2082 | page.add_file_annot( |
| 2083 | point = annot_pos, |
| 2084 | buffer_ = sample, |
| 2085 | filename = 'sample.txt', |
| 2086 | ufilename = 'sample.txt', |
| 2087 | desc = 'A test attachment file.', |
| 2088 | icon = 'PushPin', |
| 2089 | ) |
| 2090 | |
| 2091 | # Save the PDF |
| 2092 | document.save(path) |
| 2093 | |
| 2094 | # Check pymupdf.Document.scrub() works. |
| 2095 | with pymupdf.open(path) as document: |
| 2096 | document.scrub() |
| 2097 | |
| 2098 | |
| 2099 | def test_4702(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…