テキスト検索と置換
IronPDFのReplaceを使用して、PDF内のテキストを検索して置き換えることができます。
C#でPDFのテキストを置換する方法
- IronPDF C#ライブラリをインストールし、PDFのテキストを置換する。
- 既存のPDFをロードする
ファイルから
C# のメソッド - 活用する
ページ上のテキストを置き換える
テキストを置換するメソッド - メソッドに入力ページ番号、古いテキスト、新しいテキストを渡す
- 新しいテキストを含むPDFファイルをエクスポートする
using IronPdf; // Using an existing PDF var pdf = PdfDocument.FromFile("sample.pdf"); // Parameters const int pageIndex = 1; const string oldText = ".NET 6"; // Old text to remove const string newText = ".NET 7"; // New text to add // Replace Text on Page pdf.ReplaceTextOnPage(pageIndex, oldText, newText); // Save your new PDF pdf.SaveAs("new_sample.pdf");
Imports IronPdf ' Using an existing PDF Private pdf = PdfDocument.FromFile("sample.pdf") ' Parameters Private Const pageIndex As Integer = 1 Private Const oldText As String = ".NET 6" ' Old text to remove Private Const newText As String = ".NET 7" ' New text to add ' Replace Text on Page pdf.ReplaceTextOnPage(pageIndex, oldText, newText) ' Save your new PDF pdf.SaveAs("new_sample.pdf")
Install-Package IronPdf
IronPDFのReplaceを使用して、PDF内のテキストを検索して置き換えることができます。
ファイルから
C# のメソッドページ上のテキストを置き換える
テキストを置換するメソッド10 の .NET API 製品 オフィス文書用