How to Linearize a PDF in JavaScript

1 min readJun 15, 2021


Getting tired of those lengthy download times for large files? Us too. To cut down on your wait time and boost productivity, you can use the following API in JavaScript to linearize the contents of a PDF and optimize the file for streaming download. This simple process will enable you to view the document as it loads; once the download is complete, you may already be halfway through your related task.

Let’s start things off by installing the jQuery library:

bower install jquery

With the installation out of the way, we are ready to input the PDF file and call the function:

var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");
var settings = {
"url": "",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "multipart/form-data",
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
$.ajax(settings).done(function (response) {

To retrieve your API key, visit the Cloudmersive website and register for a free account; this will provide 800 calls/month across our entire library of APIs.




There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.