Class: RGhost::PdfSecurity

Inherits:
Object
  • Object
show all
Defined in:
lib/rghost/pdf_security.rb

Constant Summary collapse

PERMISSION_VALUES =
{
  :base => -4,
  :print => -4,
  :modify => -8,
  :copy => -16,
  :annotate => -32,
  :interactive => -256,
  :copy_access =>  -512,
  :assemble => -1024,
  :high_quality_print => -2048,
  :all => -3904
  
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePdfSecurity

Returns a new instance of PdfSecurity.



17
18
19
20
21
22
# File 'lib/rghost/pdf_security.rb', line 17

def initialize
  @permission_value=PERMISSION_VALUES[:all]
  @key_lenght=128
  @owner_password="unknow"
  @user_password="unknow"
end

Instance Attribute Details

#key_lengthObject

Returns the value of attribute key_length.



16
17
18
# File 'lib/rghost/pdf_security.rb', line 16

def key_length
  @key_length
end

#owner_passwordObject

Returns the value of attribute owner_password.



16
17
18
# File 'lib/rghost/pdf_security.rb', line 16

def owner_password
  @owner_password
end

#user_passwordObject

Returns the value of attribute user_password.



16
17
18
# File 'lib/rghost/pdf_security.rb', line 16

def user_password
  @user_password
end

Instance Method Details

#disable(*permissions) ⇒ Object



23
24
25
# File 'lib/rghost/pdf_security.rb', line 23

def disable(*permissions)
  @permission_value=permissions.map{|p| PERMISSION_VALUES[p] }.inject(0){|n,i| i+=n}
end

#gs_paramsObject



26
27
28
# File 'lib/rghost/pdf_security.rb', line 26

def gs_params
  "-sOwnerPassword##{clear_space(@owner_password)} -sUserPassword##{clear_space(@user_password)} -dEncryptionR#3 -dKeyLength##{@key_lenght} -dPermissions##{@permission_value}"
end