shiva example
This commit is contained in:
parent
0c3439d788
commit
efb9c7c39d
1 changed files with 7 additions and 4 deletions
|
@ -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")?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue