pdf

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPDFSize = 20 * 1024 * 1024

MaxPDFSize is the maximum raw PDF size (20 MB). After base64 encoding (~33% larger) this leaves room for conversation context within a 32 MB API limit.

Variables

This section is empty.

Functions

func GetPageCount

func GetPageCount(path string) (int, error)

GetPageCount returns the number of pages in a PDF using the `pdfinfo` command-line tool (from poppler-utils). Returns an error if pdfinfo is not available or the page count cannot be determined.

Types

type ExtractResult

type ExtractResult struct {
	OutputDir string
	PageCount int
}

ExtractResult holds the output directory and page count from page extraction.

func ExtractPages

func ExtractPages(path string, firstPage, lastPage int) (ExtractResult, error)

ExtractPages converts PDF pages to JPEG images using `pdftoppm` (from poppler-utils). firstPage and lastPage are 1-indexed and inclusive. Pass 0 for either to use pdftoppm defaults (all pages).

type PDFResult

type PDFResult struct {
	Base64       string
	OriginalSize int64
}

PDFResult holds the base64-encoded content and original size of a PDF.

func ReadPDF

func ReadPDF(path string) (PDFResult, error)

ReadPDF reads a PDF file, validates the %PDF- magic bytes, enforces the 20 MB size limit, and returns the base64-encoded content.

Jump to

Keyboard shortcuts

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