In this tutorial, we will show you how to extract Doc to Protected PDF in JavaScript using PDF.co Web API. Below is the image of the sample Doc and the Protected PDF output.
- JavaScript Sample Code
- PDF.co API Key
- Source URL, Result, and Password
- Setup PDF Security
- Run Program
- Protected PDF Demo

Step 1: JavaScript Sample Code
To begin, open your Visual Studio app and save the source code.
Step 2: PDF.co API Key
In line 21, add your API Key. You can get the PDF.co API Key in your dashboard here.
Step 3: Source URL, Result, and Password
- In line 26, enter your source file URL. If you don’t have one, you can use the built-in source URL in the sample code.
- In line 28, type in your desired protected output file name.
- In line 31, add your document password.
Step 4: Setup PDF Security
Now, let’s set up PDF Security.
- For the EncryptionAlgorithm, enter your usable bit values.
- In the AllowAccessibilitySupport, set to
true
to allow content extraction for accessibility. - For the AllowAssemblyDocument, set to
true
to allow assembling of the document. - In the AllowPrintDocument, set to
true
to allow printing documents. - For the AllowFillForms, set to
true
to allow filling to interactive form fields. - In the AllowModifyDocument, set to
true
to allow modification of PDF documents. - For the AllowContentExtaction, set to
true
to allow copying content from PDF documents. - In the AllowModifyAnnotations, set to
true
to allow interaction with text annotations. - For the PrintQuality, choose the
HighResolution
document printing quality.
Step 5: Run Program
To run the program, type in node app.js
in the terminal.
Protected PDF Demo
Here’s a quick demo to convert Doc to protected PDF.

In this tutorial, you learned how to convert Doc to protected PDF in Javascript. You learned how to use the /pdf/convert/from/doc endpoint to convert a Doc to PDF. You also learned how to add security details to a PDF document.