| |
 |
Export Form values to XML - Aspose.Pdf.Kit |
 |
This demo shows, how to Export form Field values to XML document.
Using ExportXml method in Form class of Aspose.Pdf.Kit component, developers can export the values (data) of all of these form fields to a separate XML file.
For more related information, please visit Import and Export into XML
Click Export to see how demo exports values of PDF form from pdf document
into XML document enabling user to download results.
| 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
|
<%@ Page Language="C#" MasterPageFile="~/tpl/Demo.Master" AutoEventWireup="true" CodeBehind="ExportXml.aspx.cs" Inherits="Aspose.Pdf.Kit.Demos.ExportXml"
Title="Export Form values to XML - 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"> Export Form values to XML - 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> Export form Field</b> values to XML document.
<br><br>Using <a href=http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.form.exportxml.html> ExportXml </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 export the values (data) of all of these form fields to a separate XML 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-xml.html>Import and Export into XML </a><br><br><br></span>
<p class="componentDescriptionTxt">
Click <b>Export</b> to see how demo exports values of PDF form from <a href="./resources/studentOut.pdf">pdf document</a>
into XML document enabling user to download results.
</p>
<asp:Button ID="btnExport" runat="server" Text="Export" OnClick="btnExport_Click" />
<p><br><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 ExportXml : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnExport_Click(object sender, EventArgs e)
{
// input pdf file that contains form fields
string templatePdf = GetResource(@"studentOut.pdf");
//Add a new HTML header and value to the response sent to the client
Response.AddHeader("content-disposition", "inline; filename=" + "student.xml");
// Specify the HTTP content type for response as Pdf
Response.ContentType = "application/xml";
// call ExportXml method of FormDemos class to export values of pdf form fields to Xml file
FormDemos.ExportXml(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);
}
}
}
|
|
|
|