01.
<%@ Import
Namespace
=
"PdfSharp"
%>
02.
<%@ Import
Namespace
=
"PdfSharp.Drawing"
%>
03.
<%@ Import
Namespace
=
"PdfSharp.Pdf"
%>
04.
<%@ Import
Namespace
=
"PdfSharp.Pdf.IO"
%>
05.
06.
<%@ Page Language=
"VB"
%>
07.
<script runat=
"server"
>
08.
Sub
Page_Load(sender
As
Object
, e
As
EventArgs)
09.
10.
Dim
DocPDF
As
PdfDocument =
New
PdfDocument
11.
12.
13.
Dim
objPage
As
PdfPage = DocPDF.AddPage
14.
15.
16.
Dim
gfx
As
XGraphics = XGraphics.FromPdfPage(objPage)
17.
18.
19.
Dim
font
As
XFont =
New
XFont(
"Verdana"
, 20, XFontStyle.Bold)
20.
21.
22.
gfx.DrawString(
" Hello, World!"
, font, XBrushes.Black, _
23.
New
XRect(0, 0, objPage.Width.Point, objPage.Height.Point), XStringFormats.TopCenter)
24.
25.
26.
gfx.DrawString(
"Welcome To www.ThaiCreate.Com"
, font, XBrushes.Black, _
27.
New
XRect(0, 0, objPage.Width.Point, objPage.Height.Point), XStringFormats.Center)
28.
29.
30.
gfx.DrawString(
"Version 2009"
, font, XBrushes.Black, _
31.
New
XRect(0, 0, objPage.Width.Point, objPage.Height.Point), XStringFormats.BottomCenter)
32.
33.
34.
Dim
FileName
As
String
=
"MyPDF/PdfDoc.pdf"
35.
DocPDF.Save(Server.MapPath(FileName))
36.
37.
DocPDF.Close()
38.
DocPDF =
Nothing
39.
40.
Me
.lblText.Text =
"PDF Created <a href="
& FileName &
">click here</a> to view"
41.
42.
End
Sub
43.
44.
</script>
45.
<html>
46.
<head>
47.
<title>ThaiCreate.Com ASP.NET - Send Mail</title>
48.
</head>
49.
<body>
50.
<form id=
"form1"
runat=
"server"
>
51.
<asp:Label id=
"lblText"
runat=
"server"
></asp:Label>
52.
</form>
53.
</body>
54.
</html>