Skip to content

Typen-Referenz

All public types in pdf_oxide, organized by category. For method-level documentation, see the Rust API Reference.


Geometrie

Point

pub struct Point {
    pub x: f64,
    pub y: f64,
}

Ein 2D-Punkt im PDF-Koordinatenraum (Ursprung unten links, Y steigt nach oben).

Rect

pub struct Rect {
    pub x0: f64,
    pub y0: f64,
    pub x1: f64,
    pub y1: f64,
}

Ein achsenausgerichtetes Rechteck. (x0, y0) is the lower-left corner, (x1, y1) is the upper-right corner. All coordinates are in PDF points (1 point = 1/72 inch).

Python: Accessible as a tuple (x0, y0, x1, y1).

Matrix

pub struct Matrix {
    pub a: f64,
    pub b: f64,
    pub c: f64,
    pub d: f64,
    pub e: f64,
    pub f: f64,
}

Eine 3x3 affine Transformationsmatrix im PDF-Spezifikationsformat:

| a  b  0 |
| c  d  0 |
| e  f  1 |

Verwendet für Textpositionierung, Bildplatzierung und Form-XObject-Transformationen.


Text

TextSpan

pub struct TextSpan {
    pub text: String,
    pub x: f64,
    pub y: f64,
    pub font_name: String,
    pub font_size: f64,
    pub bbox: Rect,
}

Ein Abschnitt identisch gestalteten Texts. Returned by extract_spans().

TextChar

pub struct TextChar {
    pub char: char,
    pub x: f64,
    pub y: f64,
    pub font_size: f64,
    pub font_name: String,
    pub bbox: Rect,
}

Ein einzelnes Zeichen mit präziser Positionierung. Returned by extract_chars().

Python Fields:

Feld Typ Beschreibung
char str Das Zeichen
bbox tuple[float, float, float, float] Begrenzungsrahmen (x0, y0, x1, y1)
font_name str Schriftname
font_size float Schriftgröße in Punkten
origin_x float Baseline origin X
origin_y float Baseline origin Y
rotation_degrees float Rotation angle (0–360)
advance_width float Distance to next character position

FontWeight

pub enum FontWeight {
    Thin,       // 100
    ExtraLight, // 200
    Light,      // 300
    Normal,     // 400
    Medium,     // 500
    SemiBold,   // 600
    Bold,       // 700
    ExtraBold,  // 800
    Black,      // 900
}

Color

pub struct Color {
    pub r: f64,
    pub g: f64,
    pub b: f64,
}

RGB-Farbe mit Komponenten im Bereich 0.0 bis 1.0.


Seite

SeiteSize

pub enum PageSize {
    Letter,         // 612 x 792 pt (8.5 x 11 in)
    A4,             // 595.28 x 841.89 pt (210 x 297 mm)
    Legal,          // 612 x 1008 pt (8.5 x 14 in)
    A3,             // 841.89 x 1190.55 pt
    A5,             // 419.53 x 595.28 pt
    Custom(f32, f32), // Custom width x height in points
}

Methods:

Methode Rückgabe Beschreibung
dimensions() (f32, f32) Width and height in points

SeiteInfo

pub struct PageInfo {
    pub width: f64,
    pub height: f64,
    pub rotation: i32,
    pub media_box: Rect,
    pub crop_box: Option<Rect>,
    pub trim_box: Option<Rect>,
    pub bleed_box: Option<Rect>,
    pub art_box: Option<Rect>,
}

SeiteLabelStyle

pub enum PageLabelStyle {
    Decimal,        // 1, 2, 3, ...
    UpperRoman,     // I, II, III, ...
    LowerRoman,     // i, ii, iii, ...
    UpperAlpha,     // A, B, C, ...
    LowerAlpha,     // a, b, c, ...
    None,           // No numbering
}

SeiteLabelRange

pub struct PageLabelRange {
    pub start_page: usize,
    pub style: PageLabelStyle,
    pub prefix: Option<String>,
    pub start_number: Option<usize>,
}

Defines a page label range. For example, a range starting at page 0 with LowerRoman style and start number 1 labels pages as i, ii, iii, and so on.


Bilder

ImageFormat

pub enum ImageFormat {
    Jpeg,
    Png,
    Tiff,
    Bmp,
    Gif,
    Jp2,
    Jbig2,
    Ccitt,
    Raw,
    Unknown,
}

ColorSpace

pub enum ColorSpace {
    DeviceRGB,
    DeviceCMYK,
    DeviceGray,
    ICCBased,
    CalRGB,
    CalGray,
    Lab,
    Indexed,
    Pattern,
    Separation,
    DeviceN,
    Unknown,
}

ImageInfo

pub struct ImageContent {
    pub width: u32,
    pub height: u32,
    pub bits_per_component: u8,
    pub color_space: ColorSpace,
    pub format: ImageFormat,
    pub data: Vec<u8>,
    pub bbox: Rect,
    pub horizontal_dpi: Option<f32>,
    pub vertical_dpi: Option<f32>,
}

