文字查找和替換
您可以使用 IronPDF 的 Replace 在 PDF 中查找和替換文本。
如何在 C# 中替換 PDF 文本
- 安裝 IronPDF C# 庫以替換 PDF 中的文字
- 使用 C# 中的
FromFile方法載入現有的 PDF - 利用
ReplaceTextOnPage方法替換文字 - 將頁碼、舊文本和新文本輸入到方法中
- 導出包含新文本的 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")
您可以使用 IronPDF 的 Replace 在 PDF 中查找和替換文本。
FromFile 方法載入現有的 PDFReplaceTextOnPage方法替換文字30天試用密鑰立即獲取。
15天試用金鑰 立即可用。
不需要信用卡
您的試用金鑰應已發送至您的電子郵件。試用表格已
成功提交。
如果沒有收到,請聯絡
support@ironsoftware.com
免費開始
不需要信用卡
在生產環境中測試,無水印。
在任何需要的地方都能運行。
獲得 30 天的全功能產品。
在幾分鐘內上手運行。
試用產品期間完全訪問我們的支援工程團隊
預約30分鐘的個人演示。
無合約,無卡片信息,無承諾。

10 .NET API 產品適用於您的辦公文檔