PDF Document Conversion for Rust

Export PDF to Microsoft Office® Word, Excel, PowerPoint Presentations, Images, EPUB and fixed-layout formats

Overview

Are you searching for a method to transform PDF files into other formats using Rust? Aspose.PDF for Rust via C++ is the perfect solution for converting PDF documents. This article will demonstrate how to convert PDF to text using Rust. When converting a PDF file to another format, users often want to be able to edit the PDF content. With Aspose.PDF for Rust via C++, you can easily and quickly convert your PDF documents to and from the most popular formats. Our library ensures that your PDF files are converted accurately and successfully.

PDF to DOC Conversion

Example: PDF to DOC Conversion in Rust

use asposepdf::Document;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open a PDF-document with filename
    let pdf = Document::open("sample.pdf")?;

    // Convert and save the previously opened PDF-document as DocX-document
    pdf.save_docx("sample.docx")?;

    Ok(())
}

Aspose.PDF for Rust supports PDF to DOC conversion. First, we open a PDF document. Then, we call the save_docx function. Next, close the PDF document and release any allocated resources

PDF to XSLX Conversion

PDF to XSLX Conversion

use asposepdf::Document;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open a PDF-document with filename
    let pdf = Document::open("sample.pdf")?;

    // Convert and save the previously opened PDF-document as XlsX-document
    pdf.save_xlsx("sample.xlsx")?;

    Ok(())
}

This code is a Rust function that converts a PDF file to an Excel file using the Aspose.PDF. First, we open a PDF document. Then, we call the save_xlsx function. Next, close the PDF document and release any allocated resources

PDF to XPS Conversion

Example: PDF to XPS Conversion in Rust

use asposepdf::Document;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open a PDF-document with filename
    let pdf = Document::open("sample.pdf")?;

    // Convert and save the previously opened PDF-document as Xps-document
    pdf.save_xps("sample.xps")?;

    Ok(())
}

This Rust function converts a PDF file to an XPS file using the Aspose.PDF. First, we open a PDF document. Then, we call the save_xps function. Next, close the PDF document and release any allocated resources

PDF to PNG Conversion

Example: PDF to PNG conversion in Rust

use asposepdf::Document;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open a PDF-document with filename
    let pdf = Document::open("sample.pdf")?;

    // Convert and save the specified page as Png-image
    pdf.page_to_png(1, 100, "sample_page1.png")?;

    Ok(())
}

This code is a Rust function that converts a PDF file to PNG images using the Aspose.PDF. First, we open a PDF document. Then, we call the page_to_png function. Next, close the PDF document and release any allocated resources.