How to Convert a PDF to PDF/A in JavaScript
As we’ve discussed in previous articles, the PDF format is one of the most common and popular formats for saving and sharing documents. However, when it comes to long-term archiving, PDF files allow several features that are incompatible with that particular function. To transform your PDF to an archive-compatible format, you can use the following API in JavaScript to convert it to a standardized PDF/A document.
To kick off the process, we will install the jQuery library:
bower install jquery
Then we are ready to call the function with the following code:
var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");var settings = {
"url": "https://api.cloudmersive.com/convert/edit/pdf/optimize/pdf-a",
"method": "POST",
"timeout": 0,
"headers": {
"conformanceLevel": "<string>",
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};$.ajax(settings).done(function (response) {
console.log(response);
});
It’s that easy! Your new PDF/A document will be available for immediate download and use. To retrieve your API key, head to the Cloudmersive website to register for a free account; this will provide access to 800 monthly calls across our multitude of APIs.