Convert PDF to Word documents in Go

Convert PDF files to Word formats when you need to move static document content into editable word-processing workflows. DOC and DOCX outputs are useful for review, reuse, and further content updates in Microsoft Word and other compatible editors.

Convert PDF to DOC

Use DOC conversion when you need a broadly compatible Word-processing format for editing, review, or export into older document workflows.

The following example shows how to convert a PDF document to DOC with Aspose.PDF for Go via C++.

  1. Use the Open method to load the source PDF file and return a Document instance for processing.
  2. Call the SaveDoc method to convert the opened PDF document and save the result as a DOC file.
  3. Use the Close method after conversion to release the resources associated with the opened PDF document.

    package main

    import "github.com/aspose-pdf/aspose-pdf-go-cpp"
    import "log"

    func main() {
      // Open(filename string) opens a PDF-document with filename
      pdf, err := asposepdf.Open("sample.pdf")
      if err != nil {
        log.Fatal(err)
      }
      // Close() releases allocated resources for PDF-document
      defer pdf.Close()
      // SaveDoc(filename string) saves previously opened PDF-document as Doc-document with filename
      err = pdf.SaveDoc("sample.doc")
      if err != nil {
        log.Fatal(err)
      }
    }

Convert PDF to DOCX

Aspose.PDF for Go API also lets you convert PDF documents to DOCX. DOCX is the modern Microsoft Word format based on XML packaging and is the preferred option when you need better compatibility with current editing, collaboration, and document-processing tools.

The following example shows how to convert a PDF document to DOCX with Aspose.PDF for Go via C++.

  1. Use the Open method to load the input PDF document from disk.
  2. Call the SaveDocX method to convert the opened PDF document and save the result as a DOCX file.
  3. Use the Close method when processing is complete to release the PDF resources.

    package main

    import "github.com/aspose-pdf/aspose-pdf-go-cpp"
    import "log"

    func main() {
      // Open(filename string) opens a PDF-document with filename
      pdf, err := asposepdf.Open("sample.pdf")
      if err != nil {
        log.Fatal(err)
      }
      // Close() releases allocated resources for PDF-document
      defer pdf.Close()
      // SaveDocX(filename string) saves previously opened PDF-document as DocX-document with filename
      err = pdf.SaveDocX("sample.docx")
      if err != nil {
        log.Fatal(err)
      }
    }