01.
<%@ Import Namespace=
"PdfSharp"
%>
02.
<%@ Import Namespace=
"PdfSharp.Drawing"
%>
03.
<%@ Import Namespace=
"PdfSharp.Pdf"
%>
04.
<%@ Import Namespace=
"PdfSharp.Pdf.IO"
%>
05.
06.
<%@ Page Language=
"C#"
Debug=
"true"
%>
07.
<script runat=
"server"
>
08.
void
Page_Load(Object sender, EventArgs e)
09.
{
10.
11.
PdfDocument DocPDF =
new
PdfDocument();
12.
13.
14.
PdfPage objPage = DocPDF.AddPage();
15.
16.
17.
XGraphics gfx = XGraphics.FromPdfPage(objPage);
18.
19.
20.
XFont font1 =
new
XFont(
"Verdana"
, 20, XFontStyle.Bold);
21.
XFont font2 =
new
XFont(
"Tahoma"
, 8, XFontStyle.Bold);
22.
23.
24.
gfx.DrawString(
" Welcome To www.ThaiCreate.Com"
, font1, XBrushes.Black,
25.
new
XRect(0, 50, objPage.Width.Point, objPage.Height.Point), XStringFormats.TopCenter);
26.
27.
String strString =
"STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING"
;
28.
29.
gfx.DrawString(strString, font2, XBrushes.Black, 65, 80, XStringFormats.TopLeft);
30.
31.
gfx.DrawString(strString, font2, XBrushes.Black, 65, 90, XStringFormats.TopLeft);
32.
33.
gfx.DrawString(strString, font2, XBrushes.Black, 65, 100, XStringFormats.TopLeft);
34.
35.
gfx.DrawString(strString, font2, XBrushes.Black, 65, 110, XStringFormats.TopLeft);
36.
37.
gfx.DrawString(strString, font2, XBrushes.Black, 65, 120, XStringFormats.TopLeft);
38.
39.
gfx.DrawString(strString, font2, XBrushes.Black, 65, 130, XStringFormats.TopLeft);
40.
41.
gfx.DrawString(strString, font2, XBrushes.Black, 65, 140, XStringFormats.TopLeft);
42.
43.
44.
String FileName =
"MyPDF/PdfDoc.pdf"
;
45.
DocPDF.Save(Server.MapPath(FileName));
46.
47.
DocPDF.Close();
48.
DocPDF =
null
;
49.
50.
this
.lblText.Text =
"PDF Created <a href="
+ FileName +
">click here</a> to view"
;
51.
52.
}
53.
54.
</script>
55.
<html>
56.
<head>
57.
<title>ThaiCreate.Com ASP.NET - Send Mail</title>
58.
</head>
59.
<body>
60.
<form id=
"form1"
runat=
"server"
>
61.
<asp:Label id=
"lblText"
runat=
"server"
></asp:Label>
62.
</form>
63.
</body>
64.
</html>