PDF Generator API icon

PDF Generator API

Generate PDFs, manage templates, convert HTML/URLs to PDF, and perform PDF operations like watermarking, encryption, and optimization

Overview

The "Encrypt Document" operation of the PDF Service resource allows users to apply password protection to existing PDF documents. This node takes a PDF input (either from a public URL or base64 encoded content) and encrypts it by setting an owner password (for full access) and/or a user password (for viewing). This is useful for securing sensitive PDF files before sharing or storing them, ensuring that only authorized users can open or modify the document.

Practical examples:

  • Encrypting a contract PDF with a user password so recipients can view but not edit.
  • Adding an owner password to restrict printing or copying of a confidential report.
  • Automating PDF encryption in workflows where documents are generated and then secured before distribution.

Properties

Name Meaning
PDF Source Source of the PDF document to process: either "From URL" (public URL) or "From Base64" (base64 encoded content).
PDF URL Public URL to the PDF document (required if PDF Source is "From URL").
PDF Base64 Base64 encoded PDF content (required if PDF Source is "From Base64").
Output Format Output format of the encrypted PDF:
- Base64 (JSON): returns JSON response with base64 string
- File (Binary): returns binary file data for download/attachment
- URL (JSON): returns JSON response with download URL
Owner Password Owner password granting full access to the PDF (optional but recommended).
User Password User password required for viewing the PDF (optional but recommended).

Output

The output depends on the selected "Output Format":

  • Base64 (JSON): The node outputs a JSON object containing a base64 encoded string of the encrypted PDF.
  • File (Binary): The node outputs the encrypted PDF as binary data suitable for download or attachment in subsequent workflow steps.
  • URL (JSON): The node outputs a JSON object containing a URL where the encrypted PDF can be downloaded.

In all cases, the output JSON includes metadata such as success status, operation name ("encrypt"), filename, format, and file size (if applicable).

Dependencies

  • Requires an API key credential for the external PDF Generator API service.
  • The node makes authenticated HTTP POST requests to the /pdfservices/encrypt endpoint of the API.
  • The API base URL defaults to https://us1.pdfgeneratorapi.com/api/v4 unless overridden in credentials.

Troubleshooting

  • Missing or invalid PDF input: Ensure the PDF source is correctly specified and the URL or base64 content is valid.
  • Empty passwords: While owner and user passwords are optional, providing at least one is recommended to enforce encryption.
  • Invalid output format: Choose one of the supported output formats; otherwise, the node may throw an error.
  • API authentication errors: Verify that the API key credential is correctly configured and has necessary permissions.
  • Network or API errors: Check network connectivity and API service status if requests fail.

Common error messages:

  • "Watermark text is required when Text watermark type is selected" (not relevant here but similar pattern applies for missing required fields).
  • "The operation "encrypt" is not supported for resource "pdfServices" if the operation or resource parameters are incorrect.
  • JSON parsing errors if input data is malformed.

Links and References

Discussion