-
Notifications
You must be signed in to change notification settings - Fork 664
Closed
Labels
Description
Discussed in #3236
Originally posted by rockerjunge March 7, 2024
Description of the bug
I'm new to programming and still finding my way around, but I've encountered an issue with the set_metadata() function. Unfortunately, I can't seem to get it to work correctly. Below is my code where I've implemented this method. Despite my efforts, both print statements yield identical results, with the metadata still present.
How to reproduce the bug
import os
import fitz
def test_method(input_dir, output_dir):
for filename in os.listdir(input_dir):
if filename.endswith(".pdf"):
pdf_path = os.path.join(input_dir, filename)
output_path = os.path.join(output_dir, filename.replace(".pdf", "_test.pdf"))
doc = fitz.open(pdf_path)
print(doc.metadata)
doc.set_metadata({})
print(doc.metadata)
doc.save(output_path, garbage=4)
doc.close()
input_dir = "H:\\Schwärzer Test"
output_dir = "H:\\Schwärzer Test\\Geschwaerzt"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
test_method(input_dir, output_dir)
PyMuPDF version
1.23.26
Operating system
Windows
Python version
3.11