Rust API リファレンス
このページでは pdf_oxide のすべてのパブリック構造体とメソッドを記載しています。 Pythonバインディングについては Python API Reference. For type and enum details, see Types & Enums.
PdfDocument
The low-level document handle. PDFファイルを開く, extract text, images, and metadata.
use pdf_oxide::PdfDocument;
開き方と認証
| Method | Signature | 説明 |
|---|---|---|
open |
fn open(path: impl AsRef<Path>) -> Result<Self> |
ディスクからPDFファイルを開く |
open_from_bytes |
fn open_from_bytes(data: Vec<u8>) -> Result<Self> |
メモリ上のバイトからPDFを開く |
open_with_config |
fn open_with_config(path: impl AsRef<Path>, config: impl Any) -> Result<Self> |
パーサー設定で開く |
authenticate |
fn authenticate(&mut self, password: &[u8]) -> Result<bool> |
ユーザーまたはオーナーパスワードで認証 |
メタデータ
| Method | Signature | 説明 |
|---|---|---|
page_count |
fn page_count(&mut self) -> Result<usize> |
ドキュメントのページ数 |
page_count_u32 |
fn page_count_u32(&mut self) -> u32 |
ページ数 as u32 (0 on error) |
version |
fn version(&self) -> (u8, u8) |
PDFバージョン as (major, minor) |
trailer |
fn trailer(&self) -> &Object |
生のトレーラー辞書 |
catalog |
fn catalog(&mut self) -> Result<Object> |
ドキュメントカタログ辞書 |
テキスト抽出
| Method | Signature | 説明 |
|---|---|---|
extract_text |
fn extract_text(&mut self, page_index: usize) -> Result<String> |
単一ページからのプレーンテキスト |
extract_all_text |
fn extract_all_text(&mut self) -> Result<String> |
すべてのページからのプレーンテキスト |
extract_spans |
fn extract_spans(&mut self, page_index: usize) -> Result<Vec<TextSpan>> |
フォントメタデータ付きテキストラン |
extract_spans_with_config |
fn extract_spans_with_config(&mut self, page_index: usize, config: &TextConfig) -> Result<Vec<TextSpan>> |
カスタム設定付きスパン |
extract_chars |
fn extract_chars(&mut self, page_index: usize) -> Result<Vec<TextChar>> |
文字ごとの位置とメタデータ |
extract_text_with_ocr |
fn extract_text_with_ocr(&mut self, page_index: usize) -> Result<String> |
スキャンページ用のOCRフォールバック付きテキスト |
extract_spans_with_ocr |
fn extract_spans_with_ocr(&mut self, page_index: usize) -> Result<Vec<TextSpan>> |
OCRフォールバック付きスパン |
apply_intelligent_text_processing |
fn apply_intelligent_text_processing(&self, spans: Vec<TextSpan>) -> Vec<TextSpan> |
合字展開、ハイフン再構成、OCRクリーンアップ |
extract_hierarchical_content |
fn extract_hierarchical_content(&mut self, page_index: usize) -> Result<Vec<ContentElement>> |
タグ付きPDFからの構造化コンテンツツリー |
変換
| Method | Signature | 説明 |
|---|---|---|
to_markdown |
fn to_markdown(&mut self, page_index: usize, options: &ConversionOptions) -> Result<String> |
Convert page to Markdown |
to_html |
fn to_html(&mut self, page_index: usize, options: &ConversionOptions) -> Result<String> |
Convert page to HTML |
to_plain_text |
fn to_plain_text(&mut self, page_index: usize) -> Result<String> |
Convert page to plain text |
to_markdown_all |
fn to_markdown_all(&mut self, options: &ConversionOptions) -> Result<String> |
すべてのページをMarkdownに変換 |
to_html_all |
fn to_html_all(&mut self, options: &ConversionOptions) -> Result<String> |
すべてのページをHTMLに変換 |
to_plain_text_all |
fn to_plain_text_all(&mut self) -> Result<String> |
すべてのページをプレーンテキストに変換 |
to_markdown_with_ocr |
fn to_markdown_with_ocr(&mut self, page_index: usize, options: &ConversionOptions) -> Result<String> |
OCRフォールバック付きMarkdown |
画像抽出
| Method | Signature | 説明 |
|---|---|---|
extract_images |
fn extract_images(&mut self, page_index: usize) -> Result<Vec<ImageInfo>> |
ページからの画像メタデータと生データ |
extract_images_to_files |
fn extract_images_to_files(&mut self, page_index: usize, output_dir: &str) -> Result<Vec<PathBuf>> |
画像を抽出してディスクに保存 |
パスとグラフィックスの抽出
| Method | Signature | 説明 |
|---|---|---|
extract_paths |
fn extract_paths(&mut self, page_index: usize) -> Result<Vec<PathContent>> |
ページからのベクターグラフィックス |
extract_paths_in_rect |
fn extract_paths_in_rect(&mut self, page_index: usize, rect: Rect) -> Result<Vec<PathContent>> |
矩形領域内のパス |
ページ情報
| Method | Signature | 説明 |
|---|---|---|
get_page_info |
fn get_page_info(&mut self, page_index: usize) -> Result<PageInfo> |
ページの寸法、回転、ボックス |
get_page_resources |
fn get_page_resources(&mut self, page_index: usize) -> Result<Object> |
Raw resources dictionary |
get_page_content_data |
fn get_page_content_data(&mut self, page_index: usize) -> Result<Vec<u8>> |
Raw content stream bytes |
構造とアクセシビリティ
| Method | Signature | 説明 |
|---|---|---|
structure_tree |
fn structure_tree(&mut self) -> Result<Option<StructTreeRoot>> |
タグ付き構造ツリー |
mark_info |
fn mark_info(&mut self) -> Result<MarkInfo> |
MarkInfo辞書(tagged、suspects) |
低レベル
| Method | Signature | 説明 |
|---|---|---|
load_object |
fn load_object(&mut self, obj_ref: ObjectRef) -> Result<Object> |
参照でPDFオブジェクトを読み込み |
resolve_object |
fn resolve_object(&mut self, obj: &Object) -> Result<Object> |
間接参照を解決 |
resolve_references |
fn resolve_references(&mut self, obj: &Object, max_depth: usize) -> Result<Object> |
すべての参照を再帰的に解決 |
check_for_circular_references |
fn check_for_circular_references(&mut self) -> Vec<(ObjectRef, ObjectRef)> |
循環参照チェーンを検出 |
統一された高レベルAPI。抽出、作成、編集、検索、準拠を1つの型で実現。
use pdf_oxide::api::Pdf;
コンストラクタ
| Method | Signature | 説明 |
|---|---|---|
new |
fn new() -> Self |
空のPdfインスタンスを作成 |
open |
fn open(path: impl AsRef<Path>) -> Result<Self> |
既存のPDFを読み取り用に開く |
open_editor |
fn open_editor(path: impl AsRef<Path>) -> Result<DocumentEditor> |
構造編集用に開く |
from_markdown |
fn from_markdown(content: &str) -> Result<Self> |
Create PDF from Markdown |
from_html |
fn from_html(content: &str) -> Result<Self> |
Create PDF from HTML |
from_text |
fn from_text(content: &str) -> Result<Self> |
Create PDF from plain text |
from_image |
fn from_image(path: impl AsRef<Path>) -> Result<Self> |
Create PDF from image file |
from_image_bytes |
fn from_image_bytes(data: &[u8]) -> Result<Self> |
Create PDF from image bytes |
from_images |
fn from_images<P: AsRef<Path>>(paths: &[P]) -> Result<Self> |
Multi-page from images |
from_qrcode |
fn from_qrcode(data: &str) -> Result<Self> |
QRコードを含むPDF |
from_qrcode_with_options |
fn from_qrcode_with_options(data: &str, size: f32, ecl: &str) -> Result<Self> |
カスタムサイズとエラー訂正付きQRコード |
from_barcode |
fn from_barcode(data: &str, barcode_type: BarcodeType) -> Result<Self> |
バーコードを含むPDF |
from_barcode_with_options |
fn from_barcode_with_options(data: &str, barcode_type: BarcodeType, width: f32, height: f32) -> Result<Self> |
カスタム寸法のバーコード |
抽出
| Method | Signature | 説明 |
|---|---|---|
page_count |
fn page_count(&mut self) -> Result<usize> |
ページ数 |
page |
fn page(&mut self, index: usize) -> Result<PdfPage> |
DOMライクページハンドル |
to_markdown |
fn to_markdown(&mut self, page: usize) -> Result<String> |
ページをMarkdownに |
to_html |
fn to_html(&mut self, page: usize) -> Result<String> |
ページをHTMLに |
to_text |
fn to_text(&mut self, page: usize) -> Result<String> |
ページをプレーンテキストに |
検索
| Method | Signature | 説明 |
|---|---|---|
search |
fn search(&mut self, pattern: &str) -> Result<Vec<SearchResult>> |
すべてのページを検索 |
search_with_options |
fn search_with_options(&mut self, pattern: &str, opts: &SearchOptions) -> Result<Vec<SearchResult>> |
Search with options |
search_page |
fn search_page(&mut self, page: usize, pattern: &str) -> Result<Vec<SearchResult>> |
単一ページを検索 |
highlight_matches |
fn highlight_matches(&mut self, pattern: &str) -> Result<usize> |
ハイライト注釈を追加s for matches |
メタデータ
| Method | Signature | 説明 |
|---|---|---|
set_title |
fn set_title(&mut self, title: impl Into<String>) -> Result<()> |
ドキュメントタイトルを設定 |
set_author |
fn set_author(&mut self, author: impl Into<String>) -> Result<()> |
著者を設定 |
set_subject |
fn set_subject(&mut self, subject: impl Into<String>) -> Result<()> |
件名を設定 |
set_keywords |
fn set_keywords(&mut self, keywords: impl Into<String>) -> Result<()> |
キーワードを設定 |
XMP メタデータ
| Method | Signature | 説明 |
|---|---|---|
xmp_metadata |
fn xmp_metadata(&mut self) -> Result<Option<XmpMetadata>> |
Full XMP metadata |
has_xmp_metadata |
fn has_xmp_metadata(&mut self) -> Result<bool> |
XMP存在確認 |
xmp_title |
fn xmp_title(&mut self) -> Result<Option<String>> |
XMP dc:title |
xmp_creators |
fn xmp_creators(&mut self) -> Result<Vec<String>> |
XMP dc:creatorリスト |
xmp_description |
fn xmp_description(&mut self) -> Result<Option<String>> |
XMP dc:description |
xmp_creator_tool |
fn xmp_creator_tool(&mut self) -> Result<Option<String>> |
XMP xmp:CreatorTool |
xmp_create_date |
fn xmp_create_date(&mut self) -> Result<Option<String>> |
XMP xmp:CreateDate |
xmp_modify_date |
fn xmp_modify_date(&mut self) -> Result<Option<String>> |
XMP xmp:ModifyDate |
xmp_producer |
fn xmp_producer(&mut self) -> Result<Option<String>> |
XMP pdf:Producer |
ページラベル
| Method | Signature | 説明 |
|---|---|---|
page_labels |
fn page_labels(&mut self) -> Result<Vec<PageLabelRange>> |
ページラベル範囲 |
page_label |
fn page_label(&mut self, page: usize) -> Result<String> |
特定ページのラベル |
all_page_labels |
fn all_page_labels(&mut self) -> Result<Vec<String>> |
全ページのラベル |
ページ操作
| Method | Signature | 説明 |
|---|---|---|
page_rotation |
fn page_rotation(&mut self, page: usize) -> Result<i32> |
度単位の現在の回転 |
set_page_rotation |
fn set_page_rotation(&mut self, page: usize, degrees: i32) -> Result<()> |
絶対回転を設定 |
rotate_page |
fn rotate_page(&mut self, page: usize, degrees: i32) -> Result<()> |
相対回転を追加 |
rotate_all_pages |
fn rotate_all_pages(&mut self, degrees: i32) -> Result<()> |
すべてのページを回転 |
page_media_box |
fn page_media_box(&mut self, page: usize) -> Result<[f32; 4]> |
MediaBoxの寸法 |
set_page_media_box |
fn set_page_media_box(&mut self, page: usize, rect: [f32; 4]) -> Result<()> |
MediaBoxを設定 |
page_crop_box |
fn page_crop_box(&mut self, page: usize) -> Result<Option<[f32; 4]>> |
CropBoxの寸法 |
set_page_crop_box |
fn set_page_crop_box(&mut self, page: usize, rect: [f32; 4]) -> Result<()> |
CropBoxを設定 |
crop_margins |
fn crop_margins(&mut self, left: f32, right: f32, top: f32, bottom: f32) -> Result<()> |
マージンで全ページをトリミング |
コンテンツ編集
| Method | Signature | 説明 |
|---|---|---|
save_page |
fn save_page(&mut self, page: PdfPage) -> Result<()> |
変更ページを保存 back |
erase_region |
fn erase_region(&mut self, page: usize, rect: [f32; 4]) -> Result<()> |
White-out a rectangular area |
erase_regions |
fn erase_regions(&mut self, page: usize, rects: &[[f32; 4]]) -> Result<()> |
White-out multiple areas |
clear_erase_regions |
fn clear_erase_regions(&mut self, page: usize) |
保留中の消去操作をクリア |
アノテーション
| Method | Signature | 説明 |
|---|---|---|
flatten_page_annotations |
fn flatten_page_annotations(&mut self, page: usize) -> Result<()> |
ページ上のアノテーションをフラット化 |
flatten_all_annotations |
fn flatten_all_annotations(&mut self) -> Result<()> |
すべての注釈をフラット化 |
is_page_marked_for_flatten |
fn is_page_marked_for_flatten(&self, page: usize) -> bool |
フラット化ステータスを確認 |
unmark_page_for_flatten |
fn unmark_page_for_flatten(&mut self, page: usize) |
Unmark a page |
フォーム
| Method | Signature | 説明 |
|---|---|---|
flatten_forms_on_page |
fn flatten_forms_on_page(&mut self, page: usize) -> Result<()> |
Flatten forms on a page |
flatten_forms |
fn flatten_forms(&mut self) -> Result<()> |
すべてのフォームフィールドをフラット化 |
is_page_marked_for_form_flatten |
fn is_page_marked_for_form_flatten(&self, page: usize) -> bool |
Check if page forms are marked for flatten |
will_remove_acroform |
fn will_remove_acroform(&self) -> bool |
AcroFormが削除されるか確認 on save |
export_form_data_fdf |
fn export_form_data_fdf(&mut self, output_path: impl AsRef<Path>) -> Result<()> |
Export form data as FDF |
export_form_data_xfdf |
fn export_form_data_xfdf(&mut self, output_path: impl AsRef<Path>) -> Result<()> |
Export form data as XFDF |
墨消し
| Method | Signature | 説明 |
|---|---|---|
apply_page_redactions |
fn apply_page_redactions(&mut self, page: usize) -> Result<()> |
ページの墨消しを適用 |
apply_all_redactions |
fn apply_all_redactions(&mut self) -> Result<()> |
保留中のすべての墨消しを適用 |
is_page_marked_for_redaction |
fn is_page_marked_for_redaction(&self, page: usize) -> bool |
ページに保留中の墨消しがあるか確認 |
unmark_page_for_redaction |
fn unmark_page_for_redaction(&mut self, page: usize) |
ページの保留中の墨消しを削除 |
画像
| Method | Signature | 説明 |
|---|---|---|
page_images |
fn page_images(&mut self, page: usize) -> Result<Vec<ImageInfo>> |
List images on a page |
reposition_image |
fn reposition_image(&mut self, page: usize, image_index: usize, x: f32, y: f32) -> Result<()> |
画像を移動 |
resize_image |
fn resize_image(&mut self, page: usize, image_index: usize, width: f32, height: f32) -> Result<()> |
画像のサイズ変更 |
set_image_bounds |
fn set_image_bounds(&mut self, page: usize, image_index: usize, rect: [f32; 4]) -> Result<()> |
Set image bounding box |
clear_image_modifications |
fn clear_image_modifications(&mut self, page: usize) |
保留画像変更クリア |
has_image_modifications |
fn has_image_modifications(&self, page: usize) -> bool |
保留画像変更確認 |
埋め込みファイル
| Method | Signature | 説明 |
|---|---|---|
embed_file |
fn embed_file(&mut self, name: &str, data: Vec<u8>) -> Result<()> |
ファイルを添付 |
embed_file_with_options |
fn embed_file_with_options(&mut self, file: EmbeddedFile) -> Result<()> |
フル設定で添付 |
pending_embedded_files |
fn pending_embedded_files(&self) -> &[EmbeddedFile] |
List pending file attachments |
clear_embedded_files |
fn clear_embedded_files(&mut self) |
Clear pending file attachments |
レンダリング (requires rendering feature)
| Method | Signature | 説明 |
|---|---|---|
render_page |
fn render_page(&mut self, page: usize) -> Result<RenderedImage> |
画像にレンダリング |
render_page_with_options |
fn render_page_with_options(&mut self, page: usize, opts: &RenderOptions) -> Result<RenderedImage> |
オプション付きでレンダリング |
render_page_to_file |
fn render_page_to_file(&mut self, page: usize, path: impl AsRef<Path>) -> Result<()> |
レンダリングしてファイルに保存 |
render_page_to_file_with_dpi |
fn render_page_to_file_with_dpi(&mut self, page: usize, path: impl AsRef<Path>, dpi: f32) -> Result<()> |
カスタムDPIでレンダリング |
保存
| Method | Signature | 説明 |
|---|---|---|
save |
fn save(&mut self, path: impl AsRef<Path>) -> Result<()> |
ファイルに保存 |
save_as |
fn save_as(&mut self, path: impl AsRef<Path>) -> Result<()> |
別のファイルに保存 |
save_encrypted |
fn save_encrypted(&mut self, path: impl AsRef<Path>, user_password: &str, owner_password: &str) -> Result<()> |
パスワード保護で保存 |
save_with_encryption |
fn save_with_encryption(&mut self, path: impl AsRef<Path>, config: EncryptionConfig) -> Result<()> |
Save with full encryption config |
as_bytes |
fn as_bytes(&self) -> &[u8] |
PDFバイト(作成モード) |
into_bytes |
fn into_bytes(mut self) -> Vec<u8> |
消費してPDFバイトを返す |
to_bytes |
fn to_bytes(&mut self) -> Result<Vec<u8>> |
PDFバイトを生成 |
to_markdown_file |
fn to_markdown_file(&mut self, path: impl AsRef<Path>) -> Result<()> |
全ページをMarkdownファイルとして保存 |
アクセサ
| Method | Signature | 説明 |
|---|---|---|
source_path |
fn source_path(&self) -> Option<&Path> |
開いたファイルのパス |
editor |
fn editor(&mut self) -> Option<&mut DocumentEditor> |
基礎エディタにアクセス |
config |
fn config(&self) -> &PdfConfig |
現在の設定 |
is_modified |
fn is_modified(&self) -> bool |
ドキュメントに未保存の変更があるかどうか |
PdfBuilder
メタデータとレイアウト設定付きPDF作成用の流暢なビルダーです。
use pdf_oxide::api::PdfBuilder;
use pdf_oxide::writer::PageSize;
| Method | Signature | 説明 |
|---|---|---|
new |
fn new() -> Self |
新しいビルダーを作成 |
title |
fn title(self, title: impl Into<String>) -> Self |
タイトルを設定 |
author |
fn author(self, author: impl Into<String>) -> Self |
著者を設定 |
subject |
fn subject(self, subject: impl Into<String>) -> Self |
件名を設定 |
keywords |
fn keywords(self, keywords: impl Into<String>) -> Self |
キーワードを設定 |
page_size |
fn page_size(self, size: PageSize) -> Self |
ページサイズを設定 |
margin |
fn margin(self, margin: f32) -> Self |
均一マージンを設定 |
margins |
fn margins(self, left: f32, right: f32, top: f32, bottom: f32) -> Self |
個別マージンを設定 |
font_size |
fn font_size(self, size: f32) -> Self |
フォントサイズを設定 |
line_height |
fn line_height(self, height: f32) -> Self |
行の高さを設定 |
from_markdown |
fn from_markdown(self, content: &str) -> Result<Pdf> |
Markdownから作成 |
from_html |
fn from_html(self, content: &str) -> Result<Pdf> |
HTMLから作成 |
from_text |
fn from_text(self, content: &str) -> Result<Pdf> |
プレーンテキストから作成 |
from_image |
fn from_image(self, path: impl AsRef<Path>) -> Result<Pdf> |
画像から作成 |
from_image_bytes |
fn from_image_bytes(self, data: &[u8]) -> Result<Pdf> |
画像から作成 bytes |
from_images |
fn from_images<P: AsRef<Path>>(self, paths: &[P]) -> Result<Pdf> |
複数画像からビルド |
from_qrcode |
fn from_qrcode(self, data: &str) -> Result<Pdf> |
QRコードデータからビルド |
from_barcode |
fn from_barcode(self, data: &str, barcode_type: BarcodeType) -> Result<Pdf> |
バーコードデータからビルド |
DocumentBuilder
ピクセル精度のページレイアウト用低レベルビルダーです。
use pdf_oxide::writer::DocumentBuilder;
| Method | Signature | 説明 |
|---|---|---|
new |
fn new() -> Self |
新しいビルダーを作成 |
metadata |
fn metadata(self, metadata: DocumentMetadata) -> Self |
ドキュメントメタデータを設定 |
page |
fn page(&mut self, size: PageSize) -> FluentPageBuilder |
Add a page with named size |
letter_page |
fn letter_page(&mut self) -> FluentPageBuilder |
Add US Letter page |
a4_page |
fn a4_page(&mut self) -> FluentPageBuilder |
Add A4 page |
build |
fn build(self) -> Result<Vec<u8>> |
PDFバイトを生成 |
save |
fn save(self, path: impl AsRef<Path>) -> Result<()> |
ファイルに保存 |
FluentPageBuilder
DocumentBuilder::page() で返されます。呼び出しをチェーンしてページにコンテンツを追加:
| Method | 説明 |
|---|---|
text(text, x, y, size) |
正確な座標にテキスト配置 |
heading(level, text) |
見出し(H1-H6)を追加 |
paragraph(text) |
自動折返し付き段落を追加 |
space(points) |
垂直スペースを追加 |
horizontal_rule() |
水平線を描画 |
link_url(url) |
URLリンクアノテーションを追加 |
link_page(page) |
内部ページリンクを追加 |
highlight(color) |
ハイライト注釈を追加 |
underline(color) |
下線アノテーションを追加 |
strikeout(color) |
取消線アノテーションを追加 |
sticky_note(text) |
付箋を追加 |
stamp(stamp_type) |
スタンプアノテーションを追加 |
freetext(rect, text) |
フリーテキストアノテーション追加 |
watermark(text) |
透かしオーバーレイを追加 |
add_annotation(annotation) |
任意の注釈タイプを追加 |
done() |
ページ完了、ビルダーに戻る |
DocumentEditor
構造変更用に既存PDFを開きます。
use pdf_oxide::editor::DocumentEditor;
コア
| Method | Signature | 説明 |
|---|---|---|
open |
fn open(path: impl AsRef<Path>) -> Result<Self> |
ファイルを編集用に開く |
is_modified |
fn is_modified(&self) -> bool |
未保存の変更を確認 |
source_path |
fn source_path(&self) -> &str |
元のファイルパス |
source |
fn source(&self) -> &PdfDocument |
基礎ドキュメント(読取) |
source_mut |
fn source_mut(&mut self) -> &mut PdfDocument |
基礎ドキュメント(書込) |
version |
fn version(&self) -> (u8, u8) |
PDFバージョン |
current_page_count |
fn current_page_count(&self) -> usize |
ページ数 |
メタデータ
| Method | 説明 |
|---|---|
title() / set_title() |
ドキュメントタイトルの取得/設定 |
author() / set_author() |
著者の取得/設定 |
subject() / set_subject() |
件名の取得/設定 |
keywords() / set_keywords() |
キーワードの取得/設定 |
ページ操作
| Method | 説明 |
|---|---|
get_page_rotation() / set_page_rotation() |
回転の取得/設定 |
rotate_page_by() |
相対回転を追加 |
rotate_all_pages() |
すべてのページを回転 |
get_page_media_box() / set_page_media_box() |
MediaBoxの取得/設定 |
get_page_crop_box() / set_page_crop_box() |
CropBoxの取得/設定 |
crop_margins() |
マージンで全ページをトリミング |
erase_region() / erase_regions() |
コンテンツのホワイトアウト |
extract_pages() |
ページを別ファイルに抽出 |
merge_from() / merge_pages_from() |
別のPDFからページを結合 |
DOM ライクな編集
| Method | Signature | 説明 |
|---|---|---|
get_page |
fn get_page(&mut self, page_index: usize) -> Result<PdfPage> |
DOMページハンドルを取得 |
save_page |
fn save_page(&mut self, page: PdfPage) -> Result<()> |
変更ページを保存 |
edit_page |
fn edit_page<F>(&mut self, page_index: usize, f: F) -> Result<()> |
クロージャで編集 |
page_editor |
fn page_editor(&mut self, page_index: usize) -> Result<PageEditor> |
ページエディタを取得 |
get_page_content |
fn get_page_content(&mut self, page_index: usize) -> Result<Option<StructureElement>> |
ページ構造を取得 |
set_page_content |
fn set_page_content(&mut self, page_index: usize, content: StructureElement) -> Result<()> |
ページ構造を設定 |
modify_structure |
fn modify_structure<F>(&mut self, page_index: usize, f: F) -> Result<()> |
クロージャで構造変更 |
フォームフィールド
| Method | 説明 |
|---|---|
get_form_fields() |
すべてのフォームフィールドを一覧 |
get_form_field_value(name) |
名前でフィールド値を取得 |
set_form_field_value(name, value: FormFieldValue) |
名前でフィールド値を設定 |
has_form_field(name) |
フィールド存在確認 |
add_form_field(widget) |
新しいフォームフィールドを追加 |
flatten_forms_on_page(page) |
Flatten forms on a page |
flatten_forms() |
すべてのフォームフィールドをフラット化 |
export_form_data_fdf(path) |
FDFとしてエクスポート |
export_form_data_xfdf(path) |
XFDFとしてエクスポート |
has_xfa() |
XFAフォームの確認 |
analyze_xfa() |
XFAフォームデータの分析 |
convert_xfa_to_acroform() |
XFAをAcroFormに変換 |
アノテーションとフラット化
| Method | 説明 |
|---|---|
flatten_page_annotations(page) |
ページ上のアノテーションをフラット化 |
flatten_all_annotations() |
すべての注釈をフラット化 |
get_page_annotations(page) |
ページのアノテーション一覧 |
埋め込みファイル
| Method | 説明 |
|---|---|
embed_file(name, data) |
ファイルを添付 |
embed_file_with_options(file) |
フル設定で添付 |
pending_embedded_files() |
保留添付ファイル一覧 |
clear_embedded_files() |
保留添付ファイルクリア |
DOM 型
PdfPage
クエリ可能で編集可能な要素を持つ単一ページを表します。
| Method | 説明 |
|---|---|
elements() |
ページ上のすべての要素 |
text_elements() |
テキスト要素のみ |
image_elements() |
画像要素のみ |
path_elements() |
パス/グラフィックス要素のみ |
table_elements() |
テーブル要素のみ |
find_text_containing(needle) |
部分文字列に一致するテキストを検索 |
set_text(id, new_text) |
テキストを置換 by element ID |
PdfText
| Method | Return | 説明 |
|---|---|---|
id() |
ElementId |
一意の要素識別子 |
text() |
&str |
テキストコンテンツ |
bbox() |
Rect |
バウンディング矩形 |
font_name() |
&str |
フォント名 |
font_size() |
f32 |
フォントサイズ(ポイント) |
is_bold() |
bool |
太字 |
is_italic() |
bool |
イタリック |
color() |
Color |
テキストの色 |
set_text(new) |
テキストを置換 | |
append(text) |
Append text | |
replace(old, new) |
usize |
Replace occurrences |
clear() |
Clear text |
PdfImage
| Method | Return | 説明 |
|---|---|---|
id() |
ElementId |
一意の識別子 |
bbox() |
Rect |
バウンディング矩形 |
format() |
ImageFormat |
画像形式 |
dimensions() |
(u32, u32) |
Width and height in pixels |
aspect_ratio() |
f32 |
幅 / 高さの比率 |
is_grayscale() |
bool |
Grayscale check |
alt_text() |
Option<&str> |
Alt text for accessibility |
resolution() |
Option<(f32, f32)> |
DPI(水平、垂直) |
PdfPath
| Method | Return | 説明 |
|---|---|---|
id() |
ElementId |
一意の識別子 |
bbox() |
Rect |
バウンディング矩形 |
operations() |
&[PathOperation] |
Path drawing operations |
stroke_color() |
Option<Color> |
ストロークの色 |
fill_color() |
Option<Color> |
塗りつぶしの色 |
stroke_width() |
f32 |
線幅 |
line_cap() |
LineCap |
線端スタイル |
line_join() |
LineJoin |
線結合スタイル |
is_closed() |
bool |
パスが閉じているか |
to_svg() |
String |
SVGパスデータに変換 |
to_svg_document() |
String |
スタンドアロンSVGに変換 |
PdfTable
| Method | Return | 説明 |
|---|---|---|
id() |
ElementId |
一意の識別子 |
bbox() |
Rect |
バウンディング矩形 |
row_count() |
usize |
行数 |
column_count() |
usize |
列数 |
has_header() |
bool |
最初の行がヘッダーかどうか |
get_cell(row, col) |
Option<&TableCellContent> |
セルの内容 |
caption() |
Option<&str> |
テーブルキャプション |
TextSearcher
use pdf_oxide::search::{TextSearcher, SearchOptions, SearchResult};
SearchOptions
| Field | Type | Default | 説明 |
|---|---|---|---|
case_sensitive |
bool |
true |
大文字小文字区別マッチング |
literal |
bool |
false |
リテラルとして扱う(正規表現でない) |
whole_word |
bool |
false |
完全一致のみマッチ |
max_results |
Option<usize> |
None |
結果数を制限 |
page_range |
Option<(usize, usize)> |
None |
ページ範囲に制限 |
SearchResult
| Field | Type | 説明 |
|---|---|---|
page |
usize |
ページインデックス |
text |
String |
一致したテキスト |
x |
f64 |
X position in points |
y |
f64 |
Y position in points |
FormField and XmpExtractor
FormField (read)
| Field | Type | 説明 |
|---|---|---|
name |
String |
完全修飾フィールド名 |
field_type |
FieldType |
Text, Button, Choice, Signature |
value |
Option<String> |
現在の値 |
rect |
Option<Rect> |
ウィジェットの境界 |
flags |
u32 |
フィールドフラグ |
XmpExtractor
use pdf_oxide::extractors::xmp::XmpExtractor;
PdfDocument で動作する静的メソッド:
| Method | Return | 説明 |
|---|---|---|
extract(doc) |
Result<Option<XmpMetadata>> |
XMPメタデータを抽出 |
XmpMetadata
| Field | Type | 説明 |
|---|---|---|
title |
Option<String> |
dc:title |
creators |
Vec<String> |
dc:creator |
description |
Option<String> |
dc:description |
creator_tool |
Option<String> |
xmp:CreatorTool |
create_date |
Option<String> |
xmp:CreateDate |
modify_date |
Option<String> |
xmp:ModifyDate |
producer |
Option<String> |
pdf:Producer |
PageLabelExtractor
use pdf_oxide::extractors::page_labels::PageLabelExtractor;
| Method | Return | 説明 |
|---|---|---|
extract(doc) |
Result<Vec<PageLabelRange>> |
ページラベル定義を抽出 |
label_for_page(doc, page) |
Result<String> |
特定ページのラベルを計算 |
all_labels(doc) |
Result<Vec<String>> |
全ページのラベルを計算 |
スタンドアロン関数
use pdf_oxide::document::{parse_header, parse_trailer};
| Function | Signature | 説明 |
|---|---|---|
parse_header |
fn parse_header<R: Read + Seek>(reader: &mut R, lenient: bool) -> Result<(u8, u8, u64)> |
PDFヘッダーをパース、(major, minor, byte_offset) を返す |
parse_trailer |
fn parse_trailer<R: Read>(reader: &mut R) -> Result<Object> |
トレーラー辞書をパース |
次のステップ
- Python API Reference – Pythonバインディングリファレンス
- Types & Enums – すべての型、列挙型、設定構造体
- Getting Started with Rust – チュートリアルと例