pdf.write_pages
pdf.write_pages(path, src, pages)
Input: path, src, pages · Output: no output
What it is
Exactly pdf.extract_pages, written to a file instead of returned. path (string) is the destination, overwritten if it exists. Denied in sandboxed execution.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
pdf.write_pages(path, src, pages) | path stringpath (string) is the destination, overwritten if it exists.src —not documented yetpages —not documented yet | no output | Exactly pdf.extract_pages, written to a file instead of returned. Denied in sandboxed execution. |
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
import pdf
doc = pdf.merge(["intro.pdf", "results.pdf"])
doc = pdf.add_bookmark(doc, "Introduction", 1)
doc = pdf.add_bookmark(doc, "Results", 3)
rows = pdf.outlines(doc)
print(rows) # index, level, parent_index, title, page_index
doc = pdf.add_annotation(doc, 1, type = "Text", rect = [10, 10, 200, 40], text = "draft")
doc = pdf.add_attachment(doc, "notes.txt", "notes.txt")
pdf.write_pages("with_extras.pdf", doc, 1 to pdf.page_count(doc))
not run by the build — this one needs something the repository cannot supply · from file-io