PDF 文書編集ソリューション

無料のクロスプラットフォームアプリとAPIを使用して、PDFドキュメント内のコンテンツを検索して削除します

PDFファイルを編集する方法

PDF ファイルを編集するには、Aspose.PDF API を使用します。これは プラットフォーム用の機能豊富でパワフルで使いやすいドキュメント操作 API です。NuGet パッケージマネージャーを開き、AsPose.pdf を検索してインストールします。パッケージマネージャーコンソールから以下のコマンドを使用することもできます。

PDF 文書の編集


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

1。Document のインスタンスで PDF をロードします。 1。検索語を引数として TextFragmentAbsorber オブジェクトを作成します。 1。検索オプションを設定します。 1。収集した各フラグメントをループして編集します。 1。PDF ファイルを保存します。

PDF を編集-C#.


    Document doc = new Document(dataDir + "test.pdf");

    TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(searchTerm);
    TextSearchOptions textSearchOptions = new TextSearchOptions(true);
    textFragmentAbsorber.TextSearchOptions = textSearchOptions;

    doc.Pages.Accept(textFragmentAbsorber);
    TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
    foreach (TextFragment textFragment in textFragmentCollection)
{
    Page page = textFragment.Page;
    Rectangle annotationRectangle = textFragment.Rectangle;

    Annotations.RedactionAnnotation annot = new Annotations.RedactionAnnotation(page, annotationRectangle);
    annot.FillColor = Color.Black;
    doc.Pages[textFragment.Page.Number].Annotations.Add(annot, true);
    annot.Redact();
}
    doc.Save(dataDir + "output.pdf");