pdfpages

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Pages of a PDF rendered as images with poppler, each a file a message attaches as an image

Index

Constants

View Source
const (
	// Pages one attach of a PDF takes at most, the first ones when it names none
	MaxPages = 25
	// Resolution the pages are rendered at, in dots per inch
	DPI = 150
	// Longest one program reading or rendering the PDF may take
	Limit = 2 * time.Minute
)

Variables

This section is empty.

Functions

func Count

func Count(info string) int

Pages of the PDF as pdfinfo printed them, 0 when it printed none

func Failure

func Failure(name, stderr string) error

Why poppler could not read the PDF of the name, from what it wrote, as a sentence that says what to do

func Folder

func Folder(base, pdf string) (string, error)

A new folder for the pages of the PDF under the folder given, named for the PDF; the folders kept there longer than a week removed first

func Header(head []byte) bool

Whether the bytes a file starts with hold the header of a PDF within the first kilobyte, where readers look for it

func Info

func Info(ctx context.Context, run Runner, path string) (int, error)

How many pages the PDF at the path holds, read by pdfinfo; refused in words for a file that is no PDF, one locked with a password and one poppler can't read

func PageFile

func PageFile(dir, pdf string, page int) string

File a page is rendered into in the folder, named for the PDF and the page, which the label of the prompt shows the model

func Range

func Range(spec string, total int) (int, int, error)

First and last page of a PDF of the pages given that the words ask for, the first 25 for none; refused in words for a range that is none, one outside the PDF or one of more than 25 pages

func Render

func Render(ctx context.Context, run Runner, pdf string, first, last int, dir string, done func(page int)) ([]string, error)

Renders the pages from first to last of the PDF into the folder at 150 dpi with pdftoppm, one at a time so each is told to done as it is ready, a page too large for a message rendered again at 4096 pixels on its long side; the files in page order

Types

type Missing

type Missing struct {
	Programs []string
	Packages map[string]string
}

The programs of poppler this computer lacks to render the pages of a PDF, with the package of each manager that installs them

func Lacks

func Lacks(has func(program string) bool) *Missing

The programs of poppler that are missing, nil when both are there; has says whether a program is installed

func (*Missing) Error

func (m *Missing) Error() string

func (*Missing) Remedy

func (m *Missing) Remedy() string

What installs it here: the command of the package manager of this system, else the package to install

type Output

type Output struct {
	Stdout, Stderr []byte
	Code           int
}

What a program printed and how it ended

func Run

func Run(ctx context.Context, argv []string, limit time.Duration) (Output, error)

Runs a program of this computer as a helper acting for no profile, never through a shell

type Runner

type Runner func(ctx context.Context, argv []string, limit time.Duration) (Output, error)

Runs a program to its end within its limit, with nothing on its input, and gives what it printed; an error for one that could not start or ran past its limit, exec.ErrNotFound under it for one that is not installed

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL