# PDF Library (Pdf)

Functions for working with PDF files, loaded into Stof via the custom Data type. Requires the "pdf" feature flag to be enabled.

## Pdf.extract\_images(pdf: Data\<Pdf>) -> list

Given a data pointer to a PDF document, extract all images from every page, returning them as a list of maps with image data.

```rust
// import './test_stof_pdf.pdf'; // taken from stof PDF format tests
const images = self.pdf.extract_images();
assert_eq(images.len(), 1);
assert_eq(images[0].get('height'), 500);
assert_eq(images[0].get('width'), 1250);
```

## Pdf.extract\_text(pdf: Data\<Pdf>) -> str

Given a data pointer to a PDF document, extract all text from the PDF file and return it as a string.

```rust
// import './test_stof_pdf.pdf'; // taken from stof PDF format tests
const text = self.pdf.extract_text();
assert_eq(text, "Example Stof\nDocument\n");
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stof.dev/libraries/pdf-library-pdf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
