HTML JPG PDF XML DOCX
  Product Family
PDF

通过 .NET SDK 在 PDF 页脚中添加图像

使用 Aspose.PDF Cloud .NET SDK 在 PDF 文档的页脚中添加图像的 API

Get Started

如何使用 Cloud .NET SDK 在 PDF 文档的页脚中添加图像

为了在 PDF 文档的页脚中添加图像,我们将使用 Aspose.PDF Cloud .NET SDK 这个 Cloud SDK 帮助 .NET 程序员使用 C#、ASP.NET 或其他 .NET 语言为各种云平台开发基于云的 PDF 创建、注释、编辑和转换应用程序。打开 NuGet 包管理器,搜索 Aspose.PDF Cloud 并安装。您还可以使用包管理器控制台中的以下命令。

包管理器控制台命令


     
    PM> Install-Package Aspose.Pdf-Cloud
     

通过 .NET 在 PDF 页脚中添加图像的步骤

Aspose.PDF Cloud .NET 开发人员可以轻松在 PDF 文档的页脚中添加图像。开发人员只需几行代码。

  1. 使用您的应用程序密钥和密钥创建一个新的配置对象
  2. 创建一个对象以连接到 Cloud API
  3. 上传您的文档文件
  4. 上传您的本地图像文件作为页脚。
  5. 准备页脚设置。
  6. 调用 API 添加页脚。
  7. 检查响应并记录结果。
  8. 下载更新后的文件以供本地使用。
 

此示例代码演示如何使用 PDF Cloud .NET SDK 在 PDF 文档的页脚中添加图像


    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);
                }
            }
        }
    }
 

通过 .NET SDK 操作页脚

在 PDF 的页脚中添加图像可增强文档的品牌、安全性、美学和功能。这对于确保商业文件、报告、法律文件和营销材料的专业和结构良好的展示特别有价值。 使用 Aspose.PDF Cloud .NET SDK 将页脚添加到 PDF 文档中。

使用我们的 .NET SDK,您可以

  • 以文本或图像格式添加 PDF 文档的页眉和页脚。
  • 向 PDF 文档添加表格和文本或图像戳记。
  • 将多个 PDF 文档附加到现有文件。
  • 操作 PDF 附件、注释和表单字段。
  • 对 PDF 文档进行加密或解密并设置密码。
  • 删除页面或整个 PDF 文档的所有戳记和表格。
  • 按 ID 删除 PDF 文档中特定的戳记或表格。
  • 替换 PDF 页面或整个文档中的单个或多个文本实例。
  • 广泛支持将PDF文档转换为多种其他文件格式。
  • 提取PDF文件的各种元素并优化PDF文档。
  • 您可以尝试我们的免费应用来测试功能。

  •