PageCount

Return page count in PDF-document.

func (document *Document) PageCount() (int32, error)

Parameters:

Return:

  • error - contains an error or nil if absent
  • int32 - page count of the PDF-document

Example:

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)

	}
	// PageCount() returns page count in PDF-document
	count, err := pdf.PageCount()
	if err != nil {
		log.Fatal(err)
	}
	// Print
	fmt.Println("Count:", count)
	// Close() releases allocated resources for PDF-document
	defer pdf.Close()
}