Documentation
¶
Overview ¶
Package api is the supported entry point for embedding AutoPDF in Go programs.
Construct an Engine with NewEngine, then call Engine.Generate with the caller's context. Request and Result are the stable transport contracts. Generator is the primary extension seam; WithGenerator allows another implementation or a decorator to reuse the same Engine contract. Logger is optional and defaults to a no-op implementation.
Subpackages under api/domain, api/application, api/adapters, api/builders, api/factories, and api/services are compatibility layers. New integrations should not depend on them.
For component documents, construct a DocumentEngine. It maps immutable semantic components to cached fragments, deterministic LaTeX projections, production generators, and revisioned preview sessions without changing the legacy Engine.Generate boundary.
Index ¶
- Constants
- Variables
- func GeneratePDF(cfg *config.Config, template config.Template) ([]byte, map[string]string, error)
- type Capabilities
- type ConversionOptions
- type DocumentEngine
- func (engine *DocumentEngine) Catalog() []component.Metadata
- func (engine *DocumentEngine) Compose(ctx context.Context, spec document.DocumentSpec) (composition.RenderManifest, error)
- func (engine *DocumentEngine) Generate(ctx context.Context, spec document.DocumentSpec, options ProjectionOptions, ...) (Result, error)
- func (engine *DocumentEngine) NewPreviewSession(compiler preview.Compiler, options preview.Options) (*preview.Session, error)
- func (engine *DocumentEngine) Preview(ctx context.Context, session *preview.Session, spec document.DocumentSpec, ...) <-chan preview.Result
- func (engine *DocumentEngine) Project(ctx context.Context, spec document.DocumentSpec, options ProjectionOptions) (latex.Projection, error)
- func (engine *DocumentEngine) Validate(spec document.DocumentSpec) document.Problems
- type DocumentEngineConfig
- type Engine
- type ErrorDetails
- func (ed *ErrorDetails) AddContext(key, value string) *ErrorDetails
- func (ed *ErrorDetails) LogError(logger Logger) *ErrorDetails
- func (ed *ErrorDetails) LogErrorWithMessage(logger Logger, message string) *ErrorDetails
- func (ed *ErrorDetails) ToMap() map[string]interface{}
- func (ed *ErrorDetails) WithEngine(engine string) *ErrorDetails
- func (ed *ErrorDetails) WithError(err error) *ErrorDetails
- func (ed *ErrorDetails) WithFilePath(path string) *ErrorDetails
- func (ed *ErrorDetails) WithFileSize(size int64) *ErrorDetails
- func (ed *ErrorDetails) WithFormat(format string) *ErrorDetails
- func (ed *ErrorDetails) WithOutputPath(path string) *ErrorDetails
- func (ed *ErrorDetails) WithPageCount(count int) *ErrorDetails
- func (ed *ErrorDetails) WithRecovery(suggestions []string, retryable bool, maxRetries int, timeout time.Duration) *ErrorDetails
- func (ed *ErrorDetails) WithSystem(os, arch string, memory, diskSpace int64, processID int) *ErrorDetails
- func (ed *ErrorDetails) WithTemplatePath(path string) *ErrorDetails
- func (ed *ErrorDetails) WithValidation(rule string, expected, actual interface{}) *ErrorDetails
- type Generator
- type GeneratorFunc
- type LocalProjectionGenerator
- type LogField
- type Logger
- type ManifestProjector
- type NoopLogger
- type Option
- type PDFMetadata
- type ProjectionAssetResolver
- type ProjectionDiagnostic
- type ProjectionGenerationError
- type ProjectionGenerator
- type ProjectionGeneratorFunc
- type ProjectionGeneratorOptions
- type ProjectionOptions
- type RecoveryDetails
- type Request
- type Result
- type SystemDetails
- type ValidationDetails
- type ValidationUtils
- func (vu *ValidationUtils) CreateRecoverySuggestions(category, errorCode string) []string
- func (vu *ValidationUtils) GetFileMetadata(filePath string) (map[string]interface{}, error)
- func (vu *ValidationUtils) ValidateEngine(engine string) (*ErrorDetails, error)
- func (vu *ValidationUtils) ValidateOutputPath(outputPath string) (*ErrorDetails, error)
- func (vu *ValidationUtils) ValidatePDFContent(pdfPath string) (*ErrorDetails, error)
- func (vu *ValidationUtils) ValidatePDFPath(pdfPath string) (*ErrorDetails, error)
- func (vu *ValidationUtils) ValidateTemplatePath(templatePath string) (*ErrorDetails, error)
Examples ¶
Constants ¶
const ( // PDF Path validation ErrPDFPathRequired = "PDF path is required" ErrPDFPathEmpty = "PDF path cannot be empty" ErrPDFPathInvalid = "Invalid PDF path format" // PDF File validation ErrPDFFileNotFound = "PDF file does not exist: %s" ErrPDFFileNotReadable = "Cannot read PDF file: %s" ErrPDFFileEmpty = "PDF file is empty: %s" ErrPDFFileInvalid = "File is not a valid PDF: %s" ErrPDFFileCorrupted = "PDF file appears to be corrupted: %s" ErrPDFFileExtensionInvalid = "File does not have .pdf extension: %s" // PDF Structure validation ErrPDFHeaderInvalid = "Invalid PDF header signature" ErrPDFStructureInvalid = "Invalid PDF structure" ErrPDFVersionInvalid = "Unsupported PDF version" ErrPDFValidationFailed = "PDF validation failed" // PDF Metadata validation ErrPDFMetadataInvalid = "Cannot extract PDF metadata: %s" ErrPDFPageCountInvalid = "Cannot determine page count: %s" ErrPDFFileSizeInvalid = "Cannot determine file size: %s" // PDF Content validation ErrPDFContentInvalid = "PDF content validation failed: %s" ErrPDFSecurityInvalid = "PDF security validation failed: %s" )
PDF Validation Error Messages
const ( // Template Path validation ErrTemplatePathRequired = "Template path is required" ErrTemplatePathEmpty = "Template path cannot be empty" ErrTemplatePathInvalid = "Invalid template path format" // Template File validation ErrTemplateFileNotFound = "Template file does not exist: %s" ErrTemplateFileNotReadable = "Cannot read template file: %s" ErrTemplateFileEmpty = "Template file is empty: %s" ErrTemplateFileInvalid = "Template file is not a valid LaTeX file: %s" // Template Content validation ErrTemplateContentInvalid = "Template content validation failed: %s" ErrTemplateSyntaxInvalid = "Template contains invalid LaTeX syntax: %s" ErrTemplateVariablesInvalid = "Template variables validation failed: %s" ErrTemplateDelimitersInvalid = "Template delimiters validation failed: %s" // Template Processing validation ErrTemplateProcessingFailed = "Template processing failed: %s" ErrTemplateRenderingFailed = "Template rendering failed: %s" ErrTemplateCompilationFailed = "Template compilation failed: %s" ErrTemplateValidationFailed = "Template validation failed: %s" )
Template Processing Error Messages
const ( // Variable validation ErrVariableKeyRequired = "Variable key is required" ErrVariableKeyEmpty = "Variable key cannot be empty" ErrVariableKeyInvalid = "Invalid variable key format: %s" ErrVariableValueInvalid = "Invalid variable value: %s" ErrVariableTypeInvalid = "Unsupported variable type: %s" // Variable resolution ErrVariableResolutionFailed = "Variable resolution failed: %s" ErrVariableFlatteningFailed = "Variable flattening failed: %s" ErrVariableValidationFailed = "Variable validation failed: %s" )
Variable Resolution Error Messages
const ( // Generation process ErrPDFGenerationFailed = "PDF generation failed: %s" ErrPDFGenerationTimeout = "PDF generation timeout: %s" ErrPDFGenerationCancelled = "PDF generation cancelled: %s" // Engine validation ErrEngineRequired = "LaTeX engine is required" ErrEngineNotFound = "LaTeX engine not found: %s" ErrEngineNotSupported = "Unsupported LaTeX engine: %s" ErrEngineExecutionFailed = "LaTeX engine execution failed: %s" // Output validation ErrOutputPathRequired = "Output path is required" ErrOutputPathInvalid = "Invalid output path: %s" ErrOutputPathNotWritable = "Cannot write to output path: %s" ErrOutputPathExists = "Output file already exists: %s" // Conversion validation ErrConversionFailed = "PDF conversion failed: %s" ErrConversionFormatInvalid = "Unsupported conversion format: %s" ErrConversionTimeout = "Conversion timeout: %s" )
PDF Generation Error Messages
const ( // File system errors ErrFileSystemAccess = "File system access error: %s" ErrFileSystemPermission = "File system permission error: %s" ErrFileSystemSpace = "Insufficient disk space: %s" // Memory errors ErrMemoryAllocation = "Memory allocation failed: %s" ErrMemoryInsufficient = "Insufficient memory: %s" // Network errors ErrNetworkConnection = "Network connection error: %s" ErrNetworkTimeout = "Network timeout: %s" )
System Error Messages
const ( ErrorCategoryPDF = "pdf_validation" ErrorCategoryTemplate = "template_processing" ErrorCategoryVariable = "variable_resolution" ErrorCategoryGeneration = "pdf_generation" ErrorCategoryConfiguration = "configuration" ErrorCategorySystem = "system" ErrorCategoryNetwork = "network" ErrorCategoryFileSystem = "file_system" )
Error Categories
const ( ErrorSeverityLow = "low" ErrorSeverityMedium = "medium" ErrorSeverityHigh = "high" ErrorSeverityCritical = "critical" )
Error Severity Levels
const ( ContextKeyPDFPath = "pdf_path" ContextKeyTemplatePath = "template_path" ContextKeyOutputPath = "output_path" ContextKeyEngine = "engine" ContextKeyFormat = "format" ContextKeyError = "error" ContextKeyTimestamp = "timestamp" ContextKeyDuration = "duration" ContextKeyFileSize = "file_size" ContextKeyPageCount = "page_count" )
Error Context Keys
const ( // PDF validation rules MinPDFFileSize = 100 // Minimum PDF file size in bytes MaxPDFFileSize = 100 * 1024 * 1024 // Maximum PDF file size (100MB) MinPDFHeaderLength = 4 // Minimum PDF header length // Template validation rules MinTemplateFileSize = 50 // Minimum template file size in bytes MaxTemplateFileSize = 10 * 1024 * 1024 // Maximum template file size (10MB) // Variable validation rules MaxVariableKeyLength = 100 // Maximum variable key length MaxVariableValueLength = 10000 // Maximum variable value length MaxVariableCount = 1000 // Maximum number of variables )
Validation Rules
const ( // PDF defaults DefaultPDFVersion = "1.4" DefaultPDFPageCount = 1 DefaultPDFFileSize = 1024 // Template defaults DefaultTemplateEngine = "pdflatex" DefaultTemplateFormat = "tex" // Validation defaults DefaultValidationTimeout = "30s" DefaultValidationRetries = 3 )
Default Values
Variables ¶
var ( ErrNilGenerator = errors.New("api: generator must not be nil") ErrTemplateRequired = errors.New("api: template path is required") )
var ( ErrProjectionEngineRequired = errors.New("api: projection engine is required") ErrProjectionMainMissing = errors.New("api: projection main file is missing") ErrProjectionResolverMissing = errors.New("api: projection asset resolver is required") ErrProjectionPathUnsafe = errors.New("api: unsafe projection path") ErrProjectionPathDuplicate = errors.New("api: duplicate projection path") ErrProjectionDigestMismatch = errors.New("api: projection asset digest mismatch") )
var ErrProjectionGeneratorRequired = errors.New("api: projection generator must not be nil")
Functions ¶
Types ¶
type Capabilities ¶
Capabilities describes the engines and conversion formats exposed by an Engine.
type ConversionOptions ¶
type ConversionOptions = model.ConversionOptions
ConversionOptions controls optional PDF-to-image conversion.
type DocumentEngine ¶
type DocumentEngine struct {
// contains filtered or unexported fields
}
DocumentEngine is the embeddable component -> manifest -> projection facade.
func NewDefaultDocumentEngine ¶
func NewDefaultDocumentEngine(target string, config DocumentEngineConfig) (*DocumentEngine, error)
NewDefaultDocumentEngine builds the minimal flow/section/artifact catalog.
func NewDocumentEngine ¶
func NewDocumentEngine(catalog *component.Catalog, config DocumentEngineConfig) (*DocumentEngine, error)
NewDocumentEngine constructs a facade around an immutable component catalog.
func (*DocumentEngine) Catalog ¶
func (engine *DocumentEngine) Catalog() []component.Metadata
Catalog returns a defensive editor-discovery snapshot.
func (*DocumentEngine) Compose ¶
func (engine *DocumentEngine) Compose(ctx context.Context, spec document.DocumentSpec) (composition.RenderManifest, error)
Compose renders a stable, content-addressed manifest.
func (*DocumentEngine) Generate ¶
func (engine *DocumentEngine) Generate(ctx context.Context, spec document.DocumentSpec, options ProjectionOptions, generator ProjectionGenerator) (Result, error)
Generate reaches the production effect boundary while returning the same stable Result type used by Engine.Generate.
func (*DocumentEngine) NewPreviewSession ¶
func (engine *DocumentEngine) NewPreviewSession(compiler preview.Compiler, options preview.Options) (*preview.Session, error)
NewPreviewSession creates a revisioned session using the same projection values as production. The compiler is an explicit effect adapter.
func (*DocumentEngine) Preview ¶
func (engine *DocumentEngine) Preview(ctx context.Context, session *preview.Session, spec document.DocumentSpec, options ProjectionOptions) <-chan preview.Result
Preview projects a document and submits it to a long-lived session.
func (*DocumentEngine) Project ¶
func (engine *DocumentEngine) Project(ctx context.Context, spec document.DocumentSpec, options ProjectionOptions) (latex.Projection, error)
Project composes and deterministically maps fragments to LaTeX source files.
Example ¶
package main
import (
"context"
"fmt"
"strings"
"github.com/BuddhiLW/AutoPDF/v2/pkg/api"
"github.com/BuddhiLW/AutoPDF/v2/pkg/document"
"github.com/BuddhiLW/AutoPDF/v2/pkg/render/latex"
)
func documentSpec() document.DocumentSpec {
return document.DocumentSpec{
SchemaVersion: document.CurrentSchemaVersion,
ID: "example",
Blocks: []document.Component{{
ID: "chapter", Kind: "section", Variant: "default",
Props: document.Props{"content": `\section{Chapter}`},
Children: []document.Component{{ID: "body", Kind: "text", Variant: "default", Props: document.Props{"content": "Hello"}}},
}},
}
}
func main() {
engine, _ := api.NewDefaultDocumentEngine("latex", api.DocumentEngineConfig{MaxWorkers: 2})
projection, _ := engine.Project(context.Background(), documentSpec(), api.ProjectionOptions{FocusSections: []string{"chapter"}})
fmt.Println(len(engine.Catalog()), len(projection.Files), strings.Contains(string(findProjectionFile(projection, "main.tex")), `\includeonly{`))
}
func findProjectionFile(projection latex.Projection, path string) []byte {
for _, file := range projection.Files {
if file.Path == path {
return file.Content
}
}
return nil
}
Output: 3 3 true
func (*DocumentEngine) Validate ¶
func (engine *DocumentEngine) Validate(spec document.DocumentSpec) document.Problems
Validate reports structural problems without rendering.
type DocumentEngineConfig ¶
type DocumentEngineConfig struct {
Target string
MaxWorkers int
Cache composition.Cache
Values map[string]any
TrustedPreamble []byte
// Projector overrides the default article-shaped LaTeX projection. Leave
// it nil for the built-in one.
Projector ManifestProjector
}
DocumentEngineConfig controls pure composition. The existing Engine and its Request/Result PDF boundary remain unchanged.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the canonical embeddable AutoPDF facade.
Example ¶
package main
import (
"context"
"fmt"
"github.com/BuddhiLW/AutoPDF/v2/pkg/api"
)
func main() {
engine, _ := api.NewEngine(api.WithGenerator(api.GeneratorFunc(
func(_ context.Context, req api.Request) (api.Result, error) {
return api.Result{PDFPath: req.OutputPath, PDF: []byte("%PDF-demo")}, nil
},
)))
result, _ := engine.Generate(context.Background(), api.Request{
TemplatePath: "invoice.tex",
OutputPath: "invoice.pdf",
Variables: map[string]string{"customer.name": "Ada"},
})
fmt.Println(result.PDFPath, len(result.PDF))
}
Output: invoice.pdf 9
func NewEngine ¶
NewEngine constructs an Engine. The default generator uses AutoPDF's built-in pipeline.
func (*Engine) Capabilities ¶
func (engine *Engine) Capabilities() Capabilities
Capabilities returns a defensive copy of the engine's advertised capabilities.
type ErrorDetails ¶
type ErrorDetails struct {
// Core identification
Category string `json:"category"`
Severity string `json:"severity"`
Timestamp time.Time `json:"timestamp"`
// Context information
Context map[string]string `json:"context,omitempty"`
// File information
FilePath string `json:"file_path,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
FileExists bool `json:"file_exists,omitempty"`
// Validation information
Validation *ValidationDetails `json:"validation,omitempty"`
// System information
System *SystemDetails `json:"system,omitempty"`
// Recovery information
Recovery *RecoveryDetails `json:"recovery,omitempty"`
}
ErrorDetails represents structured error information This replaces the generic map[string]interface{} with a proper entity
func NewErrorDetails ¶
func NewErrorDetails(category, severity string) *ErrorDetails
NewErrorDetails creates a new ErrorDetails with default values
func (*ErrorDetails) AddContext ¶
func (ed *ErrorDetails) AddContext(key, value string) *ErrorDetails
AddContext adds a key-value pair to the context
func (*ErrorDetails) LogError ¶
func (ed *ErrorDetails) LogError(logger Logger) *ErrorDetails
LogError logs the error details using structured logging
func (*ErrorDetails) LogErrorWithMessage ¶
func (ed *ErrorDetails) LogErrorWithMessage(logger Logger, message string) *ErrorDetails
LogErrorWithMessage logs safe error metadata with a custom message.
func (*ErrorDetails) ToMap ¶
func (ed *ErrorDetails) ToMap() map[string]interface{}
ToMap converts ErrorDetails to a map for backward compatibility
func (*ErrorDetails) WithEngine ¶
func (ed *ErrorDetails) WithEngine(engine string) *ErrorDetails
WithEngine adds engine information to the error details
func (*ErrorDetails) WithError ¶
func (ed *ErrorDetails) WithError(err error) *ErrorDetails
WithError adds error information to the error details
func (*ErrorDetails) WithFilePath ¶
func (ed *ErrorDetails) WithFilePath(path string) *ErrorDetails
WithFilePath adds file path information to the error details
func (*ErrorDetails) WithFileSize ¶
func (ed *ErrorDetails) WithFileSize(size int64) *ErrorDetails
WithFileSize adds file size information to the error details
func (*ErrorDetails) WithFormat ¶
func (ed *ErrorDetails) WithFormat(format string) *ErrorDetails
WithFormat adds format information to the error details
func (*ErrorDetails) WithOutputPath ¶
func (ed *ErrorDetails) WithOutputPath(path string) *ErrorDetails
WithOutputPath adds output path information to the error details
func (*ErrorDetails) WithPageCount ¶
func (ed *ErrorDetails) WithPageCount(count int) *ErrorDetails
WithPageCount adds page count information to the error details
func (*ErrorDetails) WithRecovery ¶
func (ed *ErrorDetails) WithRecovery(suggestions []string, retryable bool, maxRetries int, timeout time.Duration) *ErrorDetails
WithRecovery adds recovery details to the error details
func (*ErrorDetails) WithSystem ¶
func (ed *ErrorDetails) WithSystem(os, arch string, memory, diskSpace int64, processID int) *ErrorDetails
WithSystem adds system details to the error details
func (*ErrorDetails) WithTemplatePath ¶
func (ed *ErrorDetails) WithTemplatePath(path string) *ErrorDetails
WithTemplatePath adds template path information to the error details
func (*ErrorDetails) WithValidation ¶
func (ed *ErrorDetails) WithValidation(rule string, expected, actual interface{}) *ErrorDetails
WithValidation adds validation details to the error details
type GeneratorFunc ¶
GeneratorFunc adapts a function to Generator.
Example ¶
package main
import (
"context"
"fmt"
"github.com/BuddhiLW/AutoPDF/v2/pkg/api"
)
func main() {
remote := api.GeneratorFunc(func(_ context.Context, req api.Request) (api.Result, error) {
return api.Result{PDFPath: req.OutputPath, PDF: []byte("%PDF-remote")}, nil
})
engine, _ := api.NewEngine(
api.WithGenerator(remote),
api.WithCapabilities(api.Capabilities{Engines: []string{"remote"}}),
)
fmt.Println(engine.Capabilities().Engines)
}
Output: [remote]
type LocalProjectionGenerator ¶
type LocalProjectionGenerator struct {
// contains filtered or unexported fields
}
LocalProjectionGenerator is the supported production adapter from a pure LaTeX projection to the canonical Engine.Generate boundary.
func NewProjectionGenerator ¶
func NewProjectionGenerator(options ProjectionGeneratorOptions) (*LocalProjectionGenerator, error)
NewProjectionGenerator constructs a production adapter. A nil Engine uses AutoPDF's canonical built-in generator.
func (*LocalProjectionGenerator) GenerateProjection ¶
func (generator *LocalProjectionGenerator) GenerateProjection(ctx context.Context, projection latex.Projection) (Result, error)
GenerateProjection materializes one immutable projection, invokes the canonical generation pipeline, then removes its private workspace.
type LogField ¶
type LogField struct {
Key string
Value interface{}
}
LogField represents a key-value pair for structured logging
func NewLogField ¶
NewLogField creates a new log field
type Logger ¶
type Logger interface {
// Debug logs a debug-level message
Debug(ctx context.Context, msg string, fields ...LogField)
// Info logs an info-level message
Info(ctx context.Context, msg string, fields ...LogField)
// Warn logs a warning-level message
Warn(ctx context.Context, msg string, fields ...LogField)
// Error logs an error-level message
Error(ctx context.Context, msg string, fields ...LogField)
}
Logger is a public interface for logging within AutoPDF This allows external consumers (like cartas-backend) to provide their own loggers and see logs from AutoPDF operations (like latexmk commands) in their own logger output
func NewNoopLogger ¶
func NewNoopLogger() Logger
NewNoopLogger returns a Logger suitable for libraries that do not need logging.
type ManifestProjector ¶ added in v2.1.0
type ManifestProjector interface {
ProjectManifest(manifest composition.RenderManifest, focusSections []string) (latex.Projection, error)
}
ManifestProjector maps a composed manifest to LaTeX source files. A rendering target supplies its own implementation together with its catalog; this engine never enumerates targets.
type NoopLogger ¶
type NoopLogger struct{}
NoopLogger is the default public logger and deliberately emits nothing.
type Option ¶
type Option func(*engineOptions) error
Option configures an Engine.
func WithCapabilities ¶
func WithCapabilities(capabilities Capabilities) Option
WithCapabilities advertises capabilities supplied by an embedded implementation.
func WithGenerator ¶
WithGenerator replaces the default generator with an application-supplied one.
func WithLogger ¶
WithLogger routes engine lifecycle messages to logger. A nil logger is a no-op.
type PDFMetadata ¶
type PDFMetadata = model.PDFMetadata
PDFMetadata describes a generated or inspected PDF.
type ProjectionAssetResolver ¶
type ProjectionAssetResolver interface {
Resolve(context.Context, latex.AssetBinding) ([]byte, error)
}
ProjectionAssetResolver materializes one inert projection asset.
type ProjectionDiagnostic ¶
ProjectionDiagnostic maps a compiler message back to generated source and, when possible, its component identity.
type ProjectionGenerationError ¶
type ProjectionGenerationError struct {
Err error
Diagnostics []ProjectionDiagnostic
}
ProjectionGenerationError retains the compiler error plus mapped messages.
func (*ProjectionGenerationError) Error ¶
func (failure *ProjectionGenerationError) Error() string
func (*ProjectionGenerationError) Unwrap ¶
func (failure *ProjectionGenerationError) Unwrap() error
type ProjectionGenerator ¶
type ProjectionGenerator interface {
GenerateProjection(context.Context, latex.Projection) (Result, error)
}
ProjectionGenerator is the final effect boundary for production PDF output. Implementations materialize the projection and invoke their chosen compiler.
type ProjectionGeneratorFunc ¶
ProjectionGeneratorFunc adapts a function to ProjectionGenerator.
func (ProjectionGeneratorFunc) GenerateProjection ¶
func (function ProjectionGeneratorFunc) GenerateProjection(ctx context.Context, projection latex.Projection) (Result, error)
type ProjectionGeneratorOptions ¶
type ProjectionGeneratorOptions struct {
Engine *Engine
Resolver ProjectionAssetResolver
WorkspaceRoot string
KeepWorkspace bool
OutputPath string
LaTeXEngine string
Passes int
UseLatexmk bool
Debug bool
Conversion ConversionOptions
}
ProjectionGeneratorOptions configures production projection generation. Each call still receives a private ephemeral workspace; preview workspaces are deliberately managed by pkg/preview instead.
type ProjectionOptions ¶
type ProjectionOptions struct {
FocusSections []string
}
ProjectionOptions contains request-scoped projection choices.
type RecoveryDetails ¶
type RecoveryDetails struct {
Suggestions []string `json:"suggestions,omitempty"`
Retryable bool `json:"retryable"`
MaxRetries int `json:"max_retries,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
}
RecoveryDetails contains recovery suggestions and information
type Request ¶
type Request struct {
TemplatePath string
OutputPath string
Variables map[string]string
LaTeXEngine string
WorkingDir string
Passes int
UseLatexmk bool
Debug bool
Conversion ConversionOptions
}
Request is the stable input contract for programmatic PDF generation.
type Result ¶
type Result struct {
PDFPath string
PDF []byte
ImagePaths []string
Metadata PDFMetadata
}
Result is the stable output contract for programmatic PDF generation.
type SystemDetails ¶
type SystemDetails struct {
OS string `json:"os,omitempty"`
Architecture string `json:"architecture,omitempty"`
Memory int64 `json:"memory,omitempty"`
DiskSpace int64 `json:"disk_space,omitempty"`
ProcessID int `json:"process_id,omitempty"`
}
SystemDetails contains system-specific information
type ValidationDetails ¶
type ValidationDetails struct {
Rule string `json:"rule,omitempty"`
Expected interface{} `json:"expected,omitempty"`
Actual interface{} `json:"actual,omitempty"`
Constraints map[string]interface{} `json:"constraints,omitempty"`
}
ValidationDetails contains validation-specific information
type ValidationUtils ¶
type ValidationUtils struct{}
ValidationUtils provides reusable validation functions These can leverage internal logic from the autopdf application layer
func NewValidationUtils ¶
func NewValidationUtils() *ValidationUtils
NewValidationUtils creates a new ValidationUtils instance
func (*ValidationUtils) CreateRecoverySuggestions ¶
func (vu *ValidationUtils) CreateRecoverySuggestions(category, errorCode string) []string
CreateRecoverySuggestions creates recovery suggestions based on error type
func (*ValidationUtils) GetFileMetadata ¶
func (vu *ValidationUtils) GetFileMetadata(filePath string) (map[string]interface{}, error)
GetFileMetadata extracts file metadata
func (*ValidationUtils) ValidateEngine ¶
func (vu *ValidationUtils) ValidateEngine(engine string) (*ErrorDetails, error)
ValidateEngine validates a LaTeX engine
func (*ValidationUtils) ValidateOutputPath ¶
func (vu *ValidationUtils) ValidateOutputPath(outputPath string) (*ErrorDetails, error)
ValidateOutputPath validates an output file path
func (*ValidationUtils) ValidatePDFContent ¶
func (vu *ValidationUtils) ValidatePDFContent(pdfPath string) (*ErrorDetails, error)
ValidatePDFContent validates PDF content structure
func (*ValidationUtils) ValidatePDFPath ¶
func (vu *ValidationUtils) ValidatePDFPath(pdfPath string) (*ErrorDetails, error)
ValidatePDFPath validates a PDF file path
func (*ValidationUtils) ValidateTemplatePath ¶
func (vu *ValidationUtils) ValidateTemplatePath(templatePath string) (*ErrorDetails, error)
ValidateTemplatePath validates a template file path
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package model contains dependency-free value types shared by public API layers.
|
Package model contains dependency-free value types shared by public API layers. |