| |
| ASP.NET |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<%@ Page Language="C#" MasterPageFile="~/tpl/Demo.Master" AutoEventWireup="true" CodeBehind="FillFields.aspx.cs" Inherits="Aspose.Pdf.Kit.Demos.FillFields"
Title="Fill Pdf Form Fields - Aspose.Pdf.Kit Demos" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<table width="90%" align="center" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="19"><img src="../../../../Common/images/heading_lft.jpg" alt="" width="19" height="41" /></td>
<td width="100%" class="demos-heading-bg"><h2 class="demos-heading-bg"> Fill PDF Form Fields - Aspose.Pdf.Kit</h2></td>
<td width="19"><img src="../../../../Common/images/heading_rt.jpg" alt="" width="19" height="41" /></td>
</tr>
<tr> </tr>
</table>
<p class="MsoNormal"><font size=2 face="Arial" ><span style="color:black" >This demo show how to <b> Fill form Fields</b> uisng Aspose.Pdf.Kit API.
<br><br>Using <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.form.fillfield_overloads.html> FillField </a>,<a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.form.fillimagefield_overloads.html> FillImageField </a>, <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.form.fillbarcodefield.html> FillBarcodeField </a> method in <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.form.html> Form </a> class of Aspose.Pdf.Kit component, developers can fill in form fields programmatically over Pdf document.
<br><br>
For more related information, please visit <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/how-to-fill-form-fields-with-api.html>How to Fill Form Fields With API? </a><br><br><br></span>
<p class="componentDescriptionTxt">
Click <b>Generate</b> to see how demo takes <a href="./resources/student.pdf">input PDF document</a>
and fills form fields, writing <a href="./resources/studentOut.pdf">resulting PDF document</a>.
</p>
<asp:Button ID="btnGeneratet" runat="server" Text="Generate" OnClick="btnGenerate_Click" />
<p><br><br><br><br><br><br><br><br><br></p>
</asp:Content>
|
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace Aspose.Pdf.Kit.Demos
{
public partial class FillFields : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnGenerate_Click(object sender, EventArgs e)
{
// input pdf file that contains form fields
string templatePdf = GetResource(@"student.pdf");
//Add a new HTML header and value to the response sent to the client
Response.AddHeader("content-disposition", "inline; filename=" + "studentOut.pdf");
// Specify the HTTP content type for response as Pdf
Response.ContentType = "application/pdf";
// call FillFields method of FormDemos class to fill the form fields over input pdf file
FormDemos.FillFields(GetResource(string.Empty), templatePdf, Response.OutputStream);
//end the processing of the current page to ensure that no other HTML content is sent
Response.End();
}
}
}
|
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
using System;
using System.IO;
using Aspose.Pdf.Kit;
namespace Aspose.Pdf.Kit.Demos
{
public class FormDemos
{
public FormDemos()
{
#if SITE_BUILD
// NOTE that in production you would want to call
// new License().SetLicense("path-to-license-file")
try
{
Aspose.Demos.Common.WebOperationsBridge.InitLicense(new License());
}catch
{
;
}
#endif
}
public static void FillFields(string path, string templatePdf, System.IO.Stream outputStream)
{
Form form = new Form(templatePdf, outputStream);
//Fill the field "Name" with "Mike".
form.FillField("Name","Mike");
//Choose the field "Gender" with "Male".
form.FillField("Gender","Male");
//Fill the field "Telephone".
form.FillField("Telephone","888.277.6734");
//Fill the field "Address".
form.FillField("Address","41, Lily Street, Hurstville, NSW, 2220 Australia ");
//Choose the item "GradeTwo" of the Combo field "Grade".
form.FillField("Grade","GradeTwo");
//use case for checking the checkbox "Lodging".
//form.FillField("Lodging","Yes");
//use case for unchecking the checkbox "Lodging".
form.FillField("Lodging","Off");
//Fill the image button field.
form.FillImageField("Photo", BasePage.GetResource(@"lovely.jpg"));
form.Save();
}
public static void ImportFdf(string templatePdf, string fdf,System.IO.Stream outputStream)
{
//Assign an input pdf file.
Form form = new Form(templatePdf, outputStream);
//Open an existed fdf file.
System.IO.FileStream fdfInputStream = new FileStream(fdf, FileMode.Open);
//Export all the pdf fields' value into the fdf file.
form.ImportFdf(fdfInputStream);
form.Save();
fdfInputStream.Close();
}
public static void ExportFdf(string templatePdf, System.IO.Stream outputStream)
{
//Assign an input pdf file.
Form form = new Form(templatePdf);
//Export all the pdf fields' value into the fdf file.
form.ExportFdf(outputStream);
}
public static void ImportXml(string templatePdf, string xml, System.IO.Stream outputStream)
{
//Assign an input pdf file.
Form form = new Form(templatePdf, outputStream);
//Open an existed fdf file.
System.IO.FileStream xmlInputStream = new FileStream(xml, FileMode.Open);
//Export all the pdf fields' value into the fdf file.
form.ImportXml(xmlInputStream);
form.Save();
xmlInputStream.Close();
}
public static void ExportXml(string templatePdf, System.IO.Stream outputStream)
{
//Assign an input pdf file.
Form form = new Form(templatePdf);
//Export all the pdf fields' value into the fdf file.
form.ExportXml(outputStream);
}
}
}
|
|
|
|