Skip to content

Commit c5c05cf

Browse files
authored
Merge pull request #18 from aspose-pdf-cloud/Attachments-NodeJs-Python-Php
imlplemented-attachments-nodejs-python-php-v01
2 parents 70bf0f7 + 806bae8 commit c5c05cf

File tree

12 files changed

+1731
-0
lines changed

12 files changed

+1731
-0
lines changed

pdf/nodejs/attachments/_index.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
title: Extract, Append & Replace attachments in PDF documents via Aspose.Pdf Cloud Node.js SDK
3+
url: /nodejs/attachments/
4+
description: Sample code for extracting, appending and relpacing attachments in PDF document using Cloud Node.js SDK. Use API example code for working with attachments in PDF documents with Aspose.PDF Cloud Node.js SDK.
5+
lastmod: "2024-10-29"
6+
---
7+
8+
{{< blocks/products/pf/main-wrap-class isAutogenPage="true">}}
9+
{{< blocks/products/pf/upper-banner h1="Extract, Append & Replace attachments in PDF documents via Cloud Node.js SDK" h2="API for working with attachments in PDF documents with Aspose.PDF Cloud Node.js SDK" logoImageSrc="https://products.aspose.cloud/headers/aspose_pdf-for-node.svg" sourceAdditionalConversionTag="" additionalConversionTag="PDF" pfName="" subTitlepfName="" downloadUrl="" fileiconsmall1="HTML" fileiconsmall2="JPG" fileiconsmall3="PDF" fileiconsmall4="XML" fileiconsmall5="DOCX" >}}
10+
11+
{{< blocks/products/pf/main-container pfName="Aspose.PDF Cloud" subTitlepfName="Node.js SDK" >}}
12+
{{< blocks/products/pf/sub-menu logoImageSrc="https://products.aspose.cloud/sdk/aspose_pdf-for-node.svg"
13+
autoGeneratedVersion="true"
14+
liveDemosLink="https://products.aspose.app/pdf/family/" PricingLink="https://purchase.aspose.cloud/pricing" buyLink="" docsLink="https://docs.aspose.cloud/pdf" directDownloadLink="https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-node.js" >}}
15+
16+
{{% blocks/products/pf/agp/content h2="How to extract, append & replace attachments in PDF documents using Cloud Node.js SDK" %}}
17+
18+
For working with attachments in PDF documents, we'll use
19+
[Aspose.PDF Cloud Node.js SDK](https://products.aspose.cloud/pdf/nodejs/)
20+
This Cloud SDK SDK assists Node.js programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Node.js programming language via Aspose.PDF REST API. Open
21+
[NPM](https://www.npmjs.com/package/asposepdfcloud)
22+
package manager, search for
23+
Aspose.PDF Cloud,
24+
and install. You may also use the following command from the Package Manager Console.
25+
26+
{{% blocks/products/pf/agp/code-block title="Package Manager Console Command" offSpacer="true" %}}
27+
28+
```bash
29+
30+
 
31+
npm install asposepdfcloud --save
32+
 
33+
 
34+
35+
```
36+
37+
{{% /blocks/products/pf/agp/code-block %}}
38+
39+
{{% /blocks/products/pf/agp/content %}}
40+
41+
{{< blocks/products/pf/agp/feature-section isGrey="true" >}}
42+
43+
{{% blocks/products/pf/agp/feature-section-col title="Steps to update attachments in PDF documents via Cloud Node.js SDK" %}}
44+
45+
{{% blocks/products/pf/agp/text %}}
46+
47+
Aspose.PDF Cloud Node.js developers can easily extract, append & replace attachments in PDF documents. Developers need just a few lines of code.
48+
49+
{{% /blocks/products/pf/agp/text %}}
50+
51+
1. Load your Application Secret and Key from the JSON file or set credentials in another way
52+
1. Create an object to connect to the Cloud API
53+
1. Upload your document file
54+
1. Perform the extracting attachment actions for PDf document using one of the function getDocumentAttachments or getDocumentAttachmentByIndex or getDownloadDocumentAttachmentByIndex as shown in the next example
55+
1. Also you can perform extracting actions for PDF document using one of the function getDownloadDocumentAttachment or getDocumentFileAttachmentAnnotations or getDownloadDocumentAttachment or getDownloadDocumentAttachment
56+
1. To perform extracting actions for PDF documsnt page you can perform function getPageFileAttachmentAnnotations
57+
1. Perform the appending attachment actions for PDf document using postAddDocumentAttachment or perform appending attachments to page using postPageFileAttachmentAnnotations fumction
58+
1. Perform replacement attachment actions for PDF document using postPageFileAttachmentAnnotations or putFileAttachmentAnnotation or putFileAttachmentAnnotationDataExt
59+
1. Download the result if need it
60+
61+
{{% /blocks/products/pf/agp/feature-section-col %}}
62+
63+
{{% blocks/products/pf/agp/feature-section-col title="System Requirements" %}}
64+
65+
{{% blocks/products/pf/agp/text %}}
66+
67+
It is easy to get started with Aspose.PDF Cloud Node.js SDK and there is nothing to install. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud Node.js SDK.
68+
69+
* CPU: 1GHz
70+
* RAM: 512Mb
71+
* Free space on disk: 20Mb
72+
* Any OS Microsoft Windows, Mac OS, Linux x32/x64
73+
* node.js v4.8 or higher
74+
75+
{{% /blocks/products/pf/agp/text %}}
76+
77+
{{% /blocks/products/pf/agp/feature-section-col %}}
78+
79+
{{% blocks/products/pf/agp/code-block title="This sample code shows extracting attachments of PDF document using PDF Cloud Node.js SDK" offSpacer="" %}}
80+
81+
```js
82+
const fs = require("fs");
83+
const credentials = require("./credentials.json");
84+
const { PdfApi } = require("asposepdfcloud");
85+
const { ImageTemplatesRequest } = require("asposepdfcloud/src/models/imageTemplatesRequest");
86+
const { ImageTemplate } = require("asposepdfcloud/src/models/imageTemplate");
87+
const { ImageSrcType } = require("asposepdfcloud/src/models/imageSrcType");
88+
89+
// Load your Application Secret and Key from the JSON file or set credentials in another way
90+
import * as BaseTest from "./baseTestPdfApi";
91+
import "mocha";
92+
var assert = require('assert');
93+
94+
describe("Attachments Tests", () => {
95+
96+
const name = "PdfWithEmbeddedFiles.pdf";
97+
const attachmentIndex = 1;
98+
99+
before( async ()=> {
100+
await BaseTest.uploadFile(name);
101+
});
102+
103+
describe("GetDocumentAttachmentByIndex Test", () => {
104+
105+
it("should return response with code 200", async () => {
106+
107+
return BaseTest.getPdfApi().getDocumentAttachmentByIndex(name, attachmentIndex, null, BaseTest.remoteTempFolder)
108+
.then((result) => {
109+
assert.equal(result.response.statusCode, 200);
110+
});
111+
});
112+
});
113+
114+
describe("GetDocumentAttachments Test", () => {
115+
116+
it("should return response with code 200", async () => {
117+
118+
return BaseTest.getPdfApi().getDocumentAttachments(name, null, BaseTest.remoteTempFolder)
119+
.then((result) => {
120+
assert.equal(result.response.statusCode, 200);
121+
});
122+
});
123+
});
124+
125+
describe("GetDownloadDocumentAttachmentByIndex Test", () => {
126+
127+
it("should return response with code 200", async () => {
128+
129+
return BaseTest.getPdfApi().getDownloadDocumentAttachmentByIndex(name, attachmentIndex, null, BaseTest.remoteTempFolder)
130+
.then((result) => {
131+
assert.equal(result.response.statusCode, 200);
132+
});
133+
});
134+
});
135+
});
136+
```
137+
138+
{{% /blocks/products/pf/agp/code-block %}}
139+
140+
{{< /blocks/products/pf/agp/feature-section >}}
141+
142+
{{< blocks/products/pf/agp/faq-item question="" answer="" >}}
143+
144+
<!-- aboutfile Starts -->
145+
146+
{{< blocks/products/pf/agp/democard icon="fa-cogs" text=" No need to download or setup anything." >}}
147+
{{< blocks/products/pf/agp/democard icon="fa-edit" text=" No need to write any code." >}}
148+
{{< blocks/products/pf/agp/democard icon="fa-file-text" text=" Just upload your BMP file and hit the \"Convert\" button." >}}
149+
{{< blocks/products/pf/agp/democard icon="fa-download" text=" You will instantly receive a link to download the result." >}}
150+
151+
{{% blocks/products/pf/agp/content h3="About Aspose.PDF Cloud Node.js SDK" %}}
152+
153+
Aspose.PDF Cloud is a true REST API that enables you to perform a wide range of document processing operations including creation, manipulation, conversion and rendering of PDF documents in the cloud.
154+
155+
{{% /blocks/products/pf/agp/content %}}
156+
157+
{{< blocks/products/pf/agp/about-file-section >}}
158+
159+
{{< /blocks/products/pf/agp/about-file-text >}}
160+
161+
{{< blocks/products/pf/agp/about-file-text fileFormat="PDF" readMoreLink="https://docs.fileformat.com/view/pdf/" >}}
162+
Portable Document Format (PDF) is a type of document created by Adobe back in 1990s. The purpose of this file format was to introduce a standard for representation of documents and other reference material in a format that is independent of application software, hardware as well as Operating System. PDF files can be opened in Adobe Acrobat Reader/Writer as well in most modern browsers like Chrome, Safari, Firefox via extensions/plug-ins. Most of the commercially available software suites also offer conversion of their documents to PDF file format without the requirement of any additional software component. Thus, PDF file format has full capability to contain information like text, images, hyperlinks, form-fields, rich media, digital signatures, attachments, metadata, Geospatial features and 3D objects in it that can become as part of source document.
163+
164+
{{< /blocks/products/pf/agp/about-file-text >}}
165+
166+
{{< /blocks/products/pf/agp/about-file-section >}}
167+
168+
{{< /blocks/products/pf/agp/demobox >}}
169+
170+
<!-- aboutfile Ends -->
171+
172+
{{< /blocks/products/pf/main-container >}}
173+
174+
{{< /blocks/products/pf/main-wrap-class >}}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
title: Append attachments in PDF documents via Aspose.Pdf Cloud Node.js SDK
3+
url: /nodejs/attachments/
4+
description: Sample code for appending attachments in PDF document using Cloud Node.js SDK. Use API example code for working with attachments in PDF documents with Aspose.PDF Cloud Node.js SDK.
5+
lastmod: "2024-10-29"
6+
---
7+
8+
{{< blocks/products/pf/main-wrap-class isAutogenPage="true">}}
9+
{{< blocks/products/pf/upper-banner h1="Append attachments in PDF documents via Cloud Node.js SDK" h2="API for working with attachments in PDF documents with Aspose.PDF Cloud Node.js SDK" logoImageSrc="https://products.aspose.cloud/headers/aspose_pdf-for-node.svg" sourceAdditionalConversionTag="" additionalConversionTag="PDF" pfName="" subTitlepfName="" downloadUrl="" fileiconsmall1="HTML" fileiconsmall2="JPG" fileiconsmall3="PDF" fileiconsmall4="XML" fileiconsmall5="DOCX" >}}
10+
11+
{{< blocks/products/pf/main-container pfName="Aspose.PDF Cloud" subTitlepfName="Node.js SDK" >}}
12+
{{< blocks/products/pf/sub-menu logoImageSrc="https://products.aspose.cloud/sdk/aspose_pdf-for-node.svg"
13+
autoGeneratedVersion="true"
14+
liveDemosLink="https://products.aspose.app/pdf/family/" PricingLink="https://purchase.aspose.cloud/pricing" buyLink="" docsLink="https://docs.aspose.cloud/pdf" directDownloadLink="https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-node.js" >}}
15+
16+
{{% blocks/products/pf/agp/content h2="How to append attachments in PDF documents using Cloud Node.js SDK" %}}
17+
18+
For working with attachments in PDF documents, we'll use
19+
[Aspose.PDF Cloud Node.js SDK](https://products.aspose.cloud/pdf/nodejs/)
20+
This Cloud SDK SDK assists Node.js programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Node.js programming language via Aspose.PDF REST API. Open
21+
[NPM](https://www.npmjs.com/package/asposepdfcloud)
22+
package manager, search for
23+
Aspose.PDF Cloud,
24+
and install. You may also use the following command from the Package Manager Console.
25+
26+
{{% blocks/products/pf/agp/code-block title="Package Manager Console Command" offSpacer="true" %}}
27+
28+
```bash
29+
30+
 
31+
npm install asposepdfcloud --save
32+
 
33+
 
34+
35+
```
36+
37+
{{% /blocks/products/pf/agp/code-block %}}
38+
39+
{{% /blocks/products/pf/agp/content %}}
40+
41+
{{< blocks/products/pf/agp/feature-section isGrey="true" >}}
42+
43+
{{% blocks/products/pf/agp/feature-section-col title="Steps to append attachments in PDF documents via Cloud Node.js SDK" %}}
44+
45+
{{% blocks/products/pf/agp/text %}}
46+
47+
Aspose.PDF Cloud Node.js developers can easily append attachments in PDF documents. Developers need just a few lines of code.
48+
49+
{{% /blocks/products/pf/agp/text %}}
50+
51+
1. Load your Application Secret and Key from the JSON file or set credentials in another way
52+
1. Create an object to connect to the Cloud API
53+
1. Upload your document file
54+
1. Perform the appending attachment actions for PDf document using postAddDocumentAttachment or perform appending attachments to page using postPageFileAttachmentAnnotations fumction
55+
1. Download the result if need it
56+
57+
{{% /blocks/products/pf/agp/feature-section-col %}}
58+
59+
{{% blocks/products/pf/agp/feature-section-col title="System Requirements" %}}
60+
61+
{{% blocks/products/pf/agp/text %}}
62+
63+
It is easy to get started with Aspose.PDF Cloud Node.js SDK and there is nothing to install. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud Node.js SDK.
64+
65+
* CPU: 1GHz
66+
* RAM: 512Mb
67+
* Free space on disk: 20Mb
68+
* Any OS Microsoft Windows, Mac OS, Linux x32/x64
69+
* node.js v4.8 or higher
70+
71+
{{% /blocks/products/pf/agp/text %}}
72+
73+
{{% /blocks/products/pf/agp/feature-section-col %}}
74+
75+
{{% blocks/products/pf/agp/code-block title="This sample code shows append file attachment annotation to PDF document using PDF Cloud Node.js SDK" offSpacer="" %}}
76+
77+
```js
78+
const { PdfApi } = require("asposepdfcloud");
79+
const { PdfAType } = require("asposepdfcloud/src/models/fieldType");
80+
81+
82+
pdfApi = new PdfApi("client-application-key", "client=application-secret");
83+
84+
console.log('running example');
85+
86+
const attachment = new AttachmentInfo();
87+
attachment.name = "my-attachment-name"; // need to replace with real file name
88+
attachment.path = "my-attachment-file-path"; // need to replace with real file path
89+
attachment.description = "my-attachment-description"; // need to replace with real description
90+
attachment.mimeType = "type/subtype"; // need to replace with real MIME type
91+
92+
pdfApi.postAddDocumentAttachment ("PdfWithAnttachments.pdf", attachment, null, null)
93+
.then((result) => {
94+
console.log(result.response);
95+
});
96+
```
97+
98+
{{% /blocks/products/pf/agp/code-block %}}
99+
100+
{{< /blocks/products/pf/agp/feature-section >}}
101+
102+
{{< blocks/products/pf/agp/faq-item question="" answer="" >}}
103+
104+
<!-- aboutfile Starts -->
105+
106+
{{< blocks/products/pf/agp/democard icon="fa-cogs" text=" No need to download or setup anything." >}}
107+
{{< blocks/products/pf/agp/democard icon="fa-edit" text=" No need to write any code." >}}
108+
{{< blocks/products/pf/agp/democard icon="fa-file-text" text=" Just upload your PDF file." >}}
109+
{{< blocks/products/pf/agp/democard icon="fa-download" text=" You will instantly receive a link to download the result." >}}
110+
111+
{{% blocks/products/pf/agp/content h3="About Aspose.PDF Cloud Node.js SDK" %}}
112+
113+
Aspose.PDF Cloud is a true REST API that enables you to perform a wide range of document processing operations including creation, manipulation, conversion and rendering of PDF documents in the cloud.
114+
115+
{{% /blocks/products/pf/agp/content %}}
116+
117+
{{< blocks/products/pf/agp/about-file-section >}}
118+
119+
{{< /blocks/products/pf/agp/about-file-text >}}
120+
121+
{{< blocks/products/pf/agp/about-file-text fileFormat="PDF" readMoreLink="https://docs.fileformat.com/view/pdf/" >}}
122+
Portable Document Format (PDF) is a type of document created by Adobe back in 1990s. The purpose of this file format was to introduce a standard for representation of documents and other reference material in a format that is independent of application software, hardware as well as Operating System. PDF files can be opened in Adobe Acrobat Reader/Writer as well in most modern browsers like Chrome, Safari, Firefox via extensions/plug-ins. Most of the commercially available software suites also offer conversion of their documents to PDF file format without the requirement of any additional software component. Thus, PDF file format has full capability to contain information like text, images, hyperlinks, form-fields, rich media, digital signatures, attachments, metadata, Geospatial features and 3D objects in it that can become as part of source document.
123+
124+
{{< /blocks/products/pf/agp/about-file-text >}}
125+
126+
{{< /blocks/products/pf/agp/about-file-section >}}
127+
128+
{{< /blocks/products/pf/agp/demobox >}}
129+
130+
<!-- aboutfile Ends -->
131+
132+
{{< /blocks/products/pf/main-container >}}
133+
134+
{{< /blocks/products/pf/main-wrap-class >}}

0 commit comments

Comments
 (0)