Qu

pdf.extract_pages

Builtin index · File I/O

result = pdf.extract_pages(src, pages)

Input: src, pages · Output: result

What it is

A new PDF holding just the pages asked for. src (string path, or Vec of bytes) is the document; pages is a page number, or a Vec/List of them (1 to 3 works — it is already a Vec), numbered from 1. Pages come out in the document's order, not the order asked for, and a page the document does not have is a named error rather than a silently shorter file. Implemented by removing the other pages, so the ones that stay keep their own fonts, resources and annotations.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = pdf.extract_pages(src, pages)
src string or Vecsrc (string path, or Vec of bytes) is the document.
pages number, Vec, or Listpages is a page number, or a Vec/List of them (1 to 3 works — it is already a Vec), numbered from 1.
result Vec
Returns a Vec of bytes.

Examples

No documentation example calls this form yet. The File I/O chapter is where one belongs.