shiva example

This commit is contained in:
Breval Ferrari 2025-04-06 10:41:41 -04:00
parent 0c3439d788
commit efb9c7c39d
No known key found for this signature in database
GPG key ID: F71E304D6400AB8E

View file

@ -2,8 +2,8 @@ use std::fs::File;
use anyhow::{anyhow, Context, Error}; use anyhow::{anyhow, Context, Error};
use bingus::{ use bingus::{
doc::printpdf::PdfDocument, img::{Dimensions, RgbImage},
img::{Dimensions, GrayImage}, txt::{DocumentType, ShivaDocument, ShivaFormat},
Bendable, Bytes, Bendable, Bytes,
}; };
use clap::Parser; use clap::Parser;
@ -16,7 +16,10 @@ fn main() -> Result<(), Error> {
let args = Cli::parse(); let args = Cli::parse();
let bytes = File::open(args.input_file) let bytes = File::open(args.input_file)
.context("opening file")? .context("opening file")?
.bend_into::<PdfDocument>((), Default::default()) .bend_into::<ShivaDocument>(
ShivaFormat::new(DocumentType::PDF, DocumentType::DOCX),
Default::default(),
)
.map_err(|e| anyhow!("parsing PDF: {e}"))? .map_err(|e| anyhow!("parsing PDF: {e}"))?
.bend_into::<Bytes>((), Default::default()) .bend_into::<Bytes>((), Default::default())
.unwrap_infallible(); .unwrap_infallible();
@ -28,7 +31,7 @@ fn main() -> Result<(), Error> {
} }
}; };
bytes bytes
.bend_into::<GrayImage>(dimensions, Default::default()) .bend_into::<RgbImage>(dimensions, Default::default())
.context("bending into an image")? .context("bending into an image")?
.save(args.output_file) .save(args.output_file)
.context("saving output file")?; .context("saving output file")?;