diff --git a/pdfconduit/conduit/encrypt.py b/pdfconduit/conduit/encrypt.py index 86544ce7..f319ff8e 100644 --- a/pdfconduit/conduit/encrypt.py +++ b/pdfconduit/conduit/encrypt.py @@ -58,8 +58,8 @@ def encrypt(self, decrypt=None): # todo: add metadata adding functionality pdf_writer.addMetadata({ '/Producer': 'pdfconduit', - '/Creator': 'HPA Design', - '/Author': 'HPA Design', + '/Creator': 'pdfconduit', + '/Author': 'Stephen Neal', }) # Write encrypted PDF to file diff --git a/pdfconduit/transform/merge.py b/pdfconduit/transform/merge.py index aa5e68fd..2a31fe9d 100644 --- a/pdfconduit/transform/merge.py +++ b/pdfconduit/transform/merge.py @@ -64,10 +64,9 @@ def pdfrw(pdf_files, output): writer.addpages(PdfReader(inpfn).pages) writer.trailer.Info = IndirectPdfDict( - Title='HPA Design', - Author='HPA Design', - Subject='HPA Design', - Creator='HPA Design', + Author='Stephen Neal', + Creator='pdfconduit', + Producer='pdfconduit', ) writer.write(output) return output diff --git a/tests/test_conduit_encrypt.py b/tests/test_conduit_encrypt.py index 7f83ad9f..de62869b 100644 --- a/tests/test_conduit_encrypt.py +++ b/tests/test_conduit_encrypt.py @@ -189,6 +189,23 @@ def test_password_byte_string(self): b'\xd0H\xd1R\x9eS]\x18\x84\xcd8V6{\x18KJ\x90\xdf\x01\xe67\xd1n\xca\x06[\xafNd\x90\x0b' ) + @Timer.decorator + def test_encrypted_pdf_has_metadata(self): + encrypted = Encrypt(self.pdf_path, + self.user_pw, + self.owner_pw, + output=self.temp.name, + bit128=True, + suffix='metadata') + + self.assertPdfExists(encrypted) + self.assertEncrypted(encrypted) + + metadata = Info(encrypted.output, self.user_pw).metadata + self.assertEqual(metadata['/Producer'], 'pdfconduit') + self.assertEqual(metadata['/Creator'], 'pdfconduit') + self.assertEqual(metadata['/Author'], 'Stephen Neal') + def _getPdfSecurity(self, encrypted): return Info(encrypted.output, self.user_pw).security diff --git a/tests/test_transform_merge.py b/tests/test_transform_merge.py index 5a3d681d..6dee2473 100644 --- a/tests/test_transform_merge.py +++ b/tests/test_transform_merge.py @@ -30,6 +30,10 @@ def test_merge_pypdf3(self): # Assert sum of pages in original pdf files equals sum of pages in merged pdf self.assertEqual(sum([Info(pdf).pages for pdf in self.pdfs]), Info(merged.file).pages) + # Assert metadata was added correctly + metadata = Info(merged.output).metadata + self.assertEqual(metadata['/Producer'], 'PyPDF3') + @Timer.decorator def test_merge_pdfrw(self): """Merge multiple PDF files into a single PDF using the `pdfrw` library.""" @@ -41,6 +45,12 @@ def test_merge_pdfrw(self): # Assert sum of pages in original pdf files equals sum of pages in merged pdf self.assertEqual(sum([Info(pdf).pages for pdf in self.pdfs]), Info(merged.file).pages) + # Assert metadata was added correctly + metadata = Info(merged.output).metadata + self.assertEqual(metadata['/Producer'], 'pdfconduit') + self.assertEqual(metadata['/Creator'], 'pdfconduit') + self.assertEqual(metadata['/Author'], 'Stephen Neal') + if __name__ == '__main__': unittest.main()