PDF kit command

file.protect

Protect with passwords

Encrypt the document (applied by the next doc_save, a full rewrite). openPassword is needed to open it. permissionsPassword is needed to change security and lifts the restrictions given by printing/changes/copy/accessibility; those restrictions (and their defaults) apply only when permissionsPassword is given. With openPassword alone the document is encrypted and everything stays allowed, so passing a restriction without permissionsPassword is an error. Passwords are never echoed back. Undoable.

Kit
PDF 0.1.0 (.pdf)
Changes the document
yes

Parameters

Parameters of file.protect
NameTypeRequiredDescription
accessibilitybooleannoAllow screen readers to read the text (needs permissionsPassword; default true).
changes"none" | "pages" | "fill-sign" | "comment-fill-sign" | "any-except-extract"noNeeds permissionsPassword. Default none.
compatibility"aes-256" | "aes-128" | "rc4-128" | "rc4-40"noDefault aes-256 (Acrobat X and later).
copybooleannoAllow copying text and images (needs permissionsPassword; default false).
encryptMetadatabooleannoDefault true.
openPasswordstringnoRequired to open the document. On its own it restricts nothing. (minLength 1)
permissionsPasswordstringnoRequired to change security; enables printing/changes/copy/accessibility and their defaults. (minLength 1)
printing"none" | "low" | "high"noNeeds permissionsPassword. Default high.

Call through pdf_run

text
pdf_run {
  "path": "<file>.pdf",
  "steps": [{ "command": "file.protect" }]
}

The required parameters, with placeholders for their types: not a tested example. Optional: accessibility, changes, compatibility, copy, encryptMetadata, openPassword, permissionsPassword, printing. pdf_run answers the step’s result in completed[i].result.

Result

The kit gives no result schema for this command.

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "accessibility": {
      "description": "Allow screen readers to read the text (needs permissionsPassword; default true).",
      "type": "boolean"
    },
    "changes": {
      "description": "Needs permissionsPassword. Default none.",
      "enum": [
        "none",
        "pages",
        "fill-sign",
        "comment-fill-sign",
        "any-except-extract"
      ],
      "type": "string"
    },
    "compatibility": {
      "description": "Default aes-256 (Acrobat X and later).",
      "enum": [
        "aes-256",
        "aes-128",
        "rc4-128",
        "rc4-40"
      ],
      "type": "string"
    },
    "copy": {
      "description": "Allow copying text and images (needs permissionsPassword; default false).",
      "type": "boolean"
    },
    "encryptMetadata": {
      "description": "Default true.",
      "type": "boolean"
    },
    "openPassword": {
      "description": "Required to open the document. On its own it restricts nothing. (minLength 1)",
      "type": "string"
    },
    "permissionsPassword": {
      "description": "Required to change security; enables printing/changes/copy/accessibility and their defaults. (minLength 1)",
      "type": "string"
    },
    "printing": {
      "description": "Needs permissionsPassword. Default high.",
      "enum": [
        "none",
        "low",
        "high"
      ],
      "type": "string"
    }
  },
  "type": "object"
}

Generated from the command list of @kition/[email protected] and the kit itself (pdf_commands through @kition/[email protected], built from KitionAI/kition-pdf@b0d2725). As data: commands.jsonl.