HTML JPG PDF XML DOCX
  Product Family
PDF

Work with pages in PDF docuemnts via .NET SDK

API for working with pages in the PDF documents via .NET.

Get Started

Work with pages in PDF docuemnts. Most popular actions with Pages in .NET

How to work with Pages in the PDF documents using Cloud .NET SDK

In order to manipulate Pages in the PDF documents via Cloud .NET SDK , 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.

Package Manager Console Command


    PM> Install-Package Aspose.Pdf-Cloud
     

Steps to add image stamp to pages using .NET SDK

Aspose.PDF Cloud developers can easily load & append image stamp to pages of the PDF documents in just a few lines of code.

  1. Create a new Configuration object with your Application Secret and Key.
  2. Create an object to connect to the Cloud API.
  3. Uploads the PDF to cloud storage.
  4. Upload image file to cloud storage.
  5. Create an ImageStamp object with your settings.
  6. Perform append ImageStamp object to page of the PDF on cloud storage.
  7. Checks the response and logs the result.
  8. Downloads the updated file for local use.
 

This sample code shows adding image stamp on pages of the PDF document


    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace Pages
    {
        public class PagesAddImageStamp
        {
            public static async Task Append(string documentName, string outputName, int pageNumber, string imageFileName, float width, float height, string remoteFolder)
            {
		// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required). 
		pdfApi = new PdfApi(AppSecret, AppSid);

                using (var file = File.OpenRead(Path.Combine(localFolder, documentName)))
		{ // Upload the local PDF to cloud storage folder name.
                    FilesUploadResult uploadResponse = await pdfApi.UploadFileAsync(Path.Combine(remoteFolder, documentName), documentName);
                    Console.WriteLine(uploadResponse.Uploaded[0]);
                }
                using (var file = File.OpenRead(Path.Combine(localFolder, imageFileName)))
		{ // Upload the local image file to cloud storage folder name.
                    FilesUploadResult uploadImageResponse = await pdfApi.UploadFileAsync(Path.Combine(remoteFolder, imageFileName), imageFileName);
                    Console.WriteLine(uploadImageResponse.Uploaded[0]);
                }

                ImageStamp stamp = new ImageStamp(
                    Background: true,
                    HorizontalAlignment: HorizontalAlignment.Center,
                    VerticalAlignment: VerticalAlignment.Top,
                    Opacity: 0.3,
                    Rotate: Rotation.None,
                    RotateAngle: 45,
                    Width: width,
                    Height: height,
                    Zoom: 1,
                    FileName: Path.Combine(remoteFolder, imageFileName));

                // Append new image stamp to page of the PDF on cloud storage.
                AsposeResponse response = await pdfApi.PostPageImageStampsAsync(documentName, pageNumber, new List<ImageStamp> { stamp }, folder: remoteFolder);

                // Checks the response and logs the result.
                if (response == null)
                    Console.WriteLine("PagesAddImageStamp(): Unexpected error!");
                else if (response.Code < 200 || response.Code > 299)
                    Console.WriteLine("PagesAddImageStamp(): Failed to append image stamp to the page of document.");
                else
                { // Downloads the updated file for local use.
                    Console.WriteLine("PagesAddImageStamp(): image '{0}' appended as stamp to the page '{1}' of the document '{2}.", imageFileName, pageNumber, documentName);
                    Stream stream = pdfApi.DownloadFile(Path.Combine(remoteFolder, documentName));
                    using var fileStream = File.Create(Path.Combine(localFolder, "add_page_image_stamp_" + outputName));
                    stream.Position = 0;
                    await stream.CopyToAsync(fileStream);
                    Console.WriteLine("PagesAddImageStamp(): File '{0}' successfully downloaded.", "add_page_image_stamp_" + outputName);
                }
            }
        }
    }