Creating PDF files
using PDF sharp
Form1
Design a form with a textbox and a command button
Add the following dll to your project,
- PdfSharp.Charting.dll
- PdfSharp.dll
- PdfSharp.resources.dll
VB
CODE
Imports PdfSharp
Imports
PdfSharp.Drawing
Imports
PdfSharp.Pdf
Public Class Form1
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pdf
As PdfDocument = New
PdfDocument
Dim
pdfPage As PdfPage = pdf.AddPage
Dim
graph As XGraphics =
XGraphics.FromPdfPage(pdfPage)
Dim
font As XFont = New
XFont("Times New Roman", 12,
XFontStyle.Regular)
graph.DrawString(TextBox1.Text, font,
XBrushes.Chocolate, _
New
XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
Dim
pdfFilename As String
= "firstpage.pdf"
pdf.Save(pdfFilename)
Process.Start(pdfFilename)
End Sub
End Class
No comments:
Post a Comment