# Global

##

### Methods

#### constructor(permissions, userPassword, ownerPassword, fileId)

Source:
  - libs/pdfsecurity.js, line 23

Initializes encryption settings

##### Example

    var security = new PDFSecurity(["print"])

##### Parameters:

Name | Type | Description
--- | --- | ---
`permissions` | Array | Permissions allowed for user, "print", "modify", "copy" and "annot-forms".
`userPassword` | String | Permissions apply to this user. Leaving this empty means the document is not password protected but viewer has the above permissions.
`ownerPassword` | String | Owner has full functionalities to the file.
`fileId` | String | As hex string, should be same as the file ID in the trailer.

#### encryptor(objectId, generation) → {function}

Source:
  - libs/pdfsecurity.js, line 132

Returns an encryptor function which can take in a byte string and returns the encrypted version

##### Example

    out("stream");
    encryptor = security.encryptor(object.id, 0);
    out(encryptor(data));
    out("endstream");

##### Parameters:

Name | Type | Description
--- | --- | ---
`objectId` | number |
`generation` | number | Not sure what this is for, you can set it to 0

##### Returns:

Type
  function

#### hexToBytes(hex) → {String}

Source:
  - libs/pdfsecurity.js, line 101

Converts a hex string to a byte string

##### Parameters:

Name | Type | Description
--- | --- | ---
`hex` | String | Hex string

##### Returns:

Type
  String

#### lsbFirstWord(data) → {Array}

Source:
  - libs/pdfsecurity.js, line 67

Breaks down a 4-byte number into its individual bytes, with the least significant bit first

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | number | 32-bit number

##### Returns:

Type
  Array

#### mapArrayBufferViews()

Source:
  - libs/Blob.js, line 54

Helper function that maps ArrayBufferViews to ArrayBuffers Used by BlobBuilder constructor and old browsers that didn't support it in the Blob constructor.

#### md5cycle()

Source:
  - libs/md5.js, line 11
License:
  - Joseph Myers does not specify a particular license for his work. Author: Joseph Myers Accessed from: http://www.myersdaily.org/joseph/javascript/md5.js Modified by: Owen Leong

#### processOwnerPassword(paddedUserPassword, paddedOwnerPassword) → {String}

Source:
  - libs/pdfsecurity.js, line 115

Computes the 'O' field in the encryption dictionary

##### Parameters:

Name | Type | Description
--- | --- | ---
`paddedUserPassword` | String | Byte string of padded user password
`paddedOwnerPassword` | String | Byte string of padded owner password

##### Returns:

Type
  String

#### rc4(key, data) → {string}

Source:
  - libs/rc4.js, line 14

Converts a byte string to a hex string

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | Byte string of encryption key
`data` | string | Byte string of data to be encrypted

##### Returns:

Encrypted string

Type
  string

#### repeat()

Source:
  - libs/rc4.js, line 10
License:
  - FPDF is released under a permissive license: there is no usage restriction. You may embed it freely in your application (commercial or not), with or without modifications. Reference: http://www.fpdf.org/en/script/script37.php

#### RGBColor()

Source:
  - libs/rgbcolor.js, line 8
Author:
  - Stoyan Stefanov <sstoo@gmail.com> http://www.phpied.com/rgb-color-parser-in-javascript/
License:
  - Use it if you like it

A class to parse color values

#### Sets options for Bidi conversion(:)

Source:
  - libs/bidiEngine.js, line 2626

##### Parameters:

Name | Type | Description
--- | --- | ---
`:` | Object | isInputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) isInputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong character of input string) isOutputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) isOutputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong characterof input string) isSymmetricSwapping {boolean} (defaults to false): allowed values true(needs symmetric swapping), false (no need in symmetric swapping),

#### toHexString(byteString) → {String}

Source:
  - libs/pdfsecurity.js, line 84

Converts a byte string to a hex string

##### Parameters:

Name | Type | Description
--- | --- | ---
`byteString` | String | Byte string

##### Returns:

Type
  String

#### toPDFName(str)

Source:
  - libs/pdfname.js, line 6

Convert string to `PDF Name Object`. Detail: PDF Reference 1.3 - Chapter 3.2.4 Name Object

##### Parameters:

Name | Type | Description
--- | --- | ---
`str` |  |

### Type Definitions

#### ApiSwitchBody(pdf)

Source:
  - jspdf.js, line 394

##### Parameters:

Name | Type | Description
--- | --- | ---
`pdf` | jsPDF |

#### PatternData

Source:
  - jspdf.js, line 4461

{Matrix|undefined} matrix {Number|undefined} xStep {Number|undefined} yStep {Array.|undefined} boundingBox

##### Type:

- Object