pdf

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddImageWatermark

func AddImageWatermark(input, output, imagePath string, pages []int, password string) error

AddImageWatermark adds an image watermark to a PDF

func AddWatermark

func AddWatermark(input, output, text string, pages []int, password string) error

AddWatermark adds a text watermark to a PDF

func Compress

func Compress(input, output, password string) error

Compress optimizes a PDF for file size

func ConvertToPDFA added in v1.3.1

func ConvertToPDFA(input, output, level, password string) error

ConvertToPDFA attempts to convert a PDF to PDF/A format. Note: pdfcpu has limited PDF/A conversion capabilities. This performs optimization which may help with some PDF/A requirements, but full conversion requires specialized tools like Ghostscript or Adobe Acrobat.

func CreatePDFFromImages added in v1.3.2

func CreatePDFFromImages(images []string, output, pageSize string) error

CreatePDFFromImages creates a PDF from multiple image files. Each image becomes one page in the output PDF.

func Decrypt

func Decrypt(input, output, password string) error

Decrypt removes password protection from a PDF

func Encrypt

func Encrypt(input, output, userPW, ownerPW string) error

Encrypt adds password protection to a PDF

func ExtractImages

func ExtractImages(input, outputDir string, pages []int, password string) error

ExtractImages extracts images from a PDF

func ExtractPages

func ExtractPages(input, output string, pages []int, password string) error

ExtractPages extracts specific pages from a PDF into a new file

func ExtractText

func ExtractText(input string, pages []int, password string) (string, error)

ExtractText extracts text content from a PDF

func ExtractTextWithProgress added in v1.3.1

func ExtractTextWithProgress(input string, pages []int, password string, showProgress bool) (string, error)

ExtractTextWithProgress extracts text content from a PDF with optional progress bar

func Merge

func Merge(inputs []string, output, password string) error

Merge combines multiple PDF files into one

func MergeWithProgress added in v1.3.1

func MergeWithProgress(inputs []string, output, password string, showProgress bool) error

MergeWithProgress combines multiple PDF files into one with optional progress bar

func NewConfig added in v1.4.0

func NewConfig(password string) *model.Configuration

NewConfig creates a pdfcpu configuration with optional password.

func PageCount

func PageCount(path, password string) (int, error)

PageCount returns the number of pages in a PDF

func Rotate

func Rotate(input, output string, angle int, pages []int, password string) error

Rotate rotates pages in a PDF

func SetMetadata

func SetMetadata(input, output string, meta *Metadata, password string) error

SetMetadata sets metadata on a PDF

func Split

func Split(input, outputDir, password string) error

Split splits a PDF into individual pages

func SplitByPageCount

func SplitByPageCount(input, outputDir string, pageCount int, password string) error

SplitByPageCount splits a PDF into chunks of n pages

func SplitWithProgress added in v1.3.1

func SplitWithProgress(input, outputDir string, pageCount int, password string, showProgress bool) error

SplitWithProgress splits a PDF with optional progress bar

func Validate

func Validate(path, password string) error

Validate validates a PDF file

func ValidateToBuffer

func ValidateToBuffer(data []byte) error

ValidateToBuffer validates a PDF from bytes

Types

type Info

type Info struct {
	FilePath    string
	FileSize    int64
	Pages       int
	Version     string
	Title       string
	Author      string
	Subject     string
	Keywords    string
	Creator     string
	Producer    string
	CreatedDate string
	ModDate     string
	Encrypted   bool
}

Info holds PDF document information

func GetInfo

func GetInfo(path, password string) (*Info, error)

GetInfo returns information about a PDF file

type Metadata

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

Metadata holds PDF metadata fields

func GetMetadata

func GetMetadata(input, password string) (*Metadata, error)

GetMetadata returns the metadata of a PDF

type PDFAValidationResult added in v1.3.1

type PDFAValidationResult struct {
	IsValid  bool
	Level    string
	Errors   []string
	Warnings []string
}

PDFAValidationResult contains the result of PDF/A validation.

func ValidatePDFA added in v1.3.1

func ValidatePDFA(path, level, password string) (*PDFAValidationResult, error)

ValidatePDFA validates a PDF for PDF/A compliance. Note: pdfcpu provides basic validation; full PDF/A validation requires specialized tools.

Jump to

Keyboard shortcuts

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