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 32 33 34 35 36 37 38 39 40 41
|
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="itextsharp.text" %>
<%@ Import Namespace="itextsharp.text.pdf" %>
<script runat="server">
Protected Sub btnGeneratePDF_Click(ByVal sender As Object, ByVal e As EventArgs)
'Création d'un document
Dim myDocument = New Document()
'Ouverture d'un flux pour l'écriture sur le document
Dim fileS As New FileStream("C:\Documents and Settings\me\Bureau\fichier.pdf", FileMode.Create)
PdfWriter.GetInstance(myDocument, fileS)
'Ouverture du document
myDocument.Open()
'Ajout de la police
Dim bf = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, True)
Dim f2 As new iTextSharp.text.Font(bf, 24, iTextSharp.text.Font.NORMAL, Nothing)
'insertion texte arabe
Dim atext As New String("ص", 1)
myDocument.Add(New Phrase("hello world"))
'création d'un tableau
Dim tableau As New PdfPTable(1)
tableau.RunDirection=PdfWriter.RUN_DIRECTION_RTL
tableau.AddCell(new Phrase(10, atext, f2))
myDocument.Add(tableau)
'fermerture du document et du flux
myDocument.Close()
fileS.Close()
End Sub
</script>
<html>
<body>
<form id="Form1" runat="server">
<asp:Button id="button2" Text="Click me" runat="server" OnClick="btnGeneratePDF_Click" />
</form>
</body>
</html> |