The Code is as follows:
<% @ Import Namespace = "System" %>
<% @ Import Namespace = "System. IO" %>
<% @ Import Namespace = "System. Drawing" %>
<% @ Page language = "vb" %>
<Script runat = "server">
Dim FilePath As String = Server. MapPath ("FengEr.jpg ")
Sub Page_Load (Sender As Object, E As EventArgs)
Dim image As System. Drawing. Image = System. Drawing. Image. FromFile (FilePath)
Dim g As Graphics = Graphics. FromImage (image)
G. DrawImage (image, 0, 0, image. Width, image. Height)
Dim f As Font = new Font (" 文 ", 30)
Dim B As Brush = new SolidBrush (Color. Green)
Dim s As String = Request. QueryString ("Str ")
G. DrawString (s, f, B, 20,290)
Image. Save (Response. OutputStream, System. Drawing. Imaging. ImageFormat. Jpeg)
G. Dispose ()
Image. Dispose ()
End Sub
</Script>
You only need to save this code as An aspx file, such as Test. aspx. Put it in wwwroot (assuming your virtual directory is default ). Make another test.jpg image and print the text in the font "文" at (20,290. The call method is simple:
Http: // localhost/Test. aspx? Str = Dicky's Blog!
You can set the printing position, Font, and image files. In addition, if English is used as a parameter, it can be displayed normally, but Chinese characters cannot be displayed, because the web. config settings of Asp.net are incorrect and the following settings need to be performed:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<System. web>
<Globalization requestEncoding = "gb2312" responseEncoding = "gb2312" culture = "zh-CN" fileEncoding = "gb2312"/>
</System. web>
</Configuration>
In this way, it can be displayed normally.