Documentation
¶
Overview ¶
Package pdfsmart re-exports internal/pdfsmart's page-aware PDF conversion for external consumers (e.g. seshat-ai).
Index ¶
- Constants
- Variables
- func Unlock(data []byte, password string) ([]byte, error)
- func UnlockContext(ctx context.Context, data []byte, password string) ([]byte, error)
- type PageRenderer
- type PageResult
- type PageSource
- type Result
- type TableFinder
- type TableStructure
- type VisionFallback
- type VisionTranscriber
Constants ¶
const ( PageSourceNative = internalpdfsmart.PageSourceNative PageSourceDocling = internalpdfsmart.PageSourceDocling PageSourceVision = internalpdfsmart.PageSourceVision )
Variables ¶
var ErrPasswordRequired = internalpdfsmart.ErrPasswordRequired
ErrPasswordRequired is returned for a PDF protected by a user password that was not given, or was given wrongly.
Functions ¶
func Unlock ¶
Unlock returns a PDF in a form the page reader can open: unchanged when it is not encrypted or the reader already opens it, a decrypted copy otherwise (AES-256 and anything with a user password). An empty password is what every viewer tries first and opens a PDF whose owner password only limits printing and copying. Convert and the page readers do this themselves with an empty password; call it with the user's password for a protected PDF.
Types ¶
type PageRenderer ¶
type PageRenderer = internalpdfsmart.PageRenderer
PageRenderer renders a single PDF page to a raster image, feeding the vision-LLM fallback (see Convert's own doc comment for where this slots into the page-processing pipeline). It is an interface, like documentreader.Converter, so that this package does not depend on CGO or on the native document build tag.
type PageResult ¶
type PageResult = internalpdfsmart.PageResult
PageResult is one page's contribution to a Result.
type PageSource ¶
type PageSource = internalpdfsmart.PageSource
PageSource identifies how a page's text was obtained.
type Result ¶
type Result = internalpdfsmart.Result
Result is the outcome of a page-aware PDF-to-markdown conversion.
func Convert ¶
func Convert(ctx context.Context, data []byte, documentReader documentreader.Converter, vision VisionFallback) (Result, bool, error)
Convert extracts a PDF's text page by page, sending only the pages that actually need it (an embedded image, or a sparse/garbled native text layer) through documentReader instead of the whole document, with an optional vision-LLM fallback (see VisionFallback) for a page that still has no usable text afterward. See internal/pdfsmart's package doc for the exact routing rule, and Convert's own doc comment there for the ok=false safety contract. Pass VisionFallback{} to disable the vision stage.
type TableFinder ¶
type TableFinder = internalpdfsmart.TableFinder
TableFinder is a document reader that can also locate and lay out the tables with no ruling lines on a PDF page, from a layout model (the native reader, with its models, is one). pdfsmart asks it for pages whose text is columnar and fills the cells it finds from the page's own text. TableStructure is what it answers with.
type TableStructure ¶
type TableStructure = pdftext.TableStructure
TableStructure is a table as the models saw it, in points measured from the top left corner of the page. Boxes are {x0, top, x1, bottom}; the models' boxes overlap a little and come in any order.
type VisionFallback ¶
type VisionFallback = internalpdfsmart.VisionFallback
VisionFallback bundles the two collaborators the vision-LLM fallback stage needs. Both Renderer and Transcriber must be set (and Transcriber must report IsAvailable) for the fallback to actually run on a page - the zero value (or either field left nil) simply skips this stage, the same as a nil/unavailable docling client skips the docling stage. Passed as its own value rather than two more positional Convert parameters so a future fallback stage doesn't need another breaking signature change.
type VisionTranscriber ¶
type VisionTranscriber = internalpdfsmart.VisionTranscriber
VisionTranscriber sends a rendered page image to a vision-capable LLM and returns its transcription. Implementations must report IsAvailable=false (rather than attempting the call and failing) when the configured model isn't multimodal.