Attachments in PDF in .NET SDK
API for working with attachments in PDF documents with Aspose.PDF Cloud .NET SDK
Get StartedHow to extract or append attachments in PDF documents using C# Cloud API
For working with attachments in PDF documents, we’ll use
Aspose.PDF Cloud .NET SDK
This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open
NuGet
package manager, search for
Aspose.PDF Cloud
and install. You may also use the following command from the Package Manager Console: PM> Install-Package Aspose.Pdf-Cloud
Steps to extract attachments using .NET SDK
A basic extracting attachments programmatically with Aspose.PDF Cloud .NET SDK APIs can be done with just few lines of code.
- Upload the PDF file to cloud storage
- Retrieve the attachment by index
- Display the attachment name
This sample code shows extracting attachments of PDF document using C#
internal static void GetAllAttachments()
{
var STORAGE_FILE_NAME = "sample_attachment.pdf";
var LOCAL_FILE_NAME = @"C:\Samples\Attachments\sample_attachment.pdf";
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
using var file = File.OpenRead(LOCAL_FILE_NAME);
var uploadResult = pdfApi.UploadFile(STORAGE_FILE_NAME, file);
var attachmentsResponse = pdfApi.GetDocumentAttachments(STORAGE_FILE_NAME)
Console.WriteLine(JsonConvert.SerializeObject(attachmentsResponse.Attachments, Formatting.Indented));
}
internal static void GetSingleAttachments()
{
var STORAGE_FILE_NAME = "sample_attachment.pdf";
var LOCAL_FILE_NAME = @"C:\Samples\Attachments\sample_attachment.pdf";
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
using var file = File.OpenRead(LOCAL_FILE_NAME);
var uploadResult = pdfApi.UploadFile(STORAGE_FILE_NAME, file);
var attachmentsResponse = pdfApi.GetDocumentAttachmentByIndex(STORAGE_FILE_NAME, 1);
Console.WriteLine(JsonConvert.SerializeObject(attachmentsResponse.Attachment, Formatting.Indented));
}
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for .NET?
- Customers List
- Security