28-07-18, 08:19 PM
بالبداية انت بحاجة الى اضافة reference الى مشروعك حمله من النت PDFsharp Assemblies
وهذا مثال بسيط بعد ان يتم استدعاء النيم سبيس الخاصة
وهذا مثال بسيط بعد ان يتم استدعاء النيم سبيس الخاصة
PHP كود :
Imports System.IO
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
Try
Dim line As String
Dim readFile As System.IO.TextReader = New StreamReader("Text.txt")
Dim yPoint As Integer = 0
Dim pdf As PdfDocument = New PdfDocument
pdf.Info.Title = "Text File to PDF"
Dim pdfPage As PdfPage = pdf.AddPage
Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage)
Dim font As XFont = New XFont("Verdana", 20, XFontStyle.Regular)
While True
line = readFile.ReadLine()
If line Is Nothing Then
Exit While
Else
graph.DrawString(line, font, XBrushes.Black, _
New XRect(40, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
yPoint = yPoint + 40
End If
End While
Dim pdfFilename As String = "txttopdf.pdf"
pdf.Save(pdfFilename)
readFile.Close()
readFile = Nothing
Process.Start(pdfFilename)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class

