pdfwrite

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package pdfwrite provides the write_pdf tool: creating a new PDF from plain/markdown-ish text, appending text as new page(s) to an existing PDF, and deleting pages from an existing PDF. Text layout (word-wrap, automatic pagination) is handled by go-pdf/fpdf, a pure-Go library that ships PDF's standard 14 fonts (Helvetica, Times, Courier) built in - no font file needs to be embedded in this binary, unlike TTF-based PDF libraries. Page-level operations (append, delete) reuse pdfcpu, already a seshat dependency (internal/tools/files/read/pdf.go uses it for page count/extraction).

Index

Constants

View Source
const (
	// ToolName is the name of the PDF write tool.
	ToolName = "write_pdf"

	// SearchHint is a hint for tool search functionality.
	SearchHint = "create a PDF from text, append pages, or delete pages"

	// ToolDescription is the description of the write_pdf tool.
	ToolDescription = "Create a new PDF from plain/markdown-ish text, append text as new page(s) to an existing PDF, or delete pages from an existing PDF.\n\n" +
		"## When to use\n\n" +
		"- Creating a new PDF — provide content; text wraps and paginates automatically, lines starting with \"#\".. \"######\" become headings\n" +
		"- Appending content to an existing PDF — provide content for an existing file; it's rendered and added as new page(s) at the end\n" +
		"- Deleting pages from an existing PDF — provide delete_pages (e.g. \"2\", \"2-4\", \"2,4-6\")\n\n" +
		"## When NOT to use\n\n" +
		"- Reading PDF content — use FileRead instead\n" +
		"- Editing existing text in place, images, or complex layout — this only appends/deletes whole pages, it cannot find/replace text inside a PDF (unlike docx_edit) because PDF text isn't addressable the same way\n\n" +
		"## Rules\n\n" +
		"- content and delete_pages are mutually exclusive in a single call.\n" +
		"- Modifying an existing file (content-append or delete_pages) requires it to have been read with FileRead first, same as other write tools.\n"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool implements the write_pdf tool.

func NewTool

func NewTool(workingDir string) *Tool

NewTool creates a new PDF write tool.

func (*Tool) BackfillInput

func (t *Tool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*Tool) Call

func (t *Tool) Call(
	ctx context.Context,
	input tool.CallInput,
	permissionCheck types.CanUseToolFn,
) (tool.CallResult, error)

func (*Tool) CheckPermissions

func (t *Tool) CheckPermissions(_ context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult

func (*Tool) Definition

func (t *Tool) Definition() tool.Definition

func (*Tool) Description

func (t *Tool) Description(_ context.Context) (string, error)

func (*Tool) FormatResult

func (t *Tool) FormatResult(data any) string

func (*Tool) IsConcurrencySafe

func (t *Tool) IsConcurrencySafe(_ map[string]any) bool

func (*Tool) IsEnabled

func (t *Tool) IsEnabled() bool

func (*Tool) IsReadOnly

func (t *Tool) IsReadOnly(_ map[string]any) bool

func (*Tool) ValidateInput

func (t *Tool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

Jump to

Keyboard shortcuts

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