pdfkit-rs
Safe Rust bindings for Apple's PDFKit framework on macOS. The published Cargo package is pdfkit-rs; the Rust library target is pdfkit.
Status: v0.2.0 extends the Swift bridge and safe Rust API with document/page editing, selections, outlines, actions, destinations, borders, appearance characteristics,
PDFView,PDFThumbnailView, and a documentedPDFAccessibilityNodestatus shim for the public-header gap.
Highlights
PdfDocumentfor loading, creating, mutating, and saving PDF documentsPdfPagefor bounds, text, character geometry, annotations, and selectionsPdfAnnotation,PdfBorder,PdfActionUrl, andPdfActionGoTofor lightweight annotation editingPdfOutlineandPdfDestinationfor outline trees and in-document navigation targetsPdfSelectionfor range/line inspection and selection compositionPdfViewandPdfThumbnailViewfor headless-safe view state and thumbnail configurationPdfAppearanceCharacteristicsfor widget appearance metadataPdfAccessibilityNode::public_api_available()for reporting that PDFKit only forward-declares the type on macOS
Quick start
use *;
Surface overview
Documents, pages, and selections
PdfDocument::new,from_url,from_bytes,write_to_urlPdfDocument::insert_page,remove_page,exchange_pages,set_outline_rootPdfDocument::selection_for_entire_document,selection_from_page_points,selection_from_page_charactersPdfPage::new,bounds,set_bounds,rotation,set_rotationPdfPage::selection_for_range,selection_for_rect,selection_for_word_at_point,selection_for_line_at_pointPdfSelection::new,text_range,selections_by_line,add_selection
Outlines, annotations, and navigation
PdfOutline::new,insert_child,set_label,set_destination,set_action_url,set_action_gotoPdfAnnotation::new,info,set_contents,set_border,set_action_url,set_action_gotoPdfBorder::new,info,set_style,set_line_width,set_dash_patternPdfDestination::new,info,page,set_zoom,comparePdfActionUrl::new,url,set_url,action_typePdfActionGoTo::new,destination,set_destination,action_type
View state
PdfView::new,set_document,set_display_mode,set_display_direction,set_display_boxPdfView::set_current_selection,go_to_page,go_to_destination,visible_pagesPdfThumbnailView::new,set_pdf_view,set_thumbnail_size,set_maximum_number_of_columns
Widget appearance + accessibility status
PdfAppearanceCharacteristics::new,set_control_type,set_caption,set_background_color,infoPdfAccessibilityNode::public_api_available,PdfAccessibilityNode::availability_note
Examples
The crate now ships one smoke example per logical area:
01_document_smoke02_page_basics03_annotation_link04_outline_tree05_selection_ranges06_view_state07_thumbnail_view_state08_action_url09_action_goto10_border_style11_destination_compare12_appearance_characteristics13_accessibility_node_status
Run one example:
Run all examples:
for; do ; done
Coverage audit
See COVERAGE.md for the v0.2.0 header audit and deferred/skipped items.
License
Licensed under either of Apache-2.0 or MIT at your option.