原創(chuàng)|其它|編輯:郝浩|2012-10-23 10:59:54.000|閱讀 2134 次
概述:如果要為PDF文件替換文本的話,您需要創(chuàng)建一個PdfContentEditor類的對象,并使用BindPdf方法綁定一個輸入PDF文件。然后調用ReplaceText方法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
如果要為PDF文件替換文本的話,要用到Aspose.Pdf這個控件。首先您需要創(chuàng)建一個PdfContentEditor類的對象,并使用BindPdf方法綁定一個輸入PDF文件。然后調用ReplaceText方法。這個ReplaceText方法的負載接受兩個參數:源字符串(替換字符串)和目標字符串(被替換的字符串)。最后使用PdfContentEditor類的Save保存方法,保存新的PDF文件,下面是示例代碼
[C#]
//open input PDF PdfContentEditor pdfContentEditor = new PdfContentEditor(); pdfContentEditor.BindPdf("input.pdf"); //replace text on all pages pdfContentEditor.ReplaceText("Hello", "World"); //save output PDF pdfContentEditor.Save("ReplaceTextOnAllPages.pdf");
[VB.NET]
'open input PDF Dim pdfContentEditor As New PdfContentEditor() pdfContentEditor.BindPdf("input.pdf") 'replace text on all pages pdfContentEditor.ReplaceText("Hello", "World") 'save output PDF pdfContentEditor.Save("ReplaceTextOnAllPages.pdf")
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網