타입 & 열거형
카테고리별로 정리된 pdf_oxide의 모든 공개 타입입니다. 메서드 수준 문서는 Rust API 레퍼런스를 참조하세요.
기하학
Point
pub struct Point {
pub x: f64,
pub y: f64,
}
PDF 좌표 공간의 2D 점입니다 (원점은 왼쪽 하단, Y는 위로 증가).
Rect
pub struct Rect {
pub x0: f64,
pub y0: f64,
pub x1: f64,
pub y1: f64,
}
축 정렬 직사각형입니다. (x0, y0)은 왼쪽 하단 모서리, (x1, y1)은 오른쪽 상단 모서리입니다. 모든 좌표는 PDF 포인트 단위입니다 (1 포인트 = 1/72 인치).
Python: 튜플 (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,
}
PDF 사양 형식의 3x3 아핀 변환 행렬입니다:
| a b 0 |
| c d 0 |
| e f 1 |
텍스트 위치 지정, 이미지 배치, Form XObject 변환에 사용됩니다.
텍스트
TextSpan
pub struct TextSpan {
pub text: String,
pub x: f64,
pub y: f64,
pub font_name: String,
pub font_size: f64,
pub bbox: Rect,
}
동일한 스타일의 텍스트 실행입니다. 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,
}
정밀한 위치 지정이 있는 단일 문자입니다. extract_chars()에 의해 반환됩니다.
Python 필드:
| Field | 타입 | 설명 |
|---|---|---|
char |
str |
문자 |
bbox |
tuple[float, float, float, float] |
바운딩 박스 (x0, y0, x1, y1) |
font_name |
str |
글꼴 이름 |
font_size |
float |
글꼴 크기(포인트) |
origin_x |
float |
기준선 원점 X |
origin_y |
float |
기준선 원점 Y |
rotation_degrees |
float |
회전 각도 (0–360) |
advance_width |
float |
다음 문자 위치까지의 거리 |
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,
}
구성 요소가 0.0에서 1.0 범위인 RGB 색상입니다.
페이지
PageSize
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
}
메서드:
| 메서드 | 반환값 | 설명 |
|---|---|---|
dimensions() |
(f32, f32) |
포인트 단위의 너비와 높이 |
PageInfo
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>,
}
PageLabelStyle
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
}
PageLabelRange
pub struct PageLabelRange {
pub start_page: usize,
pub style: PageLabelStyle,
pub prefix: Option<String>,
pub start_number: Option<usize>,
}
페이지 라벨 범위를 정의합니다. 예를 들어, 페이지 0에서 시작하는 LowerRoman 스타일과 시작 번호 1은 페이지를 i, ii, iii 등으로 라벨링합니다.
이미지
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>,
}
메서드:
| 메서드 | 반환값 | 설명 |
|---|---|---|
resolution() |
Option<(f32, f32)> |
DPI (수평, 수직) |
is_high_resolution() |
bool |
DPI >= 300 |
is_medium_resolution() |
bool |
DPI 150–299 |
is_low_resolution() |
bool |
DPI < 150 |
calculate_dpi() |
Option<(f32, f32)> |
픽셀 크기와 bbox에서 계산 |
경로
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,
}
투명도 합성을 위한 그래픽 상태에서 사용됩니다. ExtGState 또는 그래픽 API를 통해 설정합니다.
콘텐츠 요소
ContentElement
모든 페이지 콘텐츠 요소의 유니온 타입입니다:
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
}
StructureElement
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>,
}
주석
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,
}
바코드
BarcodeType
barcodes 기능 플래그가 필요합니다.
pub enum BarcodeType {
QrCode,
Code128,
Ean13,
UpcA,
Code39,
Itf,
}
Python: 바코드 타입은 문자열로 전달됩니다: "code128", "ean13", "upca", "code39", "ean8", "itf".
양식
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>),
}
메서드:
| 메서드 | 반환값 | 설명 |
|---|---|---|
is_none() |
bool |
값이 None인지 확인 |
as_text() |
Option<&str> |
텍스트 값 가져오기 |
as_bool() |
Option<bool> |
불리언 값 가져오기 |
as_choice() |
Option<&str> |
선택 값 가져오기 |
as_multi_choice() |
Option<&[String]> |
다중 선택 값 가져오기 |
검색
검색Options
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)>,
}
검색Result
pub struct SearchResult {
pub page_index: usize,
pub text: String,
pub bbox: Rect,
pub context: Option<String>,
}
Pdf::search() 및 PdfDocument::search()에 의해 반환됩니다. 각 결과에는 매치가 발견된 페이지, 일치된 텍스트, 바운딩 박스 좌표, 선택적 주변 컨텍스트가 포함됩니다.
설정
ConversionOptions
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
rendering 기능 플래그가 필요합니다.
pub struct RenderOptions {
pub dpi: f32,
pub background_color: Option<Color>,
pub format: ImageFormat,
}
EncryptionConfig
pub struct EncryptionConfig {
pub user_password: String,
pub owner_password: String,
pub algorithm: EncryptionAlgorithm,
pub permissions: Permissions,
}
생성자:
EncryptionConfig::new("user_pass", "owner_pass")
.with_algorithm(EncryptionAlgorithm::Aes256)
.with_permissions(Permissions::read_only())
EncryptionAlgorithm
pub enum EncryptionAlgorithm {
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,
}
팩토리 메서드:
| 메서드 | 설명 |
|---|---|
Permissions::all() |
모든 권한 활성화 |
Permissions::read_only() |
보기만 허용 |
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>,
}
텍스트 레이아웃
TextAlign
pub enum TextAlign {
Left,
Center,
Right,
Justify,
}
RectFilterMode
공간 텍스트 추출용:
pub enum RectFilterMode {
Intersects, // Any overlap (default)
FullyContained, // Completely within bounds
MinOverlap(f32), // Minimum overlap fraction (0.0-1.0)
}
규정 준수 타입
전체 규정 준수 문서는 PDF/A, PDF/UA, PDF/X 페이지를 참조하세요.
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,
}
오류 타입
PdfError
pub enum PdfError {
Io(std::io::Error),
Parse(String),
Password,
PageOutOfRange { index: usize, count: usize },
}
| Variant | 설명 |
|---|---|
Io |
파일 시스템 또는 I/O 실패 |
Parse |
잘못된 PDF 구조 |
Password |
문서가 암호화되어 있고 비밀번호가 제공되지 않음 |
PageOutOfRange |
요청된 페이지 인덱스가 페이지 수를 초과 |
다음 단계
- Rust API 레퍼런스 – 메서드 수준 문서
- Python API 레퍼런스 – Python 바인딩
- Rust 시작하기 – 튜토리얼