通过 C++ 处理 PDF 格式的邮票

使用 C++ API 使用 Aspose.PDF 进行冲压。

如何使用 C++ 库将图章添加到 PDF

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

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

将图章添加到 PDF 文档 C++


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

1.使用 “文档” 实例加载 PDF。 1.使用 Document.Info 属性获取文档信息。 1.访问并显示不同的 Document.Info 属性。

将图章添加到 PDF-C++。


    String _dataDir("C:\\Samples\\");

    // String for input file name
    String inputFileName("AddTextStamp.pdf");
    String outputFileName("AddTextStamp_out.pdf");

    // Open document
    auto document = MakeObject<Document>(_dataDir + inputFileName);

    // Create text stamp
    auto textStamp =MakeObject<TextStamp>(u"Sample Stamp");

    // Set whether stamp is background
    textStamp->set_Background(true);
    // Set origin
    textStamp->set_XIndent(100);
    textStamp->set_YIndent(100);
    // Rotate stamp
    textStamp->set_Rotate(Rotation::on90);

    // Set text properties
    textStamp->get_TextState()->set_Font(FontRepository::FindFont(u"Arial"));
    textStamp->get_TextState()->set_FontSize(14.0F);
    textStamp->get_TextState()->set_FontStyle(FontStyles::Bold);
    textStamp->get_TextState()->set_FontStyle(FontStyles::Italic);
    textStamp->get_TextState()->set_ForegroundColor(Color::get_Green());
    // Add stamp to particular page
    document->get_Pages()->idx_get(1)->AddStamp(textStamp);

    // Save output document
    document->Save(_dataDir + outputFileName);