Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions UsesCases/Attachments/add/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create an object to connect to the Pdf.Cloud API
// 3. Create an AttachmentInfo object, which maust be inserted into Pdf file
// 4. Perform append attachment into Pdf document using postAddDocumentAttachment() function and AttachmentImfo object
// 5. Check result and perform some actions with result.body object
// All values of variables starting with "YOUR_****" should be replaced by real user values

var PdfApi = require('asposepdfcloud');

var configProps = require('YOUR_CONFIG_FFOLDER/YOUR_CONFIG.json');

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

var pdfApi = new PdfApi(config);

const attachment = new AttachmentInfo();
attachment.name = "YOUR_ATTACHMENT_NAME";
attachment.path = "YOUR_ATTACHMENT_PATH";
attachment.description = "YOUR_ATTACHMENT_DESCRIPTION";
attachment.mimeType = "type/YOUR_SUBTYPE";

let result = await pdfApi.postAddDocumentAttachment ("YOUR_PDF_FILE_NAME.pdf", attachment, null, null);

console.log(result.response);

console.log(result.body);
40 changes: 40 additions & 0 deletions UsesCases/Attachments/get/get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create a Storage API object for uploading Pdf file
// 3. Create an object to connect to the Pdf.Cloud API
// 4. Upload your document file using PutCreate() function of the Storage API object
// 5. To extract attachments from a PDF document, using getDocumentAttachments() function
// 6. Check result and perform some actions with result.body object
// All values of variables starting with "YOUR_****" should be replaced by real user values

var fs = require('fs');
var PdfApi = require('asposepdfcloud');
var StorageApi = require('asposestoragecloud');

var configProps = require('YOUR_CONFIG_FOLDER/YOUR_CONFIG.json');

var data_path = 'YOUR_DATA_FOLDER_WITH_PATH/';

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var outFolder = configProps.out_folder;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

var storageApi = new StorageApi(config);

var pdfApi = new PdfApi(config);

var fileName = "YOUR_ATTACHMENT_FILE_NAME";
var name = fileName + ".pdf";
var attachmentIndex = 1;


storageApi.PutCreate(name, null, null, data_path + name , async function(responseMessage) {

assert.equal(responseMessage.status, 'OK');

let result = await pdfApi.getDocumentAttachments(name, attachmentIndex, null, null);

console.log(result.response);

console.log(result.body);
});
38 changes: 38 additions & 0 deletions UsesCases/Attachments/get_download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create a Storage API object for uploading Pdf file
// 3. Create an object to connect to the Pdf.Cloud API
// 4. Upload your document file using PutCreate() function of the Storage API object
// 5. To extract attachments from a PDF document, using getDocumentAttachmentByIndex() function
// 6. Download the result if need it
// All values of variables starting with "YOUR_****" should be replaced by real user values

var fs = require('fs');
var PdfApi = require('asposepdfcloud');
var StorageApi = require('asposestoragecloud');

var configProps = require('YOUR_CONFIG_FFOLDER/YOUR_CONFIG.json');

var data_path = 'YOUR_DATA_FOLDER_WITH_PATH/';

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

var storageApi = new StorageApi(config);

var pdfApi = new PdfApi(config);

var fileName = "YOUR_ATTACHMENT_FILE_NAME";
var name = fileName + ".pdf";
var attachmentIndex = 1;

storageApi.PutCreate(name, null, null, data_path + name , async function(responseMessage)
{

let result = await pdfApi.getDownloadDocumentAttachmentByIndex(name, attachmentIndex, null, null);

var outfilename = fileName + attachmentIndex + ".text";
var writeStream = fs.createWriteStream(data_path + outfilename);
writeStream.write(result.body);

});
35 changes: 35 additions & 0 deletions UsesCases/Images/add/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create an object to connect to the Pdf.Cloud API
// 3. Initialize neccessary values for append image
// 4. Perform the inserting image in Pdf document using postInsertImage() function and new image file initialized values
// 6. Check result and perform some actions with result.body object
// All values of variables starting with "YOUR_****" should be replaced by real user values


var PdfApi = require('asposepdfcloud');

var configProps = require('YOUR_CONFIG_FFOLDER/YOUR_CONFIG.json');

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

pdfApi = new PdfApi(AppSID, AppKey);

let fileName = "YOUR_PDF_DOCUMENT.pdf";

let pageNum = "YOUR_PAGE_NUMBER";

let posLeftDownX = "YOUR_IMAGE_LLX";
let posLeftDownY = "YOUR_IMAGE_LLY";

let posRighUptX = "YOUR_IMAGE_URX";
let posRightUpY = "YOUR_IMAGE_URY";

let imageFile = "YOUR_IMAGE_FOLDER_AND_PATH";

