Skip to content

Commit

Permalink
Merge pull request #1155 from bcgov/dev-AA-prodissue-foimod-3469
Browse files Browse the repository at this point in the history
#FOIMOD-3469 removed condition for metadata!
  • Loading branch information
abin-aot authored Sep 19, 2024
2 parents 39c3825 + 782074e commit 4e6d6de
Showing 1 changed file with 15 additions and 12 deletions.
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

0 comments on commit 4e6d6de

Please sign in to comment.