1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.IO
Public Class T_Test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btn_test_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_test.Click
'Création du PDF
Dim test = New Document(PageSize.A4, 50, 50, 25, 25)
Dim output = New FileStream(Server.MapPath("MyFirstPDF.pdf"), FileMode.Create)
Dim writer = PdfWriter.GetInstance(test, output)
'Ouverture du document pour écriture
test.Open()
' Création d'un paragraphe 'Hello World!'
Dim welcomeParagraph = New Paragraph("Hello World!")
' Ajout du paragraphe au document
test.Add(welcomeParagraph)
'Fermeture du document -A ne surtout pas oublier-
test.Close()
End Sub
End Class |