ZelluX ZelluX - 1 year ago 104
Python Question

Extracting titles from PDF files?

I want to write a script to rename downloaded papers with their titles automatically, I'm wondering if there is any library or tricks i can make use of? The PDFs are all generated by TeX and should have some 'formal' structures.

Answer Source

You could try to use pyPdf and this example.

for example:

from pyPdf import PdfFileWriter, PdfFileReader

def get_pdf_title(pdf_file_path):
    with open(pdf_file_path) as f:
        pdf_reader = PdfFileReader(f) 
        return pdf_reader.getDocumentInfo().title

title = get_pdf_title('/home/user/Desktop/my.pdf')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download