原創(chuàng)|使用教程|編輯:郝浩|2013-04-07 13:48:58.000|閱讀 1211 次
概述:Document類提供了一個名為Form的集合,幫助用戶管理PDF文檔中的表格字段。添加一個表單字段,需要調(diào)用Form集合的Add方法。不過首先需要創(chuàng)建一個要添加到PDF文檔中的特定表格字段。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Document類提供了一個名為Form的集合,幫助用戶管理PDF文檔中的表格字段。添加一個表單字段,需要調(diào)用Form集合的Add方法。不過首先需要創(chuàng)建一個要添加到PDF文檔中的特定表格字段。
在這個例子中,我們選擇TextBoxField這個字段。您可以使用相同的方法添加任何表格字段:
首先,創(chuàng)建一個特定的字段類型對象,并設置其屬性。
然后,將該字段添加到Form集合。
示例代碼:
C#
//Open document Document pdfDocument = new Document("input.pdf"); //Create a field TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100, 200, 300, 300)); textBoxField.PartialName = "textbox1"; textBoxField.Value = "Text Box"; //textBoxField.Border = new Border( Border border = new Border(textBoxField); border.Width = 5; border.Dash = new Dash(1, 1); textBoxField.Border = border; textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green); //Add field to the document pdfDocument.Form.Add(textBoxField, 1); //Save modified PDF pdfDocument.Save("output.pdf");VB.NET
'Open document Dim pdfDocument As New Document("input.pdf") 'Create a field Dim textBoxField As New TextBoxField(pdfDocument.Pages(1), New Aspose.Pdf.Rectangle(100, 200, 300, 300)) textBoxField.PartialName = "textbox1" textBoxField.Value = "Text Box" 'textBoxField.Border = new Border( Dim border As New Border(textBoxField) border.Width = 5 border.Dash = New Dash(1, 1) textBoxField.Border = border textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green) 'Add field to the document pdfDocument.Form.Add(textBoxField, 1) 'Save modified PDF pdfDocument.Save("output.pdf")
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網(wǎng)