pub struct Tools { /* private fields */ }Expand description
Access to the document tools. Get it with Wellfriend::tools.
Each tool has a typed method (generated from the tool catalog) that uploads the input,
starts the operation, waits for it and returns a ToolResult:
use wellfriend::{CompressPdfParams, CompressPdfProfile};
let params = CompressPdfParams { profile: Some(CompressPdfProfile::AggressiveLossless), ..Default::default() };
let result = wf.tools().compress_pdf("scan.pdf", Some(params)).await?;
result.save("scan.small.pdf").await?;Implementations§
Source§impl Tools
impl Tools
Sourcepub fn with_options(self, options: RequestOptions) -> Self
pub fn with_options(self, options: RequestOptions) -> Self
The same handle with these options for every call made through it.
Sourcepub async fn run(
&self,
tool: impl Into<ToolId>,
input: impl Into<ToolInput>,
params: Option<ToolParameters>,
) -> Result<ToolResult>
pub async fn run( &self, tool: impl Into<ToolId>, input: impl Into<ToolInput>, params: Option<ToolParameters>, ) -> Result<ToolResult>
Runs any tool by id and waits for the result.
use wellfriend::{ToolId, ToolParameters};
let params = ToolParameters::new().set("profile", "medium");
wf.tools().run(ToolId::CompressPdf, "in.pdf", Some(params)).await?.save("out.pdf").await?;Sourcepub async fn start(
&self,
tool: impl Into<ToolId>,
input: impl Into<ToolInput>,
params: Option<ToolParameters>,
) -> Result<Operation>
pub async fn start( &self, tool: impl Into<ToolId>, input: impl Into<ToolInput>, params: Option<ToolParameters>, ) -> Result<Operation>
Starts a tool and returns the operation without waiting for it. Resume later with
DocumentOperations::wait.
Sourcepub fn request(&self, tool: impl Into<ToolId>) -> ToolRequest
pub fn request(&self, tool: impl Into<ToolId>) -> ToolRequest
A request builder, for tools that read named asset files.
Source§impl Tools
impl Tools
Sourcepub async fn add_page_numbers(
&self,
input: impl Into<FileInput>,
params: Option<AddPageNumbersParams>,
) -> Result<ToolResult>
pub async fn add_page_numbers( &self, input: impl Into<FileInput>, params: Option<AddPageNumbersParams>, ) -> Result<ToolResult>
Add Page Numbers: Insert numbered headers or footers.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn add_watermark(
&self,
input: impl Into<FileInput>,
params: Option<AddWatermarkParams>,
) -> Result<ToolResult>
pub async fn add_watermark( &self, input: impl Into<FileInput>, params: Option<AddWatermarkParams>, ) -> Result<ToolResult>
Add Watermark: Stamp text or image onto pages.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn edit_metadata(
&self,
input: impl Into<FileInput>,
params: Option<EditMetadataParams>,
) -> Result<ToolResult>
pub async fn edit_metadata( &self, input: impl Into<FileInput>, params: Option<EditMetadataParams>, ) -> Result<ToolResult>
Check & Edit Metadata: Review and update document information.
Accepts .pdf. Returns PDF document (application/pdf), or a ZIP of PDFs in batch mode (application/zip).
Sourcepub async fn check_pdf(
&self,
input: impl Into<FileInput>,
params: Option<CheckPdfParams>,
) -> Result<ToolResult>
pub async fn check_pdf( &self, input: impl Into<FileInput>, params: Option<CheckPdfParams>, ) -> Result<ToolResult>
Check PDF: One report on PDF/A conformance, PDF/UA accessibility and digital signatures.
Accepts .pdf. Returns JSON report (application/json): PDF/A conformance, PDF/UA accessibility and digital signatures, each with a pass, warn or fail summary and its details.
Sourcepub async fn compress_pdf(
&self,
input: impl Into<FileInput>,
params: Option<CompressPdfParams>,
) -> Result<ToolResult>
pub async fn compress_pdf( &self, input: impl Into<FileInput>, params: Option<CompressPdfParams>, ) -> Result<ToolResult>
Compress: Make PDFs and images smaller without changing how they look.
Accepts .avif, .bmp, .gif, .jpeg, .jpg, .pdf, .png, .tif, .tiff, .webp. Returns The PDF, compressed (application/pdf); an image comes back in its own format (JPEG, PNG, WebP, GIF, TIFF, BMP or AVIF) at the same pixel size, never larger than the input.
Sourcepub async fn crop_pdf(
&self,
input: impl Into<FileInput>,
params: Option<CropPdfParams>,
) -> Result<ToolResult>
pub async fn crop_pdf( &self, input: impl Into<FileInput>, params: Option<CropPdfParams>, ) -> Result<ToolResult>
Crop PDF: Trim the margins of every page or the pages you pick.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn flatten_pdf(
&self,
input: impl Into<FileInput>,
params: Option<FlattenPdfParams>,
) -> Result<ToolResult>
pub async fn flatten_pdf( &self, input: impl Into<FileInput>, params: Option<FlattenPdfParams>, ) -> Result<ToolResult>
Flatten PDF: Merge form fields into static pages.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn merge_pdf(
&self,
input: impl IntoIterator<Item = impl Into<FileInput>>,
params: Option<MergePdfParams>,
) -> Result<ToolResult>
pub async fn merge_pdf( &self, input: impl IntoIterator<Item = impl Into<FileInput>>, params: Option<MergePdfParams>, ) -> Result<ToolResult>
Merge PDF: Combine multiple PDFs into one file.
Accepts .pdf (2 to 30 files, in order). Returns PDF document (application/pdf).
Sourcepub async fn n_up_pdf(
&self,
input: impl Into<FileInput>,
params: Option<NUpPdfParams>,
) -> Result<ToolResult>
pub async fn n_up_pdf( &self, input: impl Into<FileInput>, params: Option<NUpPdfParams>, ) -> Result<ToolResult>
N-up PDF: Put several pages on each sheet.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn ocr_pdf(
&self,
input: impl Into<FileInput>,
params: Option<OcrPdfParams>,
) -> Result<ToolResult>
pub async fn ocr_pdf( &self, input: impl Into<FileInput>, params: Option<OcrPdfParams>, ) -> Result<ToolResult>
OCR PDF: Recognise the text of a scanned PDF or an image (PNG, JPEG, TIFF or WebP).
Accepts .avif, .bmp, .csv, .docx, .eml, .gif, .jpeg, .jpg, .msg, .pdf, .png, .pptx, .tif, .tiff, .tsv, .webp, .xlsx, .zip. Returns Searchable PDF (application/pdf), or the recognised text as plain text, Markdown, JSON, DOCX, HTML, XLSX, CSV, hOCR, ALTO XML, block JSON or annotation JSON, as chosen by outputMode; further formats (outputs) are listed in the result metadata.
Sourcepub async fn organize_pdf(
&self,
input: impl Into<FileInput>,
params: OrganizePdfParams,
) -> Result<ToolResult>
pub async fn organize_pdf( &self, input: impl Into<FileInput>, params: OrganizePdfParams, ) -> Result<ToolResult>
Organize PDF: Reorder pages and remove the ones you leave out.
Accepts .pdf. Returns PDF document (application/pdf).
Required: order.
Sourcepub async fn pdf_table_extraction(
&self,
input: impl Into<FileInput>,
params: Option<PdfTableExtractionParams>,
) -> Result<ToolResult>
pub async fn pdf_table_extraction( &self, input: impl Into<FileInput>, params: Option<PdfTableExtractionParams>, ) -> Result<ToolResult>
PDF Table Extraction: Extract table-like content from PDF text.
Accepts .pdf. Returns ZIP of CSV files, one per detected table (application/zip).
Sourcepub async fn protect_pdf(
&self,
input: impl Into<FileInput>,
params: ProtectPdfParams,
) -> Result<ToolResult>
pub async fn protect_pdf( &self, input: impl Into<FileInput>, params: ProtectPdfParams, ) -> Result<ToolResult>
Protect PDF: Lock a file with a password.
Accepts .pdf. Returns PDF document (application/pdf).
Required: password.
Sourcepub async fn redact_pdf(
&self,
input: impl Into<FileInput>,
params: Option<RedactPdfParams>,
) -> Result<ToolResult>
pub async fn redact_pdf( &self, input: impl Into<FileInput>, params: Option<RedactPdfParams>, ) -> Result<ToolResult>
Redact PDF: Permanently remove text, images and areas you choose.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn repair_pdf(
&self,
input: impl Into<FileInput>,
params: Option<RepairPdfParams>,
) -> Result<ToolResult>
pub async fn repair_pdf( &self, input: impl Into<FileInput>, params: Option<RepairPdfParams>, ) -> Result<ToolResult>
Repair PDF: Fix corrupted or broken PDF files.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn rotate_pdf(
&self,
input: impl Into<FileInput>,
params: Option<RotatePdfParams>,
) -> Result<ToolResult>
pub async fn rotate_pdf( &self, input: impl Into<FileInput>, params: Option<RotatePdfParams>, ) -> Result<ToolResult>
Rotate PDF: Rotate all or specific pages.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn sanitize_pdf(
&self,
input: impl Into<FileInput>,
params: Option<SanitizePdfParams>,
) -> Result<ToolResult>
pub async fn sanitize_pdf( &self, input: impl Into<FileInput>, params: Option<SanitizePdfParams>, ) -> Result<ToolResult>
Sanitize PDF.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn scale_pdf(
&self,
input: impl Into<FileInput>,
params: Option<ScalePdfParams>,
) -> Result<ToolResult>
pub async fn scale_pdf( &self, input: impl Into<FileInput>, params: Option<ScalePdfParams>, ) -> Result<ToolResult>
Scale PDF: Resize pages and their content by a percentage.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn sign_pdf(
&self,
input: impl Into<FileInput>,
params: Option<SignPdfParams>,
) -> Result<ToolResult>
pub async fn sign_pdf( &self, input: impl Into<FileInput>, params: Option<SignPdfParams>, ) -> Result<ToolResult>
Sign PDF: Add a visible signature to a PDF.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn split_pdf(
&self,
input: impl Into<FileInput>,
params: Option<SplitPdfParams>,
) -> Result<ToolResult>
pub async fn split_pdf( &self, input: impl Into<FileInput>, params: Option<SplitPdfParams>, ) -> Result<ToolResult>
Split PDF: Separate pages into individual files.
Accepts .pdf. Returns One PDF (application/pdf), or a ZIP of PDFs when the split produces several parts (application/zip).
Sourcepub async fn unlock_pdf(
&self,
input: impl Into<FileInput>,
params: Option<UnlockPdfParams>,
) -> Result<ToolResult>
pub async fn unlock_pdf( &self, input: impl Into<FileInput>, params: Option<UnlockPdfParams>, ) -> Result<ToolResult>
Unlock PDF: Remove password from a file you own.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn csv_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<CsvToPdfParams>,
) -> Result<ToolResult>
pub async fn csv_to_pdf( &self, input: impl Into<FileInput>, params: Option<CsvToPdfParams>, ) -> Result<ToolResult>
CSV to PDF: Convert CSV tables into a readable PDF.
Accepts .csv, .txt. Returns PDF document (application/pdf).
Sourcepub async fn excel_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<ExcelToPdfParams>,
) -> Result<ToolResult>
pub async fn excel_to_pdf( &self, input: impl Into<FileInput>, params: Option<ExcelToPdfParams>, ) -> Result<ToolResult>
Excel to PDF: Convert spreadsheet files to PDF.
Accepts .ods, .xlsx. Returns PDF document (application/pdf).
Sourcepub async fn image_to_pdf(
&self,
input: impl IntoIterator<Item = impl Into<FileInput>>,
params: Option<ImageToPdfParams>,
) -> Result<ToolResult>
pub async fn image_to_pdf( &self, input: impl IntoIterator<Item = impl Into<FileInput>>, params: Option<ImageToPdfParams>, ) -> Result<ToolResult>
Image to PDF: Combine supported image files into a single PDF.
Accepts .jpeg, .jpg, .png, .webp (1 to 50 files, in order). Returns PDF document (application/pdf).
Sourcepub async fn json_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<JsonToPdfParams>,
) -> Result<ToolResult>
pub async fn json_to_pdf( &self, input: impl Into<FileInput>, params: Option<JsonToPdfParams>, ) -> Result<ToolResult>
JSON to PDF: Render structured JSON into a readable PDF.
Accepts .json, .txt. Returns PDF document (application/pdf).
Sourcepub async fn markdown_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<MarkdownToPdfParams>,
) -> Result<ToolResult>
pub async fn markdown_to_pdf( &self, input: impl Into<FileInput>, params: Option<MarkdownToPdfParams>, ) -> Result<ToolResult>
Markdown to PDF: Convert Markdown content into a PDF document.
Accepts .markdown, .md, .txt. Returns PDF document (application/pdf).
Sourcepub async fn pdf_to_chunks(
&self,
input: impl Into<FileInput>,
params: Option<PdfToChunksParams>,
) -> Result<ToolResult>
pub async fn pdf_to_chunks( &self, input: impl Into<FileInput>, params: Option<PdfToChunksParams>, ) -> Result<ToolResult>
PDF to Chunks: Split the text of a PDF into chunks for search and AI retrieval.
Accepts .pdf. Returns JSON chunks (application/json): text chunks with their page ranges, for retrieval.
Sourcepub async fn pdf_to_epub(
&self,
input: impl Into<FileInput>,
params: Option<PdfToEpubParams>,
) -> Result<ToolResult>
pub async fn pdf_to_epub( &self, input: impl Into<FileInput>, params: Option<PdfToEpubParams>, ) -> Result<ToolResult>
PDF to EPUB: Create a text-based EPUB from PDF content.
Accepts .pdf. Returns EPUB e-book (application/epub+zip).
Sourcepub async fn pdf_to_excel(
&self,
input: impl Into<FileInput>,
params: Option<PdfToExcelParams>,
) -> Result<ToolResult>
pub async fn pdf_to_excel( &self, input: impl Into<FileInput>, params: Option<PdfToExcelParams>, ) -> Result<ToolResult>
PDF to Excel: Export detected PDF tables into XLSX.
Accepts .pdf. Returns XLSX spreadsheet (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet).
Sourcepub async fn pdf_to_html(
&self,
input: impl Into<FileInput>,
params: Option<PdfToHtmlParams>,
) -> Result<ToolResult>
pub async fn pdf_to_html( &self, input: impl Into<FileInput>, params: Option<PdfToHtmlParams>, ) -> Result<ToolResult>
PDF to HTML: Convert the text of a PDF into a clean web page.
Accepts .pdf. Returns HTML document (text/html), one section per page, no scripts.
Sourcepub async fn pdf_to_images(
&self,
input: impl Into<FileInput>,
params: Option<PdfToImagesParams>,
) -> Result<ToolResult>
pub async fn pdf_to_images( &self, input: impl Into<FileInput>, params: Option<PdfToImagesParams>, ) -> Result<ToolResult>
PDF to Images: Export pages or embedded images from a PDF.
Accepts .pdf. Returns ZIP of JPG images, one per page or extracted image (application/zip).
Sourcepub async fn pdf_to_json(
&self,
input: impl Into<FileInput>,
params: Option<PdfToJsonParams>,
) -> Result<ToolResult>
pub async fn pdf_to_json( &self, input: impl Into<FileInput>, params: Option<PdfToJsonParams>, ) -> Result<ToolResult>
PDF to JSON: Export PDF text as structured JSON.
Accepts .pdf. Returns Structured JSON (application/json).
Sourcepub async fn pdf_to_markdown(
&self,
input: impl Into<FileInput>,
params: Option<PdfToMarkdownParams>,
) -> Result<ToolResult>
pub async fn pdf_to_markdown( &self, input: impl Into<FileInput>, params: Option<PdfToMarkdownParams>, ) -> Result<ToolResult>
PDF to Markdown: Convert extracted PDF text into Markdown.
Accepts .pdf. Returns Markdown (text/markdown).
Sourcepub async fn pdf_to_powerpoint(
&self,
input: impl Into<FileInput>,
params: Option<PdfToPowerpointParams>,
) -> Result<ToolResult>
pub async fn pdf_to_powerpoint( &self, input: impl Into<FileInput>, params: Option<PdfToPowerpointParams>, ) -> Result<ToolResult>
PDF to PowerPoint: Turn every page into a slide of a PowerPoint deck.
Accepts .pdf. Returns PowerPoint deck (application/vnd.openxmlformats-officedocument.presentationml.presentation), one slide per page with its text as the picture description.
Sourcepub async fn pdf_to_text(
&self,
input: impl Into<FileInput>,
params: Option<PdfToTextParams>,
) -> Result<ToolResult>
pub async fn pdf_to_text( &self, input: impl Into<FileInput>, params: Option<PdfToTextParams>, ) -> Result<ToolResult>
PDF to Text: Extract selectable or OCR text from a PDF.
Accepts .pdf. Returns Plain text (text/plain).
Sourcepub async fn pdf_to_word(
&self,
input: impl Into<FileInput>,
params: Option<PdfToWordParams>,
) -> Result<ToolResult>
pub async fn pdf_to_word( &self, input: impl Into<FileInput>, params: Option<PdfToWordParams>, ) -> Result<ToolResult>
PDF to Word: Convert extracted PDF text into editable DOCX.
Accepts .pdf. Returns DOCX document (application/vnd.openxmlformats-officedocument.wordprocessingml.document).
Sourcepub async fn pdfa_conversion(
&self,
input: impl Into<FileInput>,
params: Option<PdfaConversionParams>,
) -> Result<ToolResult>
pub async fn pdfa_conversion( &self, input: impl Into<FileInput>, params: Option<PdfaConversionParams>, ) -> Result<ToolResult>
PDF/A Conversion: Convert a PDF to PDF/A for long-term archiving.
Accepts .pdf. Returns PDF document (application/pdf).
Sourcepub async fn powerpoint_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<PowerpointToPdfParams>,
) -> Result<ToolResult>
pub async fn powerpoint_to_pdf( &self, input: impl Into<FileInput>, params: Option<PowerpointToPdfParams>, ) -> Result<ToolResult>
PowerPoint to PDF: Convert presentation files to PDF.
Accepts .odp, .pptx. Returns PDF document (application/pdf).
Sourcepub async fn svg_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<SvgToPdfParams>,
) -> Result<ToolResult>
pub async fn svg_to_pdf( &self, input: impl Into<FileInput>, params: Option<SvgToPdfParams>, ) -> Result<ToolResult>
SVG to PDF: Convert safe SVG artwork into PDF format.
Accepts .svg. Returns PDF document (application/pdf).
Sourcepub async fn text_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<TextToPdfParams>,
) -> Result<ToolResult>
pub async fn text_to_pdf( &self, input: impl Into<FileInput>, params: Option<TextToPdfParams>, ) -> Result<ToolResult>
Text to PDF: Convert plain text into a PDF document.
Accepts .txt. Returns PDF document (application/pdf).
Sourcepub async fn web_capture(
&self,
input: impl Into<FileInput>,
params: Option<WebCaptureParams>,
) -> Result<ToolResult>
pub async fn web_capture( &self, input: impl Into<FileInput>, params: Option<WebCaptureParams>, ) -> Result<ToolResult>
Web page to PDF or image: Capture a web address or pasted HTML as a PDF or a PNG, JPEG or WebP image.
Accepts .htm, .html, .txt, .url. Returns PDF document (application/pdf), or a PNG, JPEG or WebP image, as chosen by output.
Sourcepub async fn word_to_pdf(
&self,
input: impl Into<FileInput>,
params: Option<WordToPdfParams>,
) -> Result<ToolResult>
pub async fn word_to_pdf( &self, input: impl Into<FileInput>, params: Option<WordToPdfParams>, ) -> Result<ToolResult>
Word to PDF: Convert document files to PDF.
Accepts .docx, .odt. Returns PDF document (application/pdf).
Sourcepub async fn convert_from_jpg(
&self,
input: impl Into<FileInput>,
params: Option<ConvertFromJpgParams>,
) -> Result<ToolResult>
pub async fn convert_from_jpg( &self, input: impl Into<FileInput>, params: Option<ConvertFromJpgParams>, ) -> Result<ToolResult>
Convert from JPG: Export JPG files to another image format.
Accepts .jpeg, .jpg. Returns Image in targetFormat: PNG, WebP, AVIF, or TIFF.
Sourcepub async fn convert_to_jpg(
&self,
input: impl Into<FileInput>,
params: Option<ConvertToJpgParams>,
) -> Result<ToolResult>
pub async fn convert_to_jpg( &self, input: impl Into<FileInput>, params: Option<ConvertToJpgParams>, ) -> Result<ToolResult>
Convert to JPG: Convert supported images to JPG.
Accepts .avif, .jpeg, .jpg, .png, .tiff, .webp. Returns JPG image (image/jpeg).
Sourcepub async fn crop_image(
&self,
input: impl Into<FileInput>,
params: CropImageParams,
) -> Result<ToolResult>
pub async fn crop_image( &self, input: impl Into<FileInput>, params: CropImageParams, ) -> Result<ToolResult>
Crop Image: Crop an image to exact dimensions.
Accepts .avif, .jpeg, .jpg, .png, .tiff, .webp. Returns Processed image (same family as input).
Required: x, y, width, height.
Sourcepub async fn image_metadata(
&self,
input: impl Into<FileInput>,
params: Option<ImageMetadataParams>,
) -> Result<ToolResult>
pub async fn image_metadata( &self, input: impl Into<FileInput>, params: Option<ImageMetadataParams>, ) -> Result<ToolResult>
Image Metadata: Read an image’s format, size, colour mode, frames and EXIF facts.
Accepts .gif, .jpeg, .jpg, .png, .webp. Returns JSON metadata report: format, width, height, colour mode, frames and EXIF summary (application/json).
Sourcepub async fn resize_image(
&self,
input: impl Into<FileInput>,
params: Option<ResizeImageParams>,
) -> Result<ToolResult>
pub async fn resize_image( &self, input: impl Into<FileInput>, params: Option<ResizeImageParams>, ) -> Result<ToolResult>
Resize Image: Change image dimensions precisely.
Accepts .avif, .jpeg, .jpg, .png, .tiff, .webp. Returns Processed image (same family as input).
Sourcepub async fn rotate_image(
&self,
input: impl Into<FileInput>,
params: Option<RotateImageParams>,
) -> Result<ToolResult>
pub async fn rotate_image( &self, input: impl Into<FileInput>, params: Option<RotateImageParams>, ) -> Result<ToolResult>
Rotate Image: Correct image orientation.
Accepts .avif, .jpeg, .jpg, .png, .tiff, .webp. Returns Processed image (same family as input).
Sourcepub async fn watermark_image(
&self,
input: impl Into<FileInput>,
params: Option<WatermarkImageParams>,
) -> Result<ToolResult>
pub async fn watermark_image( &self, input: impl Into<FileInput>, params: Option<WatermarkImageParams>, ) -> Result<ToolResult>
Watermark Image: Apply text or logo marks to an image.
Accepts .avif, .jpeg, .jpg, .png, .tiff, .webp. Returns Processed image (same family as input).