通过 C++ 在 PDF 文档中添加 Strikeout 注释

构建您自己的 C++ 应用程序,使用原生 API 操作文档文件中的注释和作者。

为了对 PDF 文件进行注释,我们将使用 Aspose.PDF for C++ API,这是一款适用于 C++ 平台的功能丰富、强大且易于使用的文档处理 API。打开 NuGet 软件包管理器,搜索 Aspose.pdf 然后安装。你也可以使用软件包管理器控制台中的以下命令。

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

通过 C++ 添加 Strikeout 注释


你需要 Aspose.PDF 才能在你的环境中试用代码。

  • 在文档类的实例中加载 PDF
  • 创建新页面或获取对现有页面的引用
  • 创建 Strikeout 注释
  • 调用 Page.Annotations 集合中的 Strikeout 注释方法 Add
  • 再次保存该文件

系统要求


所有主流操作系统都支持 C++ 的 Aspose.PDF。只要确保您具备以下先决条件即可。

  • 微软 Windows 或兼容 C++ 运行时环境的操作系统适用于 Windows 32 位、Windows 64 位和 Linux 64 位。
  • 微软 Visual Studio 等开发环境。
  • 在你的项目中引用的 C++ DLL 的 Aspose.PDF。

从 PDF 添加 Strikeout 注释-C++

Example

    // Load the PDF file
    Document document = new Document(System.IO.Path.Combine(_dataDir, "sample.pdf"));
    // This annotation is used to indicate the insertion of text
    var StrikeoutAnnotation1 = new StrikeoutAnnotation(document.Pages[1], new Rectangle(299.988, 713.664, 308.708, 720.769))
    {
        Title = "Aspose User",
        Subject = "Inserted text 1",
        Flags = AnnotationFlags.Print,
        Color = Color.Blue
    };
    document.Pages[1].Annotations.Add(StrikeoutAnnotation1);
    document.Save(System.IO.Path.Combine(_dataDir, "sample_Strikeout.pdf"));