Created
January 20, 2023 12:21
-
-
Save abhilashsajeev/094cb7797ba9d25b0ededc79384d8662 to your computer and use it in GitHub Desktop.
pdf_compresson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
pdfcpu "github.com/pdfcpu/pdfcpu" | |
api "github.com/pdfcpu/pdfcpu/pkg/api" | |
) | |
func main() { | |
inputPath := "input.pdf" | |
outputPath := "output.pdf" | |
// Encrypt the PDF | |
opt := pdfcpu.EncryptOptions{ | |
Owners: pdfcpu.NewUserAccess(pdfcpu.PermPrint | pdfcpu.PermModify), | |
Users: pdfcpu.NewUserAccess(pdfcpu.PermPrint), | |
} | |
pages := []int{1, 3} | |
err := api.EncryptFilePages(inputPath, outputPath, pages, &opt) | |
if err != nil { | |
fmt.Printf("Error encrypting PDF: %v\n", err) | |
} else { | |
fmt.Println("PDF encrypted successfully!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment