pdfops

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 16 Imported by: 0 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

Package pdfops implements page and document operations on PDF files, backed by pdfcpu.

Pages are 1-based. Every operation that writes reads its whole input first and writes to a temporary file next to out, renamed into place only on success, so in == out is safe and a failed operation never leaves a partial output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyInfo added in v1.1.0

func CopyInfo(from, in, out string) error

CopyInfo writes in to out with the info dictionary of from instead of its own: the entries extract keeps, and ModDate set to now. When in has those entries already, it writes nothing.

func Decrypt

func Decrypt(in, out, pw string) error

Decrypt removes encryption using either the user or the owner password.

func DeletePages

func DeletePages(in, out string, pages []int) error

DeletePages removes pages. Deleting every page is refused.

func Encrypt

func Encrypt(in, out, userPW, ownerPW string) error

Encrypt protects the document with AES-256. At least one password is required; pdfcpu's default permissions (printing only, without the owner password) apply.

func ExtractPages

func ExtractPages(in, out string, pages []int) error

ExtractPages writes a new PDF holding just pages, in the given order.

func InsertBlankPage

func InsertBlankPage(in, out string, after int) error

InsertBlankPage inserts a blank page after page after (0 inserts at the front), sized like the page it is inserted next to.

func Merge

func Merge(inputs []string, out string) error

Merge concatenates inputs, in order, into out. out may be one of the inputs.

func Optimize

func Optimize(in, out string) error

Optimize rewrites the document, dropping redundant objects and compressing structure.

func PageCount

func PageCount(path string) (int, error)

PageCount returns the number of pages in the PDF at path.

func ReorderPages

func ReorderPages(in, out string, order []int) error

ReorderPages rewrites the document with its pages in order, a permutation of 1..n.

func Rotate

func Rotate(in, out string, pages []int, degrees int) error

Rotate rotates pages clockwise by degrees, a multiple of 90 (negative turns counter-clockwise). Empty pages rotates every page.

func SetMetadata

func SetMetadata(in, out string, m Metadata) error

SetMetadata replaces the six Metadata entries; an empty field removes its entry.

func Split

func Split(in, outDir string, ranges [][]int) (paths []string, err error)

Split writes one PDF per range into outDir, named <base>_part<N>.pdf (N from 1), each holding that range's pages in order, and returns their paths. On error no part is left behind.

func Validate

func Validate(path string) error

Validate reports whether the PDF at path passes pdfcpu's relaxed validation.

Types

type Metadata

type Metadata struct {
	Title    string
	Author   string
	Subject  string
	Keywords string
	Creator  string
	Producer string
}

Metadata holds the document information dictionary entries Lankir edits.

func GetMetadata

func GetMetadata(path string) (Metadata, error)

GetMetadata reads the document information dictionary.

Jump to

Keyboard shortcuts

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