原創(chuàng)|使用教程|編輯:郝浩|2013-04-07 13:48:58.000|閱讀 1233 次
概述:Document類提供了一個(gè)名為Form的集合,幫助用戶管理PDF文檔中的表格字段。添加一個(gè)表單字段,需要調(diào)用Form集合的Add方法。不過首先需要?jiǎng)?chuàng)建一個(gè)要添加到PDF文檔中的特定表格字段。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Document類提供了一個(gè)名為Form的集合,幫助用戶管理PDF文檔中的表格字段。添加一個(gè)表單字段,需要調(diào)用Form集合的Add方法。不過首先需要?jiǎng)?chuàng)建一個(gè)要添加到PDF文檔中的特定表格字段。
在這個(gè)例子中,我們選擇TextBoxField這個(gè)字段。您可以使用相同的方法添加任何表格字段:
首先,創(chuàng)建一個(gè)特定的字段類型對(duì)象,并設(shè)置其屬性。
然后,將該字段添加到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")
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)