How to Remove PDF Restrictions with cURL

Learn how to remove restrictions from PDFs to enable printing, editing content and form fields, copying text, and more with the Restrict PDF API Tool.
Share this page

Why Remove PDF Restrictions with cURL?

The pdfRest Restrict PDF API Tool offers a convenient way to remove restrictions on your PDF documents programmatically. By using this API, you can automate the process of securing your PDFs against unauthorized access or modification. This tutorial will show you how to send an API call to the Restrict PDF /unrestricted-pdf endpoint using cURL, the standard command-line tool for making network requests.

Imagine you have a collection of confidential reports in PDF format that you need to share with a select group of people. You want to prevent anyone else from editing, copying, or printing these documents. When you need to edit them, the /unrestricted-pdf endpoint allows you to remove these restrictions quickly and easily. By using cURL, you can integrate this functionality into your existing workflow, such as a script that processes these reports automatically.

Removing PDF Restrictions with cURL Code Example

curl -X POST "https://api.pdfrest.com/unrestricted-pdf" \
  -H "Accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  -F "file=@/path/to/file" \
  -F "output=example_out" \
  -F "current_permissions_password=password"

Reference to the provided code: pdfRest API samples repository on GitHub.

Breaking Down the Code

This section explains each part of the cURL command used to call the /unrestricted-pdf API endpoint:

curl -X POST "https://api.pdfrest.com/unrestricted-pdf"

This initiates a cURL command to make a POST request to the Restrict PDF endpoint.

-H "Accept: application/json"

This header tells the server that the client expects a response in JSON format.

-H "Content-Type: multipart/form-data"

This header indicates that the request body will be sent as multipart/form-data, which is necessary for uploading files.

-H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

This header includes your personal API key for authentication with the pdfRest API.

-F "file=@/path/to/file"

This form field uploads the PDF file from the specified path to be restricted.

-F "output=example_out"

This form field sets the base name for the output file that will be created after the restrictions are removed.

-F "current_permissions_password=password"

This form field sets the password that will be required to lift the restrictions on the restricted PDF file.

Beyond the Tutorial

In this tutorial, you've learned how to use cURL to make an API call to one of the Restrict PDF endpoints of pdfRest. This allows you to programmatically remove restrictions on your PDF documents, ensuring they are protected against unauthorized use. By integrating this into your workflow, you can automate the process of securing your documents.

To explore more possibilities and to demo all of the pdfRest API Tools, visit the API Lab. For a comprehensive understanding of the API's capabilities, refer to the API Reference Guide.

Note: This is an example of a multipart API call. Code samples using JSON payloads can be found at the pdfRest API samples repository on GitHub.

Generate a self-service API Key now!

Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.

Compare Plans
Contact Us