Available on crate feature
async only.Expand description
Executor-agnostic async wrappers for PDFKit document finding.
Enabled with the async Cargo feature.
PdfDocumentFindStream runs PDFDocument.findString(_:withOptions:) on a
worker thread, converts every match into an owned Rust snapshot, and emits a
bounded async stream backed by doom_fish_utils::stream::BoundedAsyncStream.
The stream emits synthetic DidBeginFind / DidEndFind notifications around
the match sequence. Dropping it waits for the worker thread to finish and then
closes the stream.
§Example
use pdfkit::async_api::{
PdfDocumentFindEvent, PdfDocumentFindOptions, PdfDocumentFindStream,
};
use pdfkit::PdfDocument;
let document = PdfDocument::from_url("examples/assets/hello.pdf")?;
let stream = PdfDocumentFindStream::find_string(
&document,
"Hello",
PdfDocumentFindOptions::NONE,
8,
)?;
while let Some(event) = stream.next().await {
match event {
PdfDocumentFindEvent::Notification(notification) => {
println!("notification={}", notification.name());
}
PdfDocumentFindEvent::Match(found) => {
println!("match={:?} pages={:?}", found.text, found.pages);
}
PdfDocumentFindEvent::Failed(error) => {
eprintln!("search failed: {error}");
}
}
}Structs§
- PdfDocument
Find Match - Owned snapshot of one
PDFDocumentstring match. - PdfDocument
Find Options PDFDocument.findString(_:withOptions:)comparison options.- PdfDocument
Find Page Match - One page of a match snapshot emitted by
PdfDocumentFindStream. - PdfDocument
Find Stream - Async stream of
PDFDocumentfind notifications and match snapshots.
Enums§
- PdfDocument
Find Event - Events emitted while a PDFKit string search is running.