IRONSOFTWAREHOME
文字搜尋與替換
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
Dim pdf = PdfDocument.FromFile("sample.pdf")

' Parameters
Const pageIndex As Integer = 1
Const oldText As String = ".NET 6" ' Old text to remove
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")
NuGet Download
PM > Install-Package IronPdf
文字搜尋與替換

文字搜尋與替換

您可以使用 IronPdf 的 Replace 功能在 PDF 文件中搜尋並替換文字。

此程式碼示範如何使用 C# 中的 IronPDF 函式庫,在 PDF 檔案中替換文字。 首先,請確保您已透過 NuGet 安裝 IronPDF 函式庫。 該程式碼透過 FromFile 方法載入現有 PDF 檔案,使用 ReplaceTextOnPage 替換指定頁面的文字,並將結果儲存為新的 PDF 檔案。需指定頁碼、待替換的文字以及新文字。 最後,變更會以 SaveAs 標記儲存,並 PRINT 訊息以確認操作已完成。

學習如何使用 IronPDF 在 PDF 中尋找與替換文字
在 GitHub 上查看

準備開始了嗎?

Nuget Downloads 20,756,830版本:2026.7剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費現場演示
Booking Badge

受到全球數百萬工程師的信任

Iron Software的客戶標誌
獲取您的無義務諮詢
填寫以下表格或電子郵件sales@ironsoftware.com
您的詳細資訊將始終保密
受到全球數百萬工程師的信任
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立