Skip to content

Commit a9d8e97

Browse files
authored
Merge pull request #30 from aspose-pdf-cloud/holub
feat: PDF Pages (add landing pages - add Header/Footer section - nodejs)
2 parents d554c6f + 80bcacc commit a9d8e97

File tree

24 files changed

+414
-371
lines changed

24 files changed

+414
-371
lines changed

pdf/net/attachments/_index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ PM> Install-Package Aspose.Pdf-Cloud
4747

4848
{{% /blocks/products/pf/agp/text %}}
4949

50-
1.
50+
1. Upload the PDF file to cloud storage
51+
1. Retrieve the attachment by index
52+
1. Display the attachment name
5153

5254
{{% /blocks/products/pf/agp/feature-section-col %}}
5355

pdf/net/attachments/append/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PM> Install-Package Aspose.Pdf-Cloud
3737

3838
{{< blocks/products/pf/agp/feature-section isGrey="true" >}}
3939

40-
{{% blocks/products/pf/agp/feature-section-col title="Steps to add attachments in PDF documents via Cloud .NET SDK" %}}
40+
{{% blocks/products/pf/agp/feature-section-col title="Steps to add attachments - .NET SDK" %}}
4141

4242
{{% blocks/products/pf/agp/text %}}
4343

pdf/net/attachments/extract/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PM> Install-Package Aspose.Pdf-Cloud
3737

3838
{{< blocks/products/pf/agp/feature-section isGrey="true" >}}
3939

40-
{{% blocks/products/pf/agp/feature-section-col title="Steps to extract attachments in PDF documents via Cloud .NET SDK" %}}
40+
{{% blocks/products/pf/agp/feature-section-col title="Steps to extract attachments - .NET SDK" %}}
4141

4242
{{% blocks/products/pf/agp/text %}}
4343

pdf/nodejs/attachments/_index.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ liveDemosLink="https://products.aspose.app/pdf/family/" PricingLink="https://pur
4040

4141
{{< blocks/products/pf/agp/feature-section isGrey="true" >}}
4242

43-
{{% blocks/products/pf/agp/feature-section-col title="Steps to extract attachments in PDF documents via Cloud Node.js SDK" %}}
43+
{{% blocks/products/pf/agp/feature-section-col title="Steps to extract attachments - Cloud Node.js" %}}
4444

4545
{{% blocks/products/pf/agp/text %}}
4646

@@ -87,46 +87,67 @@ It is easy to get started with Aspose.PDF Cloud Node.js SDK and there is nothing
8787
import { AttachmentInfo } from "asposepdfcloud/src/models/attachmentInfo.js";
8888

