More PDF editing with the Online-Convert.com API!
We have already explored the topic of PDF editing with our API when we showed you how to split & merge PDF documents. In this article, we will have a look at how to protect your PDF files from copying, editing and being printed and distributed. How? By adding password protection to your PDF.
How To Use Our API To Edit PDFs
Before we dive into the process of adding password protection to a PDF, you’ll need to learn the basics of using the Online-Convert.com with the help of an API execution app. This API tutorial contains a basic introduction to postman and a link to the necessary collection file.
Of course you can also check out our video tutorial on how to use the online-convert.com API.
Now that we have covered the basics, lets have a look at how to protect your PDF to prevent people from viewing it without the password. You can furthermore specify what “users” of the PDF will be allowed to do once they entered the password.
The following command will be the basic command we’ll use.
{ "input": [{ "type": "remote", "source": "https://cdn.online-convert.com/example-file/document/pdf/example.pdf" }], "conversion": [{ "target": "pdf", "category": "document" }] }
This POST command will convert an example PDF into another PDF file. The following command will be added to enable the usage of different options, in our case the PDF protection:
"options": { }
Add Password Protection To A PDF
In order to add password protection to a PDF file, you have to add the following options to your POST command:
"new_owner_password": { "type": "string", "pattern": "^[\\w\\W]{0,64}$", "description": "Adds or change the owner's password (up to 64 characters)" }, "new_user_password": { "type": "string", "pattern": "^[\\w\\W]{0,64}$", "description": "Adds or change the user's password (up to 64 characters)" }, "allow_printing": { "type": "boolean", "description": "Allows the printing of the document" }, "allow_copying": { "type": "boolean", "description": "Allows the copying of the document" }, "allow_modification": { "type": "boolean", "description": "Allows the modification of the document" }
The new owner and user passwords can contain strings of characters made up from letters, numbers and special characters. The individual strings can be up to 64 characters long.
The permissions include permission to print, copy or modify the resulting PDF document. The value for these settings can either be true or false.
Following this scheme, a full POST command to add password protection to your PDF should look like this:
{ "input": [{ "type": "remote", "source": "https://cdn.online-convert.com/example-file/document/pdf/example.pdf" }], "conversion": [{ "target": "pdf", "category": "document", "options": { "new_owner_password": "owner", "new_user_password": "user", "allow_printing": false, "allow_copying": false, "allow_modification": false } }] }
With this call, you are disabling a user of your PDF from printing, copying and modifying. The password for this user is user. When you enter the owner password owner, however, you can do everything you did not allow for a user.
Got any questions?
If you still have questions about how to use Online-Convert.com’s API to edit your PDFs, drop us a message. A friendly and competent support team will make sure that you will be able to do your conversions just like you wanted to.
Further Information
Follow us