Reputation: 31
I have a function that is passed a pdfplumber.pdf.PDF
argument and I need to reference the filename of the PDF. Is there any way to get the filename from a pdfplumber.pdf.PDF
class instance?
Upvotes: 0
Views: 450
Reputation: 31
Yes, if pdf
is a pdfplumber.pdf.PDF
, then you can easily find the filename:
import pdfplumber
pdf = pdfplumber.open('your.pdf')
filename = pdf.stream.name
print(filename)
Upvotes: 1