PDF Document Conversion for Go

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 Go? Aspose.PDF for Go via C++ is the perfect solution for converting PDF documents. This article will demonstrate how to convert PDF to text using Go. When converting a PDF file to another format, users often want to be able to edit the PDF content. With Aspose.PDF for Go 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 Go


    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)
      }
      // SaveDocX(filename string) saves previously opened PDF-document as DocX-document with filename
      err = pdf.SaveDocX("sample.docx")
      if err != nil {
        log.Fatal(err)
      }
      // Close() releases allocated resources for PDF-document
      defer pdf.Close()
    }

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

PDF to XSLX Conversion

PDF to XSLX Conversion


  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)
    }
    // SaveXlsX(filename string) saves previously opened PDF-document as XlsX-document with filename
    err = pdf.SaveXlsX("sample.xlsx")
    if err != nil {
      log.Fatal(err)
    }
    // Close() releases allocated resources for PDF-document
    defer pdf.Close()
  }

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

PDF to XPS Conversion

Example: PDF to XPS Conversion in Go


    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)
      }
      // SaveXps(filename string) saves previously opened PDF-document as Xps-document with filename
      err = pdf.SaveXps("sample.xps")
      if err != nil {
        log.Fatal(err)
      }
      // Close() releases allocated resources for PDF-document
      defer pdf.Close()
    }

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

PDF to PNG Conversion

Example: PDF to PNG conversion in Go


    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)
      }
      // PageToPng(num int32, resolution_dpi int32, filename string) saves the specified page as Png-image file
      err = pdf.PageToPng(1, 100, "sample_page1.png")
      if err != nil {
        log.Fatal(err)
      }
      // Close() releases allocated resources for PDF-document
      defer pdf.Close()
    }

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