Methods:

Methode Rückgabe Beschreibung
resolution() Option<(f32, f32)> DPI als (horizontal, vertikal)
is_high_resolution() bool DPI >= 300
is_medium_resolution() bool DPI 150–299
is_low_resolution() bool DPI < 150
calculate_dpi() Option<(f32, f32)> Compute from pixel dimensions and bbox

Pfade

PathContent

pub struct PathContent {
    pub operations: Vec<PathOperation>,
    pub stroke_color: Option<Color>,
    pub fill_color: Option<Color>,
    pub stroke_width: f32,
    pub line_cap: LineCap,
    pub line_join: LineJoin,
    pub bbox: Rect,
}

PathOperation

pub enum PathOperation {
    MoveTo { x: f64, y: f64 },
    LineTo { x: f64, y: f64 },
    CurveTo { x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64 },
    ClosePath,
    Rect { x: f64, y: f64, width: f64, height: f64 },
}

LineCap

pub enum LineCap {
    Butt,    // Square end at endpoint (default)
    Round,   // Semicircle at endpoint
    Square,  // Square extends half line width past endpoint
}

LineJoin

pub enum LineJoin {
    Miter,   // Sharp corner (default)
    Round,   // Rounded corner
    Bevel,   // Flat corner
}

BlendMode

pub enum BlendMode {
    Normal,
    Multiply,
    Screen,
    Overlay,
    Darken,
    Lighten,
    ColorDodge,
    ColorBurn,
    HardLight,
    SoftLight,
    Difference,
    Exclusion,
}

Verwendet im Grafikzustand für Transparenz-Compositing. Set via ExtGState or the graphics API.


Inhaltselemente

InhaltElement

Der Union-Typ für alle Seiteninhaltelemente:

pub enum ContentElement {
    Text(TextContent),
    Image(ImageContent),
    Path(PathContent),
    Table(TableContent),
    Structure(StructureElement),
}

TextContent

pub struct TextContent {
    pub text: String,
    pub font_name: String,
    pub font_size: f64,
    pub font_weight: FontWeight,
    pub font_style: FontStyle,
    pub color: Color,
    pub bbox: Rect,
}

FontStyle

pub enum FontStyle {
    Normal,
    Italic,
    Oblique,
}

TextStyle

pub struct TextStyle {
    pub font_name: String,
    pub font_size: f64,
    pub font_weight: FontWeight,
    pub font_style: FontStyle,
    pub color: Color,
}

TableContent

pub struct TableContent {
    pub rows: Vec<TableRowContent>,
    pub column_count: usize,
    pub has_header: bool,
    pub caption: Option<String>,
    pub style: Option<TableContentStyle>,
    pub source: TableSource,
    pub bbox: Rect,
}

TableRowContent

pub struct TableRowContent {
    pub cells: Vec<TableCellContent>,
    pub is_header: bool,
}

TableCellContent

pub struct TableCellContent {
    pub text: String,
    pub row_span: usize,
    pub col_span: usize,
    pub alignment: TableCellAlign,
    pub vertical_alignment: TableCellVAlign,
    pub bbox: Rect,
}

TableCellAlign / TableCellVAlign

pub enum TableCellAlign {
    Left,
    Center,
    Right,
}

pub enum TableCellVAlign {
    Top,
    Middle,
    Bottom,
}

TableSource

pub enum TableSource {
    StructureTree,    // From tagged PDF structure
    Geometric,        // Detected from layout analysis
    Manual,           // User-created
}

StrukturElement

pub struct StructureElement {
    pub structure_type: String,
    pub children: Vec<ContentElement>,
    pub alt_text: Option<String>,
    pub actual_text: Option<String>,
    pub language: Option<String>,
}

Anmerkungen

AnnotationType

pub enum AnnotationSubtype {
    Text,
    Link,
    FreeText,
    Line,
    Square,
    Circle,
    Polygon,
    PolyLine,
    Highlight,
    Underline,
    Squiggly,
    StrikeOut,
    Stamp,
    Caret,
    Ink,
    Popup,
    FileAttachment,
    Sound,
    Movie,
    Screen,
    Widget,
    PrinterMark,
    TrapNet,
    Watermark,
    ThreeD,
    Redact,
    RichMedia,
    Unknown,
}

TextAnnotationIcon

pub enum TextAnnotationIcon {
    Comment,
    Key,
    Note,
    Help,
    NewParagraph,
    Paragraph,
    Insert,
    Check,
    Circle,
    Cross,
    RightArrow,
    RightPointer,
    Star,
    UpArrow,
    UpLeftArrow,
}

StampType

pub enum StampType {
    Approved,
    Experimental,
    NotApproved,
    AsIs,
    Expired,
    NotForPublicRelease,
    Confidential,
    Final,
    Sold,
    Departmental,
    ForComment,
    TopSecret,
    Draft,
    ForPublicRelease,
}

Strichcodes

BarcodeType

Erfordert die Feature-Flag barcodes.

