原創(chuàng)|其它|編輯:郝浩|2012-10-23 10:59:54.000|閱讀 2134 次
概述:如果要為PDF文件替換文本的話,您需要?jiǎng)?chuàng)建一個(gè)PdfContentEditor類的對(duì)象,并使用BindPdf方法綁定一個(gè)輸入PDF文件。然后調(diào)用ReplaceText方法。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
如果要為PDF文件替換文本的話,要用到Aspose.Pdf這個(gè)控件。首先您需要?jiǎng)?chuàng)建一個(gè)PdfContentEditor類的對(duì)象,并使用BindPdf方法綁定一個(gè)輸入PDF文件。然后調(diào)用ReplaceText方法。這個(gè)ReplaceText方法的負(fù)載接受兩個(gè)參數(shù):源字符串(替換字符串)和目標(biāo)字符串(被替換的字符串)。最后使用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")
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)