8989
async function getAllAttachments() {
90-
const LOCAL_PATH = "C:\\Samples\\";
91-
const LOCAL_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
92-
const STORAGE_FILE_NAME = "sample_attachment.pdf";
93-
try {
94-
const pdfApi = new PdfApi(credentials.id, credentials.key);
95-
const pdfData = await fs.readFile(LOCAL_FILE_NAME);
96-
await pdfApi.uploadFile(STORAGE_FILE_NAME, pdfData);
97-
98-
const result = await pdfApi.getDocumentAttachments(STORAGE_FILE_NAME);
99-
100-
if (result.body.code === 200 && result.body.attachments) {
101-
const attachmentList = result.body.attachments.list || [];
102-
if (!attachmentList.length) {
103-
console.error("No attachments found.");
104-
return;
105-
}
106-
107-
const downloadTasks = attachmentList.map(async (attachment) => {
108-
try {
109-
const attachmentUrl = attachment.links[0].href;
110-
const info = await pdfApi.getDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
111-
const download = await pdfApi.getDownloadDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
112-
await fs.writeFile(path.join(LOCAL_PATH, info.body.attachment.name), download.body);
113-
} catch (error) {
114-
console.error("Failed to download attachment:", error);
90+
const LOCAL_PATH = "C:\\Samples\\";
91+
const LOCAL_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
92+
const STORAGE_FILE_NAME = "sample_attachment.pdf";
93+
try {
94+
const pdfApi = new PdfApi(credentials.id, credentials.key);
95+
const pdfData = await fs.readFile(LOCAL_FILE_NAME);
96+
await pdfApi.uploadFile(STORAGE_FILE_NAME, pdfData);
97+
98+
const result = await pdfApi.getDocumentAttachments(STORAGE_FILE_NAME);
99+
100+
if (result.body.code === 200 && result.body.attachments) {
101+
const attachmentList = result.body.attachments.list || [];
102+
if (!attachmentList.length) {
103+
console.error("No attachments found.");
104+
return;
115105
}
116-
});
117106

118-
await Promise.all(downloadTasks);
119-
} else {
120-
console.error("Failed to retrieve attachments. Status:", result.statusCode);
107+
const downloadTasks = attachmentList.map(async (attachment) => {
108+
try {
109+
const attachmentUrl = attachment.links[0].href;
110+
const info = await pdfApi.getDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
111+
const download = await pdfApi.getDownloadDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
112+
await fs.writeFile(path.join(LOCAL_PATH, info.body.attachment.name), download.body);
113+
} catch (error) {
114+
console.error("Failed to download attachment:", error);
115+
}
116+
});
117+
118+
await Promise.all(downloadTasks);
119+
} else {
120+
console.error("Failed to retrieve attachments. Status:", result.statusCode);
121+
}
122+
} catch (error) {
123+
console.error("Error processing PDF attachments:", error);
121124
}
122-
} catch (error) {
123-
console.error("Error processing PDF attachments:", error);
124125
}
125-
}
126126
```
127127

128128
{{% /blocks/products/pf/agp/code-block %}}
129129

130+
{{% blocks/products/pf/agp/content h2="Work with the Attachments in PDF via Node.js SDK" %}}
131+
132+
Getting attachments from a PDF is essential for accessing supplementary content, improving workflow efficiency, ensuring compliance, and enhancing security. It helps users retrieve critical files, automate document processing, and optimize document management in business, legal, and technical applications.
133+
Get the AcroForms from PDF documents with [Aspose.PDF Cloud Node.js SDK](https://products.aspose.cloud/pdf/nodejs/).
134+
135+
**With our Node.js library you can**
136+
137+
+ Add PDF document's header & footer in text or image format.
138+
+ Add tables & stamps (text or image) to PDF documents.
139+
+ Append multiple PDF documents to an existing file.
140+
+ Work with PDF attachments, annotations, & form fields.
141+
+ Apply encryption or decryption to PDF documents & set a password.
142+
+ Delete all stamps & tables from a page or entire PDF document.
143+
+ Delete a specific stamp or table from the PDF document by its ID.
144+
+ Replace single or multiple instances of text on a PDF page or from the entire document.
145+
+ Extensive support for converting PDF documents to various other file formats.
146+
+ Extract various elements of PDF files & make PDF documents optimized.
147+
+ You can try out our [free App](https://products.aspose.app/pdf/xfa) to add the AcroForms into PDF files online and test the functionality.
148+
149+
{{% /blocks/products/pf/agp/content %}}
150+
130151
{{< /blocks/products/pf/agp/feature-section >}}
131152

132153
{{< blocks/products/pf/agp/faq-item question="" answer="" >}}

pdf/nodejs/attachments/append/_index.md

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ liveDemosLink="https://products.aspose.app/pdf/family/" PricingLink="https://pur
4040

4141
{{< blocks/products/pf/agp/feature-section isGrey="true" >}}
4242

43-
{{% blocks/products/pf/agp/feature-section-col title="Steps to append attachments in PDF documents via Cloud Node.js SDK" %}}
43+
{{% blocks/products/pf/agp/feature-section-col title="Steps to add attachments - Cloud Node.js" %}}
4444

4545
{{% blocks/products/pf/agp/text %}}
4646

@@ -83,43 +83,64 @@ It is easy to get started with Aspose.PDF Cloud Node.js SDK and there is nothing
8383
import { AttachmentInfo } from "asposepdfcloud/src/models/attachmentInfo.js";
8484

8585
async function addAttachment() {
86-
const LOCAL_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
87-
const STORAGE_FILE_NAME = "sample_attachment.pdf";
88-
const LOCAL_ATTACHMENT_FILE_NAME = "C:\\Samples\\Attachments\\file_example_MP3_700KB.mp3";
89-
const STORAGE_ATTACHMENT_FILE_NAME = "file_example_MP3_700KB.mp3";
90-
const RESULT_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
91-
try {
92-
const pdfApi = new PdfApi(credentials.id, credentials.key);
93-
let buffer = await fs.readFile(LOCAL_FILE_NAME);
94-
let uploadResult = await pdfApi.uploadFile(STORAGE_FILE_NAME, buffer);
95-
console.log(`Uploaded: ${uploadResult.body.errors.length === 0}`);
96-
buffer = await fs.readFile(LOCAL_ATTACHMENT_FILE_NAME);
97-
uploadResult = await pdfApi.uploadFile(STORAGE_ATTACHMENT_FILE_NAME, buffer);
98-
console.log(`Uploaded: ${uploadResult.body.errors.length === 0}`);
99-
100-
const attachment = new AttachmentInfo();
101-
attachment.name = STORAGE_ATTACHMENT_FILE_NAME;
102-
attachment.path = STORAGE_ATTACHMENT_FILE_NAME;
103-
attachment.description = "An example of MP3 file";
104-
attachment.mimeType = "audio/mpeg";
105-
106-
const appendResult = await pdfApi.postAddDocumentAttachment(STORAGE_FILE_NAME, attachment, null, null);
107-
108-
if (appendResult.body.code == 200) {
109-
const downloadResult = await pdfApi.downloadFile(STORAGE_FILE_NAME);
110-
await fs.writeFile(RESULT_FILE_NAME, downloadResult.body);
86+
const LOCAL_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
87+
const STORAGE_FILE_NAME = "sample_attachment.pdf";
88+
const LOCAL_ATTACHMENT_FILE_NAME = "C:\\Samples\\Attachments\\file_example_MP3_700KB.mp3";
89+
const STORAGE_ATTACHMENT_FILE_NAME = "file_example_MP3_700KB.mp3";
90+
const RESULT_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
91+
try {
92+
const pdfApi = new PdfApi(credentials.id, credentials.key);
93+
let buffer = await fs.readFile(LOCAL_FILE_NAME);
94+
let uploadResult = await pdfApi.uploadFile(STORAGE_FILE_NAME, buffer);
95+
console.log(`Uploaded: ${uploadResult.body.errors.length === 0}`);
96+
buffer = await fs.readFile(LOCAL_ATTACHMENT_FILE_NAME);
97+
uploadResult = await pdfApi.uploadFile(STORAGE_ATTACHMENT_FILE_NAME, buffer);
98+
console.log(`Uploaded: ${uploadResult.body.errors.length === 0}`);
99+
100+
const attachment = new AttachmentInfo();
101+
attachment.name = STORAGE_ATTACHMENT_FILE_NAME;
102+
attachment.path = STORAGE_ATTACHMENT_FILE_NAME;
103+
attachment.description = "An example of MP3 file";
104+
attachment.mimeType = "audio/mpeg";
105+
106+
const appendResult = await pdfApi.postAddDocumentAttachment(STORAGE_FILE_NAME, attachment, null, null);
107+
108+
if (appendResult.body.code == 200) {
109+
const downloadResult = await pdfApi.downloadFile(STORAGE_FILE_NAME);
110+
await fs.writeFile(RESULT_FILE_NAME, downloadResult.body);
111+
}
112+
else
113+
console.log("Unexpected error : can't download attachments");
114+
115+
} catch (error) {
116+
console.error(error.message);
111117
}
112-
else
113-
console.log("Unexpected error : can't download attachments");
114-
115-
} catch (error) {
116-
console.error(error.message);
117118
}
118-
}
119119
```
120120

121121
{{% /blocks/products/pf/agp/code-block %}}
122122

123+
{{% blocks/products/pf/agp/content h2="Work with the Attachments in PDF via Node.js SDK" %}}
124+
125+
Adding attachments to a PDF improves document organization, accessibility, and usability. It ensures all relevant files are stored in one place, streamlines workflows, enhances collaboration, and meets security and legal requirements, making it a valuable feature for business, legal, academic, and multimedia applications.
126+
Add the AcroForms into PDF documents with [Aspose.PDF Cloud Node.js SDK](https://products.aspose.cloud/pdf/nodejs/).
127+
128+
**With our Node.js library you can**
129+
130+
+ Add PDF document's header & footer in text or image format.
131+
+ Add tables & stamps (text or image) to PDF documents.
132+
+ Append multiple PDF documents to an existing file.
133+
+ Work with PDF attachments, annotations, & form fields.
134+
+ Apply encryption or decryption to PDF documents & set a password.
135+
+ Delete all stamps & tables from a page or entire PDF document.
136+
+ Delete a specific stamp or table from the PDF document by its ID.
137+
+ Replace single or multiple instances of text on a PDF page or from the entire document.
138+
+ Extensive support for converting PDF documents to various other file formats.
139+
+ Extract various elements of PDF files & make PDF documents optimized.
140+
+ You can try out our [free App](https://products.aspose.app/pdf/xfa) to add the AcroForms into PDF files online and test the functionality.
141+
142+
{{% /blocks/products/pf/agp/content %}}
143+
123144
{{< /blocks/products/pf/agp/feature-section >}}
124145

125146
{{< blocks/products/pf/agp/faq-item question="" answer="" >}}

pdf/nodejs/attachments/extract/_index.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ liveDemosLink="https://products.aspose.app/pdf/family/" PricingLink="https://pur
4040

4141
{{< blocks/products/pf/agp/feature-section isGrey="true" >}}
4242

43-
{{% blocks/products/pf/agp/feature-section-col title="Steps to extract attachments from PDF documents via Cloud Node.js SDK" %}}
43+
{{% blocks/products/pf/agp/feature-section-col title="Steps to extract attachments - Cloud Node.js" %}}
4444

4545
{{% blocks/products/pf/agp/text %}}
4646

@@ -84,46 +84,67 @@ It is easy to get started with Aspose.PDF Cloud Node.js SDK and there is nothing
8484
import { AttachmentInfo } from "asposepdfcloud/src/models/attachmentInfo.js";
8585

8686
async function getAllAttachments() {
87-
const LOCAL_PATH = "C:\\Samples\\";
88-
const LOCAL_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
89-
const STORAGE_FILE_NAME = "sample_attachment.pdf";
90-
try {
91-
const pdfApi = new PdfApi(credentials.id, credentials.key);
92-
const pdfData = await fs.readFile(LOCAL_FILE_NAME);
93-
await pdfApi.uploadFile(STORAGE_FILE_NAME, pdfData);
94-
95-
const result = await pdfApi.getDocumentAttachments(STORAGE_FILE_NAME);
96-
97-
if (result.body.code === 200 && result.body.attachments) {
98-
const attachmentList = result.body.attachments.list || [];
99-
if (!attachmentList.length) {
100-
console.error("No attachments found.");
101-
return;
102-
}
103-
104-
const downloadTasks = attachmentList.map(async (attachment) => {
105-
try {
106-
const attachmentUrl = attachment.links[0].href;
107-
const info = await pdfApi.getDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
108-
const download = await pdfApi.getDownloadDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
109-
await fs.writeFile(path.join(LOCAL_PATH, info.body.attachment.name), download.body);
110-
} catch (error) {
111-
console.error("Failed to download attachment:", error);
87+
const LOCAL_PATH = "C:\\Samples\\";
88+
const LOCAL_FILE_NAME = "C:\\Samples\\Attachments\\sample_attachment.pdf";
89+
const STORAGE_FILE_NAME = "sample_attachment.pdf";
90+
try {
91+
const pdfApi = new PdfApi(credentials.id, credentials.key);
92+
const pdfData = await fs.readFile(LOCAL_FILE_NAME);
93+
await pdfApi.uploadFile(STORAGE_FILE_NAME, pdfData);
94+
95+
const result = await pdfApi.getDocumentAttachments(STORAGE_FILE_NAME);
96+
97+
if (result.body.code === 200 && result.body.attachments) {
98+
const attachmentList = result.body.attachments.list || [];
99+
if (!attachmentList.length) {
100+
console.error("No attachments found.");
101+
return;
112102
}
113-
});
114103

115-
await Promise.all(downloadTasks);
116-
} else {
117-
console.error("Failed to retrieve attachments. Status:", result.statusCode);
104+
const downloadTasks = attachmentList.map(async (attachment) => {
105+
try {
106+
const attachmentUrl = attachment.links[0].href;
107+
const info = await pdfApi.getDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
108+
const download = await pdfApi.getDownloadDocumentAttachmentByIndex(STORAGE_FILE_NAME, attachmentUrl);
109+
await fs.writeFile(path.join(LOCAL_PATH, info.body.attachment.name), download.body);
110+
} catch (error) {
111+
console.error("Failed to download attachment:", error);
112+
}
113+
});
114+
115+
await Promise.all(downloadTasks);
116+
} else {
117+
console.error("Failed to retrieve attachments. Status:", result.statusCode);
118+
}
119+
} catch (error) {
120+
console.error("Error processing PDF attachments:", error);
118121
}
119-
} catch (error) {
120-
console.error("Error processing PDF attachments:", error);
121122
}
122-
}
123123
```
124124

125125
{{% /blocks/products/pf/agp/code-block %}}
126126

127+
{{% blocks/products/pf/agp/content h2="Work with the Attachments in PDF via Node.js SDK" %}}
128+
129+
Getting attachments from a PDF is essential for accessing supplementary content, improving workflow efficiency, ensuring compliance, and enhancing security. It helps users retrieve critical files, automate document processing, and optimize document management in business, legal, and technical applications.
130+
Get the AcroForms from PDF documents with [Aspose.PDF Cloud Node.js SDK](https://products.aspose.cloud/pdf/nodejs/).
131+
132+
**With our Node.js library you can**
133+
134+
+ Add PDF document's header & footer in text or image format.
135+
+ Add tables & stamps (text or image) to PDF documents.
136+
+ Append multiple PDF documents to an existing file.
137+
+ Work with PDF attachments, annotations, & form fields.
138+
+ Apply encryption or decryption to PDF documents & set a password.
139+
+ Delete all stamps & tables from a page or entire PDF document.
140+
+ Delete a specific stamp or table from the PDF document by its ID.
141+
+ Replace single or multiple instances of text on a PDF page or from the entire document.
142+
+ Extensive support for converting PDF documents to various other file formats.
143+
+ Extract various elements of PDF files & make PDF documents optimized.
144+
+ You can try out our [free App](https://products.aspose.app/pdf/xfa) to add the AcroForms into PDF files online and test the functionality.
145+
146+
{{% /blocks/products/pf/agp/content %}}
147+
127148
{{< /blocks/products/pf/agp/feature-section >}}
128149

129150
{{< blocks/products/pf/agp/faq-item question="" answer="" >}}

0 commit comments

Comments
 (0)