• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

OrganicWeb

Mailchimp Training & Consulting

  • Home
  • Services
    • Public Mailchimp Classes
    • Mailchimp Training – Group
    • Mailchimp Training – 1-on-1
    • Mailchimp Consulting
  • Content
    • Blog
    • Mailchimp Tutorials on YouTube
  • Contact & About
    • Contact
    • About

How To Add or Edit PDF Properties With Python

Unless you pay for a PDF writing application then it can seem difficult if you want to edit or add to PDF file properties. Adobe Acrobat Reader for example lets you view document properties (open the document then click File – Properties) but you need to have Acrobat Pro to be able to edit properties.

Fortunately it’s simple to add or amend PDF properties with Python and PyPDF2. The script below will help you edit and add PDF properties.

from PyPDF2 import PdfFileReader, PdfFileWriter

filein = open('C:/Users/username/Downloads/old_file.pdf', 'rb')
reader = PdfFileReader(filein)
writer = PdfFileWriter()

writer.appendPagesFromReader(reader)
metadata = reader.getDocumentInfo()
writer.addMetadata(metadata)

# Add your properties here:
writer.addMetadata({
    '/Author': 'Your Name',
    '/Keywords':'your,keywords',
    '/Subject':'Your subject',
    '/Title':'Enter the document title'
})

fileout = open('C:/Users/username/Downloads/new_file.pdf', 'wb')
writer.write(fileout)

filein.close()
fileout.close()

I found this code online however am unable to locate the original source.

Found this useful? Please share:

  • How Can I Edit an Attachment in Mailchimp? [Solved]
  • How to add a PDF attachment to Mailchimp
  • How to send an attachment in Mailchimp

Filed Under: General March 2022

Watch Gary in action

Gary frequently adds Mailchimp instructional videos to his YouTube channel. Subscribe to keep updated.

→  Subscribe   ←

Add a survey (and answers) into a Mailchimp email.

Create high-converting buttons in Mailchimp.

Reader Interactions

Leave a ReplyCancel reply

You are here: Home / General / How To Add or Edit PDF Properties With Python

Primary Sidebar

Get Mailchimp Class Updates

Get class updates

Mailchimp write about my work

Read on Mailchimp.com

Gary on Australian National Radio

Changes are coming to the Australian Spam Act

Read Gary's article in SmartCompany

Meet Gary, Mailchimp Expert

Gary is a Mailchimp Expert and Partner. He delivers Mailchimp training and consulting services in Australia, New Zealand and Singapore. Gary presents at Mailchimp events and hosts the first, and only, Australian Mailchimp sponsored event. He is M.B.A. qualified from Henley Business School, U.K.

Contact Gary for your Mailchimp needs

Footer

Customer Rating

Get class updates

Mailchimp Pro Partners

Contact

Contact Gary for all your Mailchimp training, consulting and integration needs.

gary@organicweb.com.au
0410923445

Copyright © 2023 · Sitemap · ABN: 40800872179 · Privacy Policy · Terms of Service