| |
 |
Fill PDF Form using FDF - Aspose.Pdf.Kit |
 |
This demo shows, how to Fill form Fields by importing contents of FDF document.
Using ImportFdf method in Form class of Aspose.Pdf.Kit component, developers can import values from FDF file to fill form fields over Pdf document. Form class also offers ExportFdf method, to export the PDF Form Field's values into an FDF file.
For more related information, please visit Import and Export into FDF
Click Import to see how demo takes input PDF document
and fills its form fields by importing a FDF document. Results
of this operation can be donwloaded by user for review.
| 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="ImportFdf.aspx.cs" Inherits="Aspose.Pdf.Kit.Demos.ImportFdf"
Title="Fill Pdf Form using FDF - 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 using FDF - 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 shows, how to <b> Fill form Fields</b> by importing contents of FDF document.
<br><br>Using <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.form.importfdf.html> ImportFdf </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 import values from FDF file to fill form fields over Pdf document. Form class also offers <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.form.exportfdf.html> ExportFdf </a> method, to export the PDF Form Field's values into an FDF file.
<br><br>
For more related information, please visit <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/import-and-export-into-fdf.html>Import and Export into FDF </a><br><br></span>
<p class="componentDescriptionTxt">
Click <b>Import</b> to see how demo takes <a href="./resources/student.pdf">input PDF document</a>
and fills its form fields by importing a <a href="./resources/student.fdf">FDF document</a>. Results
of this operation can be donwloaded by user for review.
</p>
<asp:Button ID="btnImport" runat="server" Text="Import" OnClick="btnImport_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
40
|
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 ImportFdf : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnImport_Click(object sender, EventArgs e)
{
// input pdf file that contains form fields
string templatePdf = GetResource(@"student.pdf");
string fdf = GetResource(@"student.fdf");
//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 ImportFdf method of FormDemos class to fill the form fields with values from input fdf file
FormDemos.ImportFdf(templatePdf, fdf, 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);
}
}
}
|
|
|
|