Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set_metadata() does not work #3237

Open
JorjMcKie opened this issue Mar 7, 2024 Discussed in #3236 · 2 comments
Open

Set_metadata() does not work #3237

JorjMcKie opened this issue Mar 7, 2024 Discussed in #3236 · 2 comments

Comments

@JorjMcKie
Copy link
Collaborator

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

@JorjMcKie JorjMcKie added the bug label Mar 7, 2024
@JorjMcKie
Copy link
Collaborator Author

This only pertains to missing updating the dictionary afterwards. The document is being changed and can be save as expected.

@julian-smith-artifex-com
Copy link
Collaborator

Addressed in #3555.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants