Remove Metadata from PDF in Python

Contents
[ ]

To remove Metadata from Pdf document using Aspose.PDF Java for Python, simply invoke RemoveMetadata class.

Python Code


doc= self.Document()
pdf = self.Document()
pdf=self.dataDir + 'input1.pdf'

if (re.findall('/pdfaid:part/',doc.getMetadata())):
doc.getMetadata().removeItem("pdfaid:part")


if (re.findall('/dc:format/',doc.getMetadata())):
doc.getMetadata().removeItem("dc:format")


# save update document with new information
doc.save(self.dataDir + "Remove_Metadata.pdf")

print "Removed metadata successfully, please check output file."

Download Running Code

Download Remove Metadata (Aspose.PDF) from any of the below mentioned social coding sites: