-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from datalogics-tsmith/raw-json-calls-js
PDFCLOUD-2823 Add upload + raw JSON Javascript samples
- Loading branch information
Showing
36 changed files
with
1,823 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
47 changes: 47 additions & 0 deletions
47
JavaScript/Endpoint Examples/JSON Payload/compressed-pdf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
47 changes: 47 additions & 0 deletions
47
JavaScript/Endpoint Examples/JSON Payload/decrypted-pdf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
47 changes: 47 additions & 0 deletions
47
JavaScript/Endpoint Examples/JSON Payload/encrypted-pdf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
47 changes: 47 additions & 0 deletions
47
JavaScript/Endpoint Examples/JSON Payload/exported-form-data.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
47 changes: 47 additions & 0 deletions
47
JavaScript/Endpoint Examples/JSON Payload/extracted-text.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
47 changes: 47 additions & 0 deletions
47
JavaScript/Endpoint Examples/JSON Payload/flattened-annotations-pdf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
Oops, something went wrong.