0

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?

Keegan Skeate
  • 21
  • 2
  • 6

1 Answers1

1

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)
Keegan Skeate
  • 21
  • 2
  • 6