C++ の PDF フォーマットを墨消し

Microsoft や Adobe PDF などのソフトウェアを使用せずに、サーバー側の Aspose.PDF for C++ API を使用して、ネイティブで高性能な PDF ドキュメントの機密編集情報。

C++ ライブラリを使ってPDFファイルを編集する方法

PDF ファイルを編集するために、cpp プラットフォーム用の機能豊富で強力で使いやすいドキュメント操作 API である Aspose.PDF for C++ API を使用します。NuGet パッケージマネージャーを開き、aspose.pdf を検索してインストールします。パッケージマネージャーコンソールから次のコマンドを使用することもできます。

C++ 経由でPDFドキュメントを墨消し


ご使用の環境でコードを試すには Aspose.PDF for C++ が必要です。

1.PDF を Document のインスタンスとともに読み込みます。 1.検索用語を引数として TextFragmentAbsorber オブジェクトを作成します。 1.[検索オプション] を設定します。 1.各フラグメントコレクションをループして編集します。 1.PDF ファイルを保存します。

PDFファイルを墨消し-C++。


    // Load PDF file
    auto pdfDocument = MakeObject<Document>(u"sourceFile.pdf");

    // Create TextAbsorber object to find all instances of the input search phrase
    auto textFragmentAbsorber = MakeObject<TextFragmentAbsorber>(u"Document");

    // Accept the absorber for all the pages
    pdfDocument->get_Pages()->Accept(textFragmentAbsorber);

    // Get the extracted text fragments
    auto textFragmentCollection = textFragmentAbsorber->get_TextFragments();

    // Loop through the fragments
    for (auto textFragment : textFragmentCollection){
        // Update text and other properties
        textFragment->set_Text(u"UPDATED TEXT");
        textFragment->get_TextState()->set_Font(FontRepository::FindFont(u"TimesNewRoman"));
        textFragment->get_TextState()->set_FontSize(22);
    }

    // Save the resulting PDF document.
    pdfDocument->Save(u"outputFile.pdf");