Extract text from PDF in Go

How to Extract text from PDF using Go via C++

How to extract text from PDF using Aspose.PDF for Go via C++

Do you need to parse PDF? The Aspose.PDF for Go via C++ helps extract text from PDF documents. To perform the extraction, we’ll use Aspose.PDF for Go via C++, which is an easy and secure toolkit used to work with PDF. To install and use Aspose.PDF for Go via C++, click on Download Aspose.PDF for Go.

Extract text from PDF in Go


You need Aspose.PDF for Go via C++ to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Create TextAbsorber object to extract text.
  3. Accept the absorber for all the pages.
  4. Get the extracted text
  5. Create a writer and open the file, write a line of text to the file

Extract text from PDF with Go

This sample code shows how to extract text from PDF documents

Input file:

File not added

Output format:

PDF

Output file:


    package main

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

    func main() {
        // Open(filename string) opens a PDF-document with filename
        pdf, err := asposepdf.Open("sample.pdf")
        if err != nil {
            log.Fatal(err)

        }
        // ExtractText() returns PDF-document contents as plain text
        txt, err := pdf.ExtractText()
        if err != nil {
            log.Fatal(err)
        }
        // Print
        fmt.Println("Extracted text:\n", txt)
        // Close() releases allocated resources for PDF-document
        defer pdf.Close()
    }

About Aspose.PDF for Go via C++ API

Our .NET Library can combine a document from any supported download format to any supported save format. Aspose.PDF for .NET library provides fairly universal solutions that will help you solve the tasks of merging documents. Aspose.PDF supports the most significant number of popular document formats, both for loading and saving. Draw your attention to the fact that the current section describes only popular merges. The current page provides information about merging TEXT to {{FILERESULT}}. However, there are many combinations for merging your files. For a complete list of supported formats, see the section Supported File Formats.