Delete PDF Pages with Go via C++
Contents
[
Hide
]
You can delete pages from a PDF file using Aspose.PDF for Go via C++. The next code snippet demonstrates how to manipulate a PDF document by deleting a specific page. This method is efficient for PDF document manipulation tasks, specifically for removing pages, saving the modified document, and ensuring proper resource management.
- Opening a PDF File.
- Deleting a Specific Page with PageDelete function.
- Saving the Document using Save method.
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)
}
// PageDelete(num int32) deletes specified page in PDF-document
err = pdf.PageDelete(1)
if err != nil {
log.Fatal(err)
}
// Save() saves previously opened PDF-document
err = pdf.Save()
if err != nil {
log.Fatal(err)
}
// Close() releases allocated resources for PDF-document
defer pdf.Close()
}