This sample works for me
I hope this can help you
Code:
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="PdfSharp" %>
<%@ Import Namespace="PdfSharp.Pdf" %>
<%@ Import Namespace="PdfSharp.Drawing" %>
<html>
<head runat="server">
<title>Gabriel Diaz</title>
<script runat="server">
Sub Page_Load()
Dim document As PdfDocument = New PdfDocument
Dim page As PdfPage = document.AddPage
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
Const facename As String = "Verdana"
Dim options As New XPdfFontOptions(PdfFontEncoding.WinAnsi, PdfFontEmbedding.[Default])
Dim fontItalic As New XFont(facename, 20, XFontStyle.Underline & XFontStyle.Italic, options) 'here is the magic
gfx.DrawString("Hola", fontItalic, XBrushes.DarkSlateGray, 10, 100)
Dim stream As New MemoryStream()
document.Save(stream, False)
Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", stream.Length.ToString())
Response.BinaryWrite(stream.ToArray())
Response.Flush()
stream.Close()
Response.[End]()
End Sub
</script>
</head>
<body>
</body>
</html>