elizaos_plugin_pdf/
lib.rs1#![allow(missing_docs)]
2
3pub mod client;
4pub mod error;
5pub mod service;
6pub mod types;
7
8pub use client::PdfClient;
9pub use error::{PdfError, Result};
10pub use service::PdfService;
11pub use types::*;
12
13#[allow(unused_imports)]
14use anyhow::Result as AnyhowResult;
15
16pub struct PdfPlugin {
21 client: PdfClient,
22}
23
24impl PdfPlugin {
25 pub fn new() -> Self {
27 Self {
28 client: PdfClient::new(),
29 }
30 }
31
32 pub async fn extract_text(
33 &self,
34 pdf_bytes: &[u8],
35 options: Option<PdfExtractionOptions>,
36 ) -> Result<String> {
37 self.client.extract_text(pdf_bytes, options).await
38 }
39
40 pub async fn extract_text_from_file(
42 &self,
43 file_path: &str,
44 options: Option<PdfExtractionOptions>,
45 ) -> Result<String> {
46 self.client.extract_text_from_file(file_path, options).await
47 }
48
49 pub async fn convert_to_text(
50 &self,
51 pdf_bytes: &[u8],
52 options: Option<PdfExtractionOptions>,
53 ) -> PdfConversionResult {
54 self.client.convert_to_text(pdf_bytes, options).await
55 }
56
57 pub async fn get_document_info(&self, pdf_bytes: &[u8]) -> Result<PdfDocumentInfo> {
59 self.client.get_document_info(pdf_bytes).await
60 }
61
62 pub async fn get_page_count(&self, pdf_bytes: &[u8]) -> Result<usize> {
63 self.client.get_page_count(pdf_bytes).await
64 }
65
66 pub fn client(&self) -> &PdfClient {
67 &self.client
68 }
69}
70
71impl Default for PdfPlugin {
72 fn default() -> Self {
73 Self::new()
74 }
75}
76
77pub fn get_pdf_plugin() -> PdfPlugin {
78 PdfPlugin::new()
79}