> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# pdfinfo

> Print a PDF file's metadata and page sizes with poppler's pdfinfo command line.

Print a PDF file's document information: its metadata, page count, page
size, encryption and PDF version. Mirage implements
[poppler](https://poppler.freedesktop.org)'s `pdfinfo` fields, messages and
exit codes with its own PDF reader.

## Setup

`pdfinfo` has no account config. It reads PDF files through existing mounts.

```python theme={null}
from mirage import Workspace
from mirage.commands.cli.builtin.pdf import PDFINFO
from mirage.vfs.ram import RAMVFS

ws = Workspace({"/data/": RAMVFS()})
ws.register_cli("pdfinfo", PDFINFO)
```

For YAML registration, see the [CLI overview](https://docs.mirage.strukto.ai/python/cli/index.md#register-a-cli).

## SKILL.md

The [SKILL.md](https://docs.mirage.strukto.ai/home/setup/cli/skill-md.md) an agent reads with `pdfinfo` installed.

> [tab] Rendered
>
> **Available commands**
>
> These commands are registered with this shell; `--help` after a command or subcommand shows its usage.
>
> **`pdfinfo`**
>
> ```text theme={null}
> usage: pdfinfo [-f int] [-l int] [-opw string] [-upw string] [-q] [-h] [PDF-file ...]
>
> Print a PDF file's document information: its metadata, page count, page size and PDF version.
>
> positional arguments:
>   PDF-file  The PDF file, '-' for standard input
>
> options:
>   -f int                 First page whose size to list
>   -l int                 Last page whose size to list
>   -opw string            Owner password of an encrypted file
>   -upw string            User password of an encrypted file
>   -q                     Print no messages and no errors
>   -h, -help, --help, -?  Show this help and exit
> ```

> [tab] Raw
>
> ````markdown theme={null}
> ---
> name: workspace-commands
> description: The CLIs registered in this workspace and how to call them.
> ---
>
> # Available commands
>
> These commands are registered with this shell; `--help` after a command or subcommand shows its usage.
>
> ## `pdfinfo`
>
> ```text
> usage: pdfinfo [-f int] [-l int] [-opw string] [-upw string] [-q] [-h] [PDF-file ...]
>
> Print a PDF file's document information: its metadata, page count, page size and PDF version.
>
> positional arguments:
>   PDF-file  The PDF file, '-' for standard input
>
> options:
>   -f int                 First page whose size to list
>   -l int                 Last page whose size to list
>   -opw string            Owner password of an encrypted file
>   -upw string            User password of an encrypted file
>   -q                     Print no messages and no errors
>   -h, -help, --help, -?  Show this help and exit
> ```
> ````

## Supported commands

Run `pdfinfo --help` for the supported flags and operands.
This list is generated from Mirage's registered command tree.

| Command | Description |
| - | - |
| `pdfinfo` | Print a PDF file's document information: its metadata, page count, page size and PDF version |

## Usage

```bash theme={null} theme={null} theme={null}
pdfinfo /data/report.pdf
pdfinfo -f 1 -l 3 /data/report.pdf
TZ=Asia/Shanghai pdfinfo /data/report.pdf
```

The block lists `Title`, `Subject`, `Keywords`, `Author`, `Creator`,
`Producer`, `CreationDate` and `ModDate` where the document sets them, then
`Custom Metadata`, `Metadata Stream`, `Tagged`, `UserProperties`, `Suspects`,
`Form`, `JavaScript`, `Pages`, `Encrypted`, the page size and rotation,
`File size`, `Optimized` and `PDF version`. Dates print in the session's
`TZ`, UTC when it is unset. `-l` lists the size and rotation of pages `-f`
to `-l` instead of the first page's; `-opw`, `-upw` and `-q` work as in
[pdftotext](https://docs.mirage.strukto.ai/python/cli/pdftotext.md).

## Behavior

### Differences from poppler

* `-box`, `-meta`, `-custom`, `-js`, `-struct`, `-struct-text`, `-isodates`,
  `-rawdates`, `-dests`, `-url`, `-enc`, `-listenc` and `-v` are not
  supported.
* A PDF read from standard input reports a file size of 0 bytes, as poppler
  does.

## License

| Project | Role in Mirage | License |
| - | - | - |
| [poppler](https://poppler.freedesktop.org) | Command-line behavior reference; Mirage copies none of its code | GPL |
| [pdf\_oxide](https://github.com/yfedoseev/pdf_oxide) | PDF reader dependency | MIT or Apache-2.0 |
| [Mirage](https://github.com/strukto-ai/mirage) | Command implementation | [Apache-2.0](https://github.com/strukto-ai/mirage/blob/main/LICENSE) |

See [compatibility and licenses](https://docs.mirage.strukto.ai/home/setup/clis.md#compatibility-and-licenses).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.