pdf.info
result = pdf.info(src)
Input: src · Output: result
What it is
Reads what a PDF says about itself, without extracting any content. src (string path, or Vec of bytes) is the document.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = pdf.info(src) | src string or Vecnot documented yet | pages Numas pdf.page_countversion Strthe header version such as "1.6"producer Streach Str, or none where the file's /Info dictionary omits the key — none and "" are different answers and this does not merge themencrypted —Bool, whether the file carries an /Encrypt dictionary, which explains in advance why another call on it might fail | Returns a Record with fields: pages (Num, as pdf.page_count), version (Str, the header version such as "1.6"), title, author, subject, keywords, creator, producer (each Str, or none where the file's /Info dictionary omits the key — none and "" are different answers and this does not merge them), and encrypted (Bool, whether the file carries an /Encrypt dictionary, which explains in advance why another call on it might fail). |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
import pdf
i = pdf.info("paper.pdf")
print("{i.pages} pages, PDF {i.version}, produced by {i.producer}")
# Join two files, then take one page out of the result -- no disk in
# between, because every function also accepts bytes.
both = pdf.merge(["intro.pdf", "results.pdf"])
print(pdf.page_count(both))
pdf.write_pages("just_page_3.pdf", both, 3)
# A page range. `1 to 5` is already a Vec, so it just works.
pdf.write_pages("front.pdf", "paper.pdf", 1 to 5)
not run by the build — this one needs something the repository cannot supply · from file-io