pub enum BarcodeType {
    QrCode,
    Code128,
    Ean13,
    UpcA,
    Code39,
    Itf,
}

Python: Barcode types are passed as strings: "code128", "ean13", "upca", "code39", "ean8", "itf".


Formulare

FieldType / FormFieldType

pub enum FormFieldType {
    Text,
    Button,
    Choice,
    Signature,
}

FormField

pub struct FormField {
    pub name: String,
    pub field_type: FormFieldType,
    pub value: FormFieldValue,
    pub rect: Option<Rect>,
    pub page_index: Option<usize>,
    pub readonly: bool,
    pub required: bool,
}

FormFieldValue

pub enum FormFieldValue {
    None,
    Text(String),
    Boolean(bool),
    Choice(String),
    MultiChoice(Vec<String>),
}

Methods:

Methode Rückgabe Beschreibung
is_none() bool Check if value is None
as_text() Option<&str> Get text value
as_bool() Option<bool> Get boolean value
as_choice() Option<&str> Get choice value
as_multi_choice() Option<&[String]> Get multi-choice values

Suche

SucheOptions

pub struct SearchOptions {
    pub case_sensitive: bool,
    pub literal: bool,
    pub whole_word: bool,
    pub max_results: Option<usize>,
    pub page_range: Option<(usize, usize)>,
}

SucheResult

pub struct SearchResult {
    pub page_index: usize,
    pub text: String,
    pub bbox: Rect,
    pub context: Option<String>,
}

Returned by Pdf::search() and PdfDocument::search(). Each result includes the page where the match was found, the matched text, its bounding box coordinates, and optional surrounding context.


Konfiguration

KonvertierungOptions

pub struct ConversionOptions {
    pub preserve_layout: bool,
    pub detect_headings: bool,
    pub extract_tables: bool,
    pub include_images: bool,
    pub image_output_dir: Option<String>,
    pub embed_images: bool,
    // ... additional fields
}

TextConfig

pub struct TextConfig {
    pub detect_headings: bool,
    pub detect_lists: bool,
    pub detect_tables: bool,
    pub merge_spans: bool,
}

RenderOptions

Erfordert die Feature-Flag rendering.

pub struct RenderOptions {
    pub dpi: f32,
    pub background_color: Option<Color>,
    pub format: ImageFormat,
}

VerschlüsselungConfig

pub struct VerschlüsselungConfig {
    pub user_password: String,
    pub owner_password: String,
    pub algorithm: VerschlüsselungAlgorithm,
    pub permissions: Permissions,
}

Constructor:

VerschlüsselungConfig::new("user_pass", "owner_pass")
    .with_algorithm(VerschlüsselungAlgorithm::Aes256)
    .with_permissions(Permissions::read_only())

VerschlüsselungAlgorithm

pub enum VerschlüsselungAlgorithm {
    Rc4_40,     // V=1, R=2, 40-bit (legacy)
    Rc4_128,    // V=2, R=3, 128-bit (legacy)
    Aes128,     // V=4, R=4, 128-bit
    Aes256,     // V=5, R=6, 256-bit (default, recommended)
}

Permissions

pub struct Permissions {
    pub print: bool,
    pub copy: bool,
    pub modify: bool,
    pub annotate: bool,
    pub fill_forms: bool,
    pub extract: bool,
}

Factory methods:

Methode Beschreibung
Permissions::all() All permissions enabled
Permissions::read_only() Only viewing allowed

PdfConfig

pub struct PdfConfig {
    pub page_size: PageSize,
    pub margins: (f32, f32, f32, f32),  // left, right, top, bottom
    pub font_size: f32,
    pub line_height: f32,
    pub title: Option<String>,
    pub author: Option<String>,
    pub subject: Option<String>,
    pub keywords: Option<String>,
}

Textlayout

TextAlign

pub enum TextAlign {
    Left,
    Center,
    Right,
    Justify,
}

RectFilterMode

For spatial text extraction:

pub enum RectFilterMode {
    Intersects,             // Any overlap (default)
    FullyContained,         // Completely within bounds
    MinOverlap(f32),        // Minimum overlap fraction (0.0-1.0)
}

Konformitätstypen

See the PDF/A, PDF/UA, and PDF/X pages for full compliance documentation.

PdfALevel

pub enum PdfALevel {
    A1a, A1b,
    A2a, A2b, A2u,
    A3a, A3b, A3u,
}

PdfUaLevel

pub enum PdfUaLevel {
    UA1,
    UA2,
}

PdfXLevel

pub enum PdfXLevel {
    X1a2001, X1a2003,
    X3_2002, X3_2003,
    X4, X4p,
    X5g, X5n, X5pg,
    X6, X6n, X6p,
}

Fehlertypen

PdfError

pub enum PdfError {
    Io(std::io::Error),
    Parse(String),
    Password,
    PageOutOfRange { index: usize, count: usize },
}
Variante Beschreibung
Io File system or I/O failure
Parse Malformed PDF structure
Password Document is encrypted and no password was given
PageOutOfRange Requested page index exceeds page count

Nächste Schritte