The pdfRest Encrypt PDF API Tool is a powerful resource for developers looking to secure their PDF documents. By using this API, you can add and change PDF passwords to restrict access, ensuring that only individuals with the correct password can view or modify the document. This tutorial will guide you through the process of sending an API call to Encrypt PDF using cURL, a command-line tool used for making network requests.
You might need to encrypt PDF documents to protect sensitive information such as financial reports, legal contracts, or personal data. Whether you’re sending a confidential document to a colleague or storing it in an insecure location, encryption helps prevent unauthorized access. By modifying a current password to a new passord, you can ensure only users with the new password will be able to open the file. For instance, a healthcare provider might change a PDF password on patient records before sharing them with a new insurance company.
curl -X POST "https://api.pdfrest.com/encrypted-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_open_password=password" \ -F "new_open_password=newpassword"
Reference to the provided code can be found at GitHub.
This cURL command is used to make a POST request to the Encrypt PDF endpoint. Let’s break down the components of the command:
-X POST "https://api.pdfrest.com/encrypted-pdf"
This specifies that you are making a POST request to the Encrypt PDF endpoint.
-H "Accept: application/json"
This header indicates that the server’s response should be in JSON format.
-H "Content-Type: multipart/form-data"
This header tells the server that the request body contains form data.
-H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Replace the placeholder with your actual API key to authenticate the request.
-F "file=@/path/to/file"
The '-F' flag is used to specify each field to be sent. This field contains the file path to the PDF you want to encrypt.
-F "output=example_out"
This field sets the name of the output file that will be created.
-F "current_open_password=password"
This field is the current password of the PDF if it is already protected.
-F "new_open_password=newpassword"
This field is the new password you want to set for the PDF file.
By following the steps above, you've learned how to change a PDF password using the pdfRest API and cURL. This provides an additional layer of security to your PDF files by requiring a new password to open them. You've also seen how to structure an API call with cURL and pass various parameters to customize the request.
You are now ready to explore and demo all of the pdfRest API Tools in the API Lab. For further information and a comprehensive guide to using the pdfRest API, refer to the API Reference Guide.
Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.