package encryption

import "github.com/edragoev1/pdfjet/v9/src/encryption"

Index

Types

type Passwords

type Passwords struct {
	// contains filtered or unexported fields
}

Passwords holds the user and owner passwords of an encrypted PDF. A password is used as typed, in UTF-8, and at most 127 bytes of it are used. A password that is not set is empty, so the PDF opens without a prompt when the user password is not set. Chrome does not cut a longer password to its first 127 bytes, as other viewers do, and opens the PDF only when just those are typed, so a password of 127 bytes or fewer is the one to give.

func NewPasswords
func NewPasswords() *Passwords

NewPasswords creates a new instance of Passwords.

func (*Passwords) GetOwnerPassword
func (p *Passwords) GetOwnerPassword() string

GetOwnerPassword returns the owner password.

func (*Passwords) GetUserPassword
func (p *Passwords) GetUserPassword() string

GetUserPassword returns the user password.

func (*Passwords) SetOwnerPassword
func (p *Passwords) SetOwnerPassword(ownerPassword string) *Passwords

SetOwnerPassword sets the owner password.

func (*Passwords) SetUserPassword
func (p *Passwords) SetUserPassword(userPassword string) *Passwords

SetUserPassword sets the user password.

type Permissions

type Permissions struct {
	// contains filtered or unexported fields
}

Permissions encapsulates the user access permissions for a PDF document as specified in ISO 32000-2, Table 22. Provides a type-safe interface to manipulate and query the permissions flags.

func NewPermissions
func NewPermissions() *Permissions

NewPermissions creates a new instance of Permissions with no permissions granted.

func NewPermissionsFromInt
func NewPermissionsFromInt(rawFlags int) *Permissions

NewPermissionsFromInt creates permissions from the /P value of an encryption dictionary, keeping only its permission bits.

func (*Permissions) CanAssembleDocument
func (p *Permissions) CanAssembleDocument() bool

CanAssembleDocument returns true if the user can assemble the document (manipulate pages).

func (*Permissions) CanCopyContents
func (p *Permissions) CanCopyContents() bool

CanCopyContents returns true if the user can copy or extract content.

func (*Permissions) CanExtractForAccessibility
func (p *Permissions) CanExtractForAccessibility() bool

CanExtractForAccessibility returns true if the user can extract content for accessibility.

func (*Permissions) CanFillFormFields
func (p *Permissions) CanFillFormFields() bool

CanFillFormFields returns true if the user can fill interactive form fields.

func (*Permissions) CanModifyAnnotations
func (p *Permissions) CanModifyAnnotations() bool

CanModifyAnnotations returns true if the user can add or modify annotations and form fields. This is primarily for legacy PDF support.

func (*Permissions) CanModifyContents
func (p *Permissions) CanModifyContents() bool

CanModifyContents returns true if the user can modify the document's contents.

func (*Permissions) CanPrint
func (p *Permissions) CanPrint() bool

CanPrint returns true if the user can print the document (possibly at low quality, unless CanPrintHighQuality() is true).

func (*Permissions) CanPrintHighQuality
func (p *Permissions) CanPrintHighQuality() bool

CanPrintHighQuality returns true if the user can print the document at high quality.

func (*Permissions) GetAccess
func (p *Permissions) GetAccess() UserAccess

GetAccess returns the permissions as UserAccess flags

func (*Permissions) Grant
func (p *Permissions) Grant(permissions UserAccess) *Permissions

Grant grants the specified permissions. The other permissions stay as they are.

func (*Permissions) Revoke
func (p *Permissions) Revoke(permissions UserAccess) *Permissions

Revoke revokes the specified permissions. The other permissions stay as they are.

func (*Permissions) SetAccess
func (p *Permissions) SetAccess(access UserAccess) *Permissions

SetAccess sets the permissions using UserAccess flags

func (*Permissions) String
func (p *Permissions) String() string

String returns a string that represents the current permissions for debugging purposes.

type UserAccess

type UserAccess uint32

UserAccess represents the user access permissions for an encrypted PDF document as defined in ISO 32000-2 (PDF 2.0) Table 22. Permissions are stored as flags in a 32-bit integer, whose bit positions are numbered from 1, the low-order bit.

const (
	// None No permissions (default)
	None UserAccess = 0

	// Print Bit position: 3
	Print UserAccess = 1 << 2 // 4

	// ModifyContents Bit position: 4
	ModifyContents UserAccess = 1 << 3 // 8

	// CopyContents Bit position: 5
	CopyContents UserAccess = 1 << 4 // 16

	// ModifyAnnotations Bit position: 6
	ModifyAnnotations UserAccess = 1 << 5 // 32

	// FillFormFields Bit position: 9
	FillFormFields UserAccess = 1 << 8 // 256

	// ExtractContentsForAccessibility Bit position: 10
	ExtractContentsForAccessibility UserAccess = 1 << 9 // 512

	// AssembleDocument Bit position: 11
	AssembleDocument UserAccess = 1 << 10 // 1024

	// PrintHighQuality Bit position: 12
	PrintHighQuality UserAccess = 1 << 11 // 2048
)
func (UserAccess) IsSetIn
func (ua UserAccess) IsSetIn(flags UserAccess) bool

IsSetIn reports whether this permission is set in the flags.

func (UserAccess) String
func (ua UserAccess) String() string

String returns a string representation of the UserAccess flags