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

#FOIMOD-3469 removed condition for metadata! #1155

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions computingservices/ZippingServices/services/zipperservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ def __zipfilesandupload(_message, s3credentials):

try:
_formattedbytes = __removesensitivecontent(_docbytes)
print("_formattedbytes length is {0}".format(len(_formattedbytes)))
if _formattedbytes is not None:
print("_formattedbytes length is {0}".format(len(_formattedbytes)))
else:
print("_formattedbytes is none")
except Exception:
print("error happened while removing sensitive content of {0} ".format(filename))
print(traceback.format_exc())
Expand Down Expand Up @@ -152,17 +155,17 @@ def __removesensitivecontent(documentbytes):
# clear metadata
reader2 = PyPDF2.PdfReader(BytesIO(documentbytes))
# Check if metadata exists.
if reader2.metadata is not None:
# Create a new PDF file without metadata.
writer = PyPDF2.PdfWriter()
# Copy pages from the original PDF to the new PDF.
for page_num in range(len(reader2.pages)):
page = reader2.pages[page_num]
writer.add_page(page)
#writer.remove_links() # to remove comments.
buffer = BytesIO()
writer.write(buffer)
return buffer.getvalue()
#if reader2.metadata is not None:
# Create a new PDF file without metadata.
writer = PyPDF2.PdfWriter()
# Copy pages from the original PDF to the new PDF.
for page_num in range(len(reader2.pages)):
page = reader2.pages[page_num]
writer.add_page(page)
#writer.remove_links() # to remove comments.
buffer = BytesIO()
writer.write(buffer)
return buffer.getvalue()


def __getzipfilepath(foldername, filename):
Expand Down
Loading