use std::path::Path;
pub use crate::api_error::Error;
pub enum PdfSource<'a> {
Path(&'a Path),
Bytes(&'a [u8]),
}
impl<'a> From<&'a str> for PdfSource<'a> {
fn from(s: &'a str) -> Self {
PdfSource::Path(Path::new(s))
}
}
impl<'a> From<&'a Path> for PdfSource<'a> {
fn from(p: &'a Path) -> Self {
PdfSource::Path(p)
}
}
impl<'a> From<&'a [u8]> for PdfSource<'a> {
fn from(b: &'a [u8]) -> Self {
PdfSource::Bytes(b)
}
}
#[derive(Default, Debug, Clone)]
pub struct ReadOptions {
pub(crate) password: Option<String>,
pub(crate) repair: bool,
}
impl ReadOptions {
pub fn new() -> Self {
Self::default()
}
pub fn password(&mut self, pw: impl Into<String>) -> &mut Self {
self.password = Some(pw.into());
self
}
pub fn repair(&mut self, repair: bool) -> &mut Self {
self.repair = repair;
self
}
}
#[derive(Default, Debug, Clone)]
pub struct SaveOptions {
pub(crate) format: Option<PdfFormat>,
pub(crate) linearize: bool,
}
impl SaveOptions {
pub fn new() -> Self {
Self::default()
}
pub fn format(&mut self, format: PdfFormat) -> &mut Self {
self.format = Some(format);
self
}
pub fn linearize(&mut self, linearize: bool) -> &mut Self {
self.linearize = linearize;
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PdfFormat {
Pdf1_4,
Pdf1_7,
Pdf2_0,
PdfA1b,
PdfA2b,
PdfA3b,
}
#[derive(Default, Debug, Clone)]
pub struct WatermarkOptions {
pub opacity: f64,
pub rotation: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ImageFormat {
Png,
Jpeg,
}
pub struct TextBlock {
pub text: String,
pub bbox: [f64; 4],
}
pub struct Metadata {
pub title: Option<String>,
pub author: Option<String>,
pub creation_date: Option<String>,
}
pub struct FormField {
pub name: String,
pub value: String,
pub field_type: String,
}
pub struct Signature {
pub signer_name: String,
pub date: String,
pub is_valid: bool,
}
pub struct Document {
}
impl Document {
pub fn text(&self) -> String {
unimplemented!("facade")
}
pub fn page(&self, page_number: usize) -> Page {
let _ = page_number;
unimplemented!("facade")
}
pub fn structured_text(&self) -> Vec<TextBlock> {
unimplemented!("facade")
}
pub fn page_count(&self) -> usize {
unimplemented!("facade")
}
pub fn metadata(&self) -> Metadata {
unimplemented!("facade")
}
pub fn save(&self, path: impl AsRef<Path>) -> Result<(), Error> {
let _ = path;
unimplemented!("facade")
}
pub fn save_with<F>(&self, path: impl AsRef<Path>, build_opts: F) -> Result<(), Error>
where
F: FnOnce(&mut SaveOptions) -> &mut SaveOptions,
{
let _ = path;
let _ = build_opts;
unimplemented!("facade")
}
pub fn form_fields(&self) -> Vec<FormField> {
unimplemented!("facade")
}
pub fn fill_form(&self, fields: &[(&str, &str)]) -> Result<(), Error> {
let _ = fields;
unimplemented!("facade")
}
pub fn flatten_forms(&self) -> Result<(), Error> {
unimplemented!("facade")
}
pub fn sign(&self, certificate: &[u8], private_key: &[u8]) -> Result<(), Error> {
let _ = certificate;
let _ = private_key;
unimplemented!("facade")
}
pub fn signatures(&self) -> Vec<Signature> {
unimplemented!("facade")
}
pub fn verify_signatures(&self) -> Result<bool, Error> {
unimplemented!("facade")
}
pub fn redact(&self, text: &str) -> Result<(), Error> {
let _ = text;
unimplemented!("facade")
}
pub fn redact_region(&self, page: usize, rect: [f64; 4]) -> Result<(), Error> {
let _ = page;
let _ = rect;
unimplemented!("facade")
}
pub fn to_docx(&self, path: impl AsRef<Path>) -> Result<(), Error> {
let _ = path;
unimplemented!("facade")
}
pub fn to_images(&self, pattern: &str, format: ImageFormat) -> Result<(), Error> {
let _ = pattern;
let _ = format;
unimplemented!("facade")
}
pub fn is_pdfa_compliant(&self) -> Result<bool, Error> {
unimplemented!("facade")
}
pub fn merge(&self, other_doc: &Document) -> Result<(), Error> {
let _ = other_doc;
unimplemented!("facade")
}
pub fn split_pages(&self) -> Result<Vec<Document>, Error> {
unimplemented!("facade")
}
pub fn rotate_page(&self, page: usize, angle: i32) -> Result<(), Error> {
let _ = page;
let _ = angle;
unimplemented!("facade")
}
pub fn add_watermark(&self, text: &str, options: WatermarkOptions) -> Result<(), Error> {
let _ = text;
let _ = options;
unimplemented!("facade")
}
}
pub struct Page {
}
impl Page {
pub fn text(&self) -> String {
unimplemented!("facade")
}
}
pub fn read<'a, S: Into<PdfSource<'a>>>(input: S) -> Result<Document, Error> {
let _ = input;
unimplemented!("facade")
}
pub fn read_with<'a, S, F>(input: S, build_opts: F) -> Result<Document, Error>
where
S: Into<PdfSource<'a>>,
F: FnOnce(&mut ReadOptions) -> &mut ReadOptions,
{
let _ = input;
let _ = build_opts;
unimplemented!("facade")
}