pdf2mt

package module
v0.0.0-...-2203430 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 21 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.

README

pdf2mt, a PDF to MT converter (a data format optimized for LLM consumption)

A mix of Markdown and some tabular form currently based on TOON (toonformat.dev), but don't expect this to be stable yet. We are just starting.

Extension recommendation: .md (it is mostly Markdown).

The conversion is done by Claude.ai (ANTHROPIC_API_KEY must be set in the environment)

Documentation

Overview

Package pdf2mt converts a PDF to a token-efficient hybrid document following the LLM Data Format strategy defined in llm-data-format.md:

  • Markdown headers for section hierarchy
  • TOON blocks for all uniform arrays, comma separator by default: name[N]{f1,f2}: / pipe separator when values contain commas: name[N]{f1,f2}(|):
  • Plain Markdown prose for narrative text

Conversion is done via the Claude API with vision input (one page at a time). Pages are rasterized using pdftoppm (from poppler-utils).

Environment:

ANTHROPIC_API_KEY  — required

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPDF

func ConvertPDF(ctx context.Context, pdfPath string, opts *Options) (string, error)

ConvertPDF converts the PDF at pdfPath to a token-efficient hybrid document. Requires ANTHROPIC_API_KEY in the environment and pdftoppm on PATH.

Types

type Options

type Options struct {
	// DPI used when rasterizing pages (default 150).
	DPI int
	// Model is the Claude model (default "claude-sonnet-4-6").
	Model string
	// OutputFile, if set, writes the resulting document to this path.
	OutputFile string
	// ExtractImages, if true, extracts figures that cannot be represented as
	// text or a table and writes them as PNG files alongside the output document.
	// Each extracted figure replaces its "> [Figure N: ...]" marker with a
	// Markdown image link "![Figure N: ...](filename.png)".
	ExtractImages bool
	// ImageDPI, if non-zero, overrides DPI when rasterizing pages for figure
	// extraction. Use a higher value (e.g. 300) for better image quality.
	// Has no effect when ExtractImages is false. Defaults to DPI.
	ImageDPI int
}

Options controls conversion behaviour.

Directories

Path Synopsis
Command pdf2mt converts a PDF to a token-efficient hybrid document.
Command pdf2mt converts a PDF to a token-efficient hybrid document.

Jump to

Keyboard shortcuts

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