Security

Password protect and encrypt PDF

Add password protection and set permissions on a PDF document.

Password Types

  • User Password (document open password): Required to open and view the PDF
  • Owner Password (permissions password): Required to change restrictions

Recipients don't need the owner password to open the document, only to modify permissions.

Encryption Algorithms

AlgorithmSecurity LevelCompatibility
Standard40BitLowAcrobat 3+
Standard128BitMediumAcrobat 5+
Aes128BitHighAcrobat 7+
Aes256BitHighestAcrobat 9+ (recommended)

Permissions

Control what users can do with the document:

PermissionDescription
print_documentAllow printing
print_faithful_copyAllow high-quality printing
copy_contentsAllow copy/paste of text and graphics
modify_contentsAllow editing document content
modify_annotationsAllow adding comments and form fields
fill_form_fieldsAllow filling forms and signing
extract_contentsAllow text/graphic extraction
assemble_documentAllow page manipulation (insert, delete, rotate)

Example

import httpx

response = httpx.post(
    "https://api.filegraph.ai/security/pdf/lock",
    headers={"X-API-Key": "your-api-key"},
    files={"file": open("document.pdf", "rb")},
    data={
        "user_password": "openme123",
        "owner_password": "admin456",
        "encryption_algorithm": "Aes256Bit",
        "print_document": "true",
        "copy_contents": "false"
    }
)
post/security/pdf/lock

Request

  • Base URL: https://api.filegraph.ai (the document declares no server; this is the origin it was published from)
  • URL: https://api.filegraph.ai/security/pdf/lock
  • Auth: API key in header X-API-Key

Response

Successful Response

filenamestring required

Output filename

content_typestring required

MIME type of the file

size_bytesinteger required

File size in bytes

content_base64string required

Base64-encoded file content

encryption_algorithmstring required

Encryption algorithm used

has_user_passwordboolean required

Whether a user (open) password was set

has_owner_passwordboolean required

Whether an owner (permissions) password was set

permissionsstring[] required

List of permissions enabled on the document

Example response

{
  "content_base64": "JVBERi0xLjQK...",
  "content_type": "application/pdf",
  "encryption_algorithm": "Aes256Bit",
  "filename": "protected.pdf",
  "has_owner_password": true,
  "has_user_password": true,
  "permissions": [
    "print",
    "copy"
  ],
  "size_bytes": 102400
}

Changes

No recorded changes to this operation across all 1 revision of this API.