HTML JPG PDF XML DOCX
  Product Family
PDF

Thêm Hình Ảnh vào Chân Trang của PDF qua .NET SDK

API để thêm Hình Ảnh vào Chân Trang của tài liệu PDF với Aspose.PDF Cloud .NET SDK

Get Started

Cách thêm hình ảnh vào Chân Trang của tài liệu PDF bằng Cloud .NET SDK

Để thêm hình ảnh vào Chân Trang của tài liệu PDF, chúng ta sẽ sử dụng Aspose.PDF Cloud .NET SDK SDK Đám mây này hỗ trợ các lập trình viên .NET phát triển các ứng dụng tạo, chú thích, chỉnh sửa và chuyển đổi PDF trên đám mây bằng C#, ASP.NET, hoặc các ngôn ngữ .NET khác cho các nền tảng đám mây khác nhau. Mở NuGet trình quản lý gói, tìm kiếm Aspose.PDF Cloud và cài đặt. Bạn cũng có thể sử dụng lệnh sau từ Bảng Điều Khiển Quản Lý Gói.

Lệnh Bảng Điều Khiển Quản Lý Gói


     
    PM> Install-Package Aspose.Pdf-Cloud
     

Các bước để thêm hình ảnh vào Chân Trang của PDF qua .NET

Các nhà phát triển Aspose.PDF Cloud .NET có thể dễ dàng thêm hình ảnh vào Chân Trang của tài liệu PDF. Các nhà phát triển chỉ cần vài dòng mã.

  1. Tạo một đối tượng Cấu hình mới với Mật Khẩu và Khóa Ứng Dụng của bạn
  2. Tạo một đối tượng để kết nối với API Đám mây
  3. Tải lên tệp tài liệu của bạn
  4. Tải lên tệp hình ảnh cục bộ của bạn cho Chân Trang.
  5. Chuẩn bị Cài Đặt Chân Trang.
  6. Gọi API để Thêm Chân Trang.
  7. Kiểm tra phản hồi và ghi lại kết quả.
  8. Tải xuống tệp đã cập nhật để sử dụng cục bộ.
 

Đoạn mã mẫu này cho thấy cách thêm hình ảnh vào Chân Trang của tài liệu PDF sử dụng PDF Cloud .NET SDK


    using Aspose.Pdf.Cloud.Sdk.Api;
    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace Footers
    {
        public class FootersAddImage
        {
            public static async Task Append(string documentName, string outputName, string imageFileName, int startPage, int endPage, string localFolder, 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 uploadResponse = await pdfApi.UploadFileAsync(Path.Combine(remoteFolder, imageFileName), imageFileName);
                    Console.WriteLine(uploadResponse.Uploaded[0]);
                }

                // Create new Image Footer with input parameters for the PDF on cloud storage.
                ImageFooter footer = new ImageFooter(
                    Background: true,
                    LeftMargin: 1,
                    RightMargin: 2,
                    HorizontalAlignment: HorizontalAlignment.Center,
                    Opacity: 1,
                    Rotate: Rotation.None,
                    RotateAngle: 0,
                    XIndent: 0,
                    YIndent: 0,
                    Zoom: 1,
                    Width: 24,
                    Height: 24,
                    FileName: Path.Combine(remoteFolder, imageFileName)
                );

                // Append new Image Footer in the PDF on cloud storage.
                AsposeResponse response = await pdfApi.PostDocumentImageFooterAsync(documentName, footer, startPage, endPage, folder: remoteFolder);

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

Làm việc với Chân Trang thông qua .NET SDK

Thêm hình ảnh vào chân trang của PDF nâng cao thương hiệu tài liệu, bảo mật, thẩm mỹ và chức năng. Nó đặc biệt có giá trị cho các tài liệu kinh doanh, báo cáo, giấy tờ pháp lý, và tài liệu tiếp thị, đảm bảo một bài trình bày chuyên nghiệp và có cấu trúc tốt. Thêm Chân Trang vào tài liệu PDF với Aspose.PDF Cloud .NET SDK.

Với SDK .NET của chúng tôi bạn có thể

  • Thêm đầu & chân trang của tài liệu PDF ở định dạng văn bản hoặc hình ảnh.
  • Thêm bảng & tem văn bản hoặc hình ảnh vào tài liệu PDF.
  • Ghép nhiều tài liệu PDF vào một tệp hiện có.
  • Làm việc với các tệp đính kèm, chú thích, & trường biểu mẫu của PDF.
  • Áp dụng mã hóa hoặc giải mã cho tài liệu PDF & thiết lập mật khẩu.
  • Xóa tất cả các tem & bảng khỏi một trang hoặc toàn bộ tài liệu PDF.
  • Xóa một tem hoặc bảng cụ thể khỏi tài liệu PDF theo ID của nó.
  • Thay thế một hoặc nhiều lần xuất hiện của văn bản trên một trang PDF hoặc từ toàn bộ tài liệu.
  • Hỗ trợ mở rộng cho việc chuyển đổi tài liệu PDF sang nhiều định dạng tệp khác nhau.
  • Trích xuất các thành phần khác nhau của tệp PDF và tối ưu hóa tài liệu PDF.
  • Bạn có thể thử Ứng dụng miễn phí của chúng tôi để kiểm tra chức năng.

  •