[VB.NET][1.1] Créer et remplir un fichier PDF dans code behind
Bonjour,
Pour un site web, je cherche à envoyer un mail avec une facture au format PDF en pièce jointe.
Pour cela j'ai besoin de créer et remplir un fichier PDF à partir du code behind ASP.NET.
Ma config : .Net Framwork 1.1 - Visual Studio 2003
:help:
[VB.NET]Créer et remplir un fichier PDF da
:) Merci pour votre aide
J'ai résolu mon problème en référençant la dll "itextsharp.dll" dans mon projet (dispo via le site http://itextsharp.sourceforge.net/ ).
On peut créer le Pdf dans le code behind :
Code:
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
|
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
...
Private Function ConstructionFacturePdf() As String
Dim doc As Document = New Document
Try
'on créé un fichier pdf ayant pour nom FNxxxxxx.pdf
PdfWriter.GetInstance(doc, New FileStream("FN00001.pdf", ileMode.Create))
'Ouverture
doc.Open()
'Expéditeur et destinataire
doc.Add(New Paragraph("Société X", FontFactory.GetFont("Verdana", 9, Font.BOLD)))
doc.Add(New Paragraph("12, rue des ajoncs", FontFactory.GetFont("Verdana", 9, Font.NORMAL)))
...
'Fermeture
doc.Close()
Catch de As DocumentException
Console.Error.WriteLine(de.Message)
Catch ioe As IOException
Console.Error.WriteLine(ioe.Message)
End Try
en sub |