Convert PDF to Word documents in Rust

To edit the content of a PDF file in Microsoft Word or other word processors that support DOC and DOCX formats. PDF files are editable, but DOC and DOCX files are more flexible and customizable.

Convert PDF to DOC

The provided Rust code snippet demonstrates how to convert a PDF document into a DOC using the Aspose.PDF library:

  1. Open a PDF document.
  2. Convert a PDF file to DOC using save_doc function.

  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 Doc-document
      pdf.save_doc("sample.doc")?;

      Ok(())
  }

Convert PDF to DOCX

Aspose.PDF for Rust API lets you read and convert PDF documents to DOCX. DOCX is a well-known format for Microsoft Word documents whose structure was changed from plain binary to a combination of XML and binary files. Docx files can be opened with Word 2007 and lateral versions but not with the earlier versions of MS Word which support DOC file extensions.

The provided Rust code snippet demonstrates how to convert a PDF document into a DOCX using the Aspose.PDF library:

  1. Open a PDF document.
  2. Convert a PDF file to DOCX using save_docx function.

  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(())
  }