diff --git a/JavaScript/Endpoint Examples/JSON Payload/README.md b/JavaScript/Endpoint Examples/JSON Payload/README.md new file mode 100644 index 0000000..ee22b2b --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/README.md @@ -0,0 +1,3 @@ +This directory contains examples of how to call each endpoint of the +PdfRest API using Javascript. Please refer to https://pdfrest.com/documentation.html +for accepted inputs, options, and other specifics about individual endpoints. diff --git a/JavaScript/Endpoint Examples/JSON Payload/bmp.js b/JavaScript/Endpoint Examples/JSON Payload/bmp.js new file mode 100644 index 0000000..d611575 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/bmp.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var bmp_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/bmp", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(bmp_config) + .then(function (bmp_response) { + console.log(JSON.stringify(bmp_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/compressed-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/compressed-pdf.js new file mode 100644 index 0000000..4c42cce --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/compressed-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var compress_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/compressed-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id, compression_level: "medium" }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(compress_config) + .then(function (compress_response) { + console.log(JSON.stringify(compress_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/decrypted-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/decrypted-pdf.js new file mode 100644 index 0000000..0acf208 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/decrypted-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var decrypt_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/decrypted-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id, current_open_password: "current_password" }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(decrypt_config) + .then(function (decrypt_response) { + console.log(JSON.stringify(decrypt_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/encrypted-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/encrypted-pdf.js new file mode 100644 index 0000000..eadfc35 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/encrypted-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var encrypt_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/encrypted-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id, new_open_password: "password" }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(encrypt_config) + .then(function (encrypt_response) { + console.log(JSON.stringify(encrypt_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/excel.js b/JavaScript/Endpoint Examples/JSON Payload/excel.js new file mode 100644 index 0000000..2902734 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/excel.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var excel_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/excel", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(excel_config) + .then(function (excel_response) { + console.log(JSON.stringify(excel_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/exported-form-data.js b/JavaScript/Endpoint Examples/JSON Payload/exported-form-data.js new file mode 100644 index 0000000..9402afb --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/exported-form-data.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var export_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/exported-form-data", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id, data_format: "xml" }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(export_config) + .then(function (export_response) { + console.log(JSON.stringify(export_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/extracted-text.js b/JavaScript/Endpoint Examples/JSON Payload/extracted-text.js new file mode 100644 index 0000000..e247190 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/extracted-text.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var extract_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/extracted-text", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(extract_config) + .then(function (extract_response) { + console.log(JSON.stringify(extract_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/flattened-annotations-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/flattened-annotations-pdf.js new file mode 100644 index 0000000..a26127e --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/flattened-annotations-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var flatten_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/flattened-annotations-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(flatten_config) + .then(function (flatten_response) { + console.log(JSON.stringify(flatten_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/flattened-forms-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/flattened-forms-pdf.js new file mode 100644 index 0000000..cbad5f4 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/flattened-forms-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var flatten_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/flattened-forms-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(flatten_config) + .then(function (flatten_response) { + console.log(JSON.stringify(flatten_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/flattened-layers-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/flattened-layers-pdf.js new file mode 100644 index 0000000..0646acd --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/flattened-layers-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var flatten_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/flattened-layers-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(flatten_config) + .then(function (flatten_response) { + console.log(JSON.stringify(flatten_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/flattened-transparencies-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/flattened-transparencies-pdf.js new file mode 100644 index 0000000..e69969f --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/flattened-transparencies-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var flatten_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/flattened-transparencies-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(flatten_config) + .then(function (flatten_response) { + console.log(JSON.stringify(flatten_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/get-resource.js b/JavaScript/Endpoint Examples/JSON Payload/get-resource.js new file mode 100644 index 0000000..1683e48 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/get-resource.js @@ -0,0 +1,18 @@ +// This request demonstrates how to retrieve a resource using an ID. +const axios = require('axios'); + +let config = { + method: 'get', + maxBodyLength: Infinity, // set maximum length of the request body + url: 'https://api.pdfrest.com/resource/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?format=url', + headers: { } +}; + +// define configuration options for axios request +axios.request(config) +.then((response) => { + console.log(JSON.stringify(response.data)); +}) +.catch((error) => { + console.log(error); +}); diff --git a/JavaScript/Endpoint Examples/JSON Payload/gif.js b/JavaScript/Endpoint Examples/JSON Payload/gif.js new file mode 100644 index 0000000..32649ff --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/gif.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var gif_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/gif", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(gif_config) + .then(function (gif_response) { + console.log(JSON.stringify(gif_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/jpg.js b/JavaScript/Endpoint Examples/JSON Payload/jpg.js new file mode 100644 index 0000000..5be2338 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/jpg.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var jpg_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/jpg", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(jpg_config) + .then(function (jpg_response) { + console.log(JSON.stringify(jpg_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/linearized-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/linearized-pdf.js new file mode 100644 index 0000000..1b2cfc0 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/linearized-pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var linearize_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/linearized-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(linearize_config) + .then(function (linearize_response) { + console.log(JSON.stringify(linearize_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/merged-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/merged-pdf.js new file mode 100644 index 0000000..9fa5a7a --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/merged-pdf.js @@ -0,0 +1,73 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var first_upload_data = fs.createReadStream("/path/to/first_file"); + +var first_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "first_filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: first_upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(first_upload_config) + .then(function (first_upload_response) { + var first_uploaded_id = first_upload_response.data.files[0].id; + + var second_upload_data = fs.createReadStream("/path/to/second_file"); + + var second_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "second_filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: second_upload_data, // set the data to be sent with the request + }; + + axios(second_upload_config) + .then(function (second_upload_response) { + console.log(JSON.stringify(second_upload_response.data)); + var second_uploaded_id = second_upload_response.data.files[0].id; + + var merge_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/merged-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: [first_uploaded_id, second_uploaded_id], + type: ["id", "id"], + pages: [1, "1-last"], + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(merge_config) + .then(function (merge_response) { + console.log(JSON.stringify(merge_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/package-lock.json b/JavaScript/Endpoint Examples/JSON Payload/package-lock.json new file mode 100644 index 0000000..4e3c6fb --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/package-lock.json @@ -0,0 +1,165 @@ +{ + "name": "JavaScript", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "axios": "^1.4.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + } + }, + "dependencies": { + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + }, + "follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "requires": { + "mime-db": "1.52.0" + } + }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + } + } +} diff --git a/JavaScript/Endpoint Examples/JSON Payload/package.json b/JavaScript/Endpoint Examples/JSON Payload/package.json new file mode 100644 index 0000000..cb17ec7 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "axios": "^1.4.0" + } +} diff --git a/JavaScript/Endpoint Examples/JSON Payload/pdf-info.js b/JavaScript/Endpoint Examples/JSON Payload/pdf-info.js new file mode 100644 index 0000000..c90b029 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/pdf-info.js @@ -0,0 +1,51 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var info_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/pdf-info", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: uploaded_id, + queries: + "title,subject,author,producer,creator,creation_date,modified_date", + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(info_config) + .then(function (info_response) { + console.log(JSON.stringify(info_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/pdf-with-added-attachment.js b/JavaScript/Endpoint Examples/JSON Payload/pdf-with-added-attachment.js new file mode 100644 index 0000000..37fd8dd --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/pdf-with-added-attachment.js @@ -0,0 +1,75 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var pdf_upload_data = fs.createReadStream("/path/to/pdf_file"); + +var pdf_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "pdf_filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: pdf_upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(pdf_upload_config) + .then(function (pdf_upload_response) { + var pdf_uploaded_id = pdf_upload_response.data.files[0].id; + + var attachment_upload_data = fs.createReadStream( + "/path/to/attachment_file" + ); + + var attachment_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "attachment_filename.xml", + "Content-Type": "application/octet-stream", + }, + data: attachment_upload_data, // set the data to be sent with the request + }; + + axios(attachment_upload_config) + .then(function (attachment_upload_response) { + console.log(JSON.stringify(attachment_upload_response.data)); + var attachment_uploaded_id = + attachment_upload_response.data.files[0].id; + + var attach_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/pdf-with-added-attachment", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: pdf_uploaded_id, + id_to_attach: attachment_uploaded_id, + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(attach_config) + .then(function (attach_response) { + console.log(JSON.stringify(attach_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/pdf-with-added-image.js b/JavaScript/Endpoint Examples/JSON Payload/pdf-with-added-image.js new file mode 100644 index 0000000..f5e3020 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/pdf-with-added-image.js @@ -0,0 +1,75 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var pdf_upload_data = fs.createReadStream("/path/to/pdf_file"); + +var pdf_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "pdf_filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: pdf_upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(pdf_upload_config) + .then(function (pdf_upload_response) { + var pdf_uploaded_id = pdf_upload_response.data.files[0].id; + + var image_upload_data = fs.createReadStream("/path/to/image_file"); + + var image_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "image_filename.png", + "Content-Type": "application/octet-stream", + }, + data: image_upload_data, // set the data to be sent with the request + }; + + axios(image_upload_config) + .then(function (image_upload_response) { + console.log(JSON.stringify(image_upload_response.data)); + var image_uploaded_id = image_upload_response.data.files[0].id; + + var add_image_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/pdf-with-added-image", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: pdf_uploaded_id, + image_id: image_uploaded_id, + x: 0, + y: 0, + page: 1, + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(add_image_config) + .then(function (add_image_response) { + console.log(JSON.stringify(add_image_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.js b/JavaScript/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.js new file mode 100644 index 0000000..c126c3d --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.js @@ -0,0 +1,72 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var pdf_upload_data = fs.createReadStream("/path/to/pdf_file"); + +var pdf_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "pdf_filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: pdf_upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(pdf_upload_config) + .then(function (pdf_upload_response) { + var pdf_uploaded_id = pdf_upload_response.data.files[0].id; + + var data_upload_data = fs.createReadStream("/path/to/data_file.xml"); + + var data_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "data_filename.xml", + "Content-Type": "application/octet-stream", + }, + data: data_upload_data, // set the data to be sent with the request + }; + + axios(data_upload_config) + .then(function (data_upload_response) { + console.log(JSON.stringify(data_upload_response.data)); + var data_uploaded_id = data_upload_response.data.files[0].id; + + var import_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/pdf-with-imported-form-data", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: pdf_uploaded_id, + data_file_id: data_uploaded_id, + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(import_config) + .then(function (import_response) { + console.log(JSON.stringify(import_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/pdf.js b/JavaScript/Endpoint Examples/JSON Payload/pdf.js new file mode 100644 index 0000000..69d176f --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/pdf.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.png", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var pdf_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(pdf_config) + .then(function (pdf_response) { + console.log(JSON.stringify(pdf_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/pdfa.js b/JavaScript/Endpoint Examples/JSON Payload/pdfa.js new file mode 100644 index 0000000..5d5323c --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/pdfa.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var pdfa_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/pdfa", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id, output_type: "PDF/A-2b" }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(pdfa_config) + .then(function (pdfa_response) { + console.log(JSON.stringify(pdfa_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/pdfx.js b/JavaScript/Endpoint Examples/JSON Payload/pdfx.js new file mode 100644 index 0000000..4b5d0b4 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/pdfx.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var pdfx_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/pdfx", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id, output_type: "PDF/X-4" }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(pdfx_config) + .then(function (pdfx_response) { + console.log(JSON.stringify(pdfx_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/png.js b/JavaScript/Endpoint Examples/JSON Payload/png.js new file mode 100644 index 0000000..8872625 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/png.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var png_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/png", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(png_config) + .then(function (png_response) { + console.log(JSON.stringify(png_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/powerpoint.js b/JavaScript/Endpoint Examples/JSON Payload/powerpoint.js new file mode 100644 index 0000000..b575803 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/powerpoint.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var powerpoint_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/powerpoint", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(powerpoint_config) + .then(function (powerpoint_response) { + console.log(JSON.stringify(powerpoint_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/restricted-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/restricted-pdf.js new file mode 100644 index 0000000..090694c --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/restricted-pdf.js @@ -0,0 +1,51 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var restrict_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/restricted-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: uploaded_id, + restrictions: ["print_low", "edit_content"], + new_permissions_password: "Password", + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(restrict_config) + .then(function (restrict_response) { + console.log(JSON.stringify(restrict_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/split-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/split-pdf.js new file mode 100644 index 0000000..8b66956 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/split-pdf.js @@ -0,0 +1,50 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var split_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/split-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: uploaded_id, + pages: [1, "even"], + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(split_config) + .then(function (split_response) { + console.log(JSON.stringify(split_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/tif.js b/JavaScript/Endpoint Examples/JSON Payload/tif.js new file mode 100644 index 0000000..48dc5f7 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/tif.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var tif_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/tif", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(tif_config) + .then(function (tif_response) { + console.log(JSON.stringify(tif_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/unrestricted-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/unrestricted-pdf.js new file mode 100644 index 0000000..81b7731 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/unrestricted-pdf.js @@ -0,0 +1,50 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var unrestrict_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/unrestricted-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: uploaded_id, + current_permissions_password: "current_password", + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(unrestrict_config) + .then(function (unrestrict_response) { + console.log(JSON.stringify(unrestrict_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/upload.js b/JavaScript/Endpoint Examples/JSON Payload/upload.js new file mode 100644 index 0000000..9cc0670 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/upload.js @@ -0,0 +1,27 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +// define configuration options for axios request +var config = { + method: "post", + maxBodyLength: Infinity, // set maximum length of the request body + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(config) + .then(function (response) { + console.log(JSON.stringify(response.data)); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/watermarked-pdf.js b/JavaScript/Endpoint Examples/JSON Payload/watermarked-pdf.js new file mode 100644 index 0000000..3d9ac8b --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/watermarked-pdf.js @@ -0,0 +1,50 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var watermark_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/watermarked-pdf", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: uploaded_id, + watermark_text: "watermark text", + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(watermark_config) + .then(function (watermark_response) { + console.log(JSON.stringify(watermark_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/word.js b/JavaScript/Endpoint Examples/JSON Payload/word.js new file mode 100644 index 0000000..9682a19 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/word.js @@ -0,0 +1,47 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var upload_data = fs.createReadStream("/path/to/file"); + +var upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(upload_config) + .then(function (upload_response) { + console.log(JSON.stringify(upload_response.data)); + var uploaded_id = upload_response.data.files[0].id; + + var word_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/word", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { id: uploaded_id }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(word_config) + .then(function (word_response) { + console.log(JSON.stringify(word_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/JSON Payload/zip.js b/JavaScript/Endpoint Examples/JSON Payload/zip.js new file mode 100644 index 0000000..3180ea9 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/zip.js @@ -0,0 +1,71 @@ +var axios = require("axios"); +var FormData = require("form-data"); +var fs = require("fs"); + +var first_upload_data = fs.createReadStream("/path/to/first_file"); + +var first_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "first_filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: first_upload_data, // set the data to be sent with the request +}; + +// send request and handle response or error +axios(first_upload_config) + .then(function (first_upload_response) { + var first_uploaded_id = first_upload_response.data.files[0].id; + + var second_upload_data = fs.createReadStream("/path/to/second_file"); + + var second_upload_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/upload", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Filename": "second_filename.pdf", + "Content-Type": "application/octet-stream", + }, + data: second_upload_data, // set the data to be sent with the request + }; + + axios(second_upload_config) + .then(function (second_upload_response) { + console.log(JSON.stringify(second_upload_response.data)); + var second_uploaded_id = second_upload_response.data.files[0].id; + + var zip_config = { + method: "post", + maxBodyLength: Infinity, + url: "https://api.pdfrest.com/zip", + headers: { + "Api-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Replace with your API key + "Content-Type": "application/json", + }, + data: { + id: [first_uploaded_id, second_uploaded_id], + }, // set the data to be sent with the request + }; + + // send request and handle response or error + axios(zip_config) + .then(function (zip_response) { + console.log(JSON.stringify(zip_response.data)); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + }); + }) + .catch(function (error) { + console.log(error); + });