let resultAppend = await pdfApi.postInsertImage (fileName, pageNum, posLeftDownX, posLeftDownY, posRighUptX, posRightUpY, imageFile, null, null, null);

console.log(resultAppend.response);

console.log(resultAppend.body);
29 changes: 29 additions & 0 deletions UsesCases/Images/get/get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create an object to connect to the Pdf.Cloud API
// 3. Upload your document file
// 4. Perform the rtreiving image Id from Pdf document using getIimages function
// 5. Perform the extracting image from Pdf document using getImage function and image ID value
// 6. Check result and perform some actions with result.body object
// All values of variables starting with "YOUR_****" should be replaced by real user values


var PdfApi = require('asposepdfcloud');

var configProps = require('YOUR_CONFIG_FFOLDER/YOUR_CONFIG.json');

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

pdfApi = new PdfApi(AppSID, AppKey);

let fileName = "YOUR_PDF_DOCUMENT.pdf";

let resultImageId = await pdfApi.getImages(fileName, 1, null, null);
const imageID = resultImageId.body.images.list[0].id;

let resultImage = await pdfApi.getImage(fileName, imageID, null, null);

console.log(resultImage.response);

console.log(resultImage.body);
37 changes: 37 additions & 0 deletions UsesCases/Images/get_common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create an object to connect to the Pdf.Cloud API
// 3. Upload your document file
// 4. Perform the retreiving image Id from Pdf document using getIimages() function
// 5. Perform the reading image from Pdf document using getImage() function and image ID value
// 6. Check result and perform some actions with result.body object
// 7. Perform extrating image in Png format from Pdf document into local folder using putImageExtractAsPng() function and image ID value
// 8. Check result and perform some actions with result.body object
// All values of variables starting with "YOUR_****" should be replaced by real user values


var PdfApi = require('asposepdfcloud');

var configProps = require('YOUR_CONFIG_FFOLDER/YOUR_CONFIG.json');

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

pdfApi = new PdfApi(AppSID, AppKey);

let fileName = "YOUR_PDF_DOCUMENT.pdf";

let resultImageId = await pdfApi.getImages(fileName, 1, null, null);
const imageID = resultImageId.body.images.list[0].id;

let resultImage = await pdfApi.getImage(fileName, imageID, null, null);

console.log(resultImage.response);

console.log(resultImage.body);

let extractResult = await pdfApi.putImageExtractAsPng(fileName, imageID, 512, 512, null, null, 'YOUR_DESTINATION_FOLDER');

console.log(extractResult.response);

console.log(extractResult.body);
28 changes: 28 additions & 0 deletions UsesCases/Images/remove/remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create an object to connect to the Pdf.Cloud API
// 3. Upload your document file
// 4. Perform the rtreiving image Id from Pdf document using getIimages function
// 5. Delete image from Pdf document using deleteImage function and image ID value
// 6. Check result and perform some actions with result.body object
// All values of variables starting with "YOUR_****" should be replaced by real user values

var PdfApi = require('asposepdfcloud');

var configProps = require('YOUR_CONFIG_FFOLDER/YOUR_CONFIG.json');

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

pdfApi = new PdfApi(AppSID, AppKey);

let fileName = "YOUR_PDF_DOCUMENT.pdf";

let resultImageId = await pdfApi.getImages(fileName, 1, null, null);
const imageID = resultImageId.body.images.list[0].id;

let deleteResult = await pdfApi.deleteImage(fileName, imageID, null, null);

console.log(deleteResult.response);

console.log(deleteResult.body);
29 changes: 29 additions & 0 deletions UsesCases/Images/update/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 1. Load your Application Secret and Key from the JSON file or set credentials in another way
// 2. Create an object to connect to the Pdf.Cloud API
// 3. Upload your document file
// 4. Perform the retreiving image Id from Pdf document using getIimages() function
// 5. Perform the unpdating image in Pdf document using putReplaceImage() function, image ID value and new image file
// 6. Check result and perform some actions with result.body object
// All values of variables starting with "YOUR_****" should be replaced by real user values


var PdfApi = require('asposepdfcloud');

var configProps = require('YOUR_CONFIG_FFOLDER/YOUR_CONFIG.json');

var AppSID = configProps.app_sid;
var AppKey = configProps.api_key;
var config = { 'appSid': AppSID, 'apiKey': AppKey, 'debug' : true };

pdfApi = new PdfApi(AppSID, AppKey);

let fileName = "YOUR_PDF_DOCUMENT.pdf";

let resultImageId = await pdfApi.getImages(fileName, 1, null, null);
const imageID = resultImageId.body.images.list[0].id;

let resultUpdate = await pdfApi.putReplaceImage (fileName, imageID, "YOUR_NEW_IMAGE_FOLDER_AND_NAME", null, null, null);

console.log(resultUpdate.response);

console.log(resultUpdate.body);