Bonjour ! Comment aller vous? (:
Pour commencer j'aimerais remercier cette communauté majoritairement agréable quand on ne poste pas de connerie xD
Cela fais maintenant 1 jour que je stagne sur un point... La documentation Itextsharp en vb.net. Sur votre site il y en a un super, mais pour du C#...
http://dotnet.developpez.com/articles/itextsharp/
J'ai bien essayer de prendre ce que je voulais et de le modifier mais certaine fonction ou mise en page du code sont différentes.
Actuelement j'ai ce type de tableau :
http://www.cjoint.com/doc/16_06/FFri...developpez.PNG
Et c'est bien sûr littéralement dégelasse !
J'aimerais plus aller vers ceci : (Ne faîte pas attention au cercle noir)
http://www.cjoint.com/doc/16_06/FFri...ncien-prog.PNG
Le problème c'est comme vous avez pu le voir dans ma première image, je n'ai pas définie la largeur de chaque colonne. Je pense que se serait déjà un bon début, puis par exemple définir une limite de hauteur de cellule... Je sais je demande la lune !
Du coup actuellement voici mon 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Private Sub Bt_calcul_Click(sender As System.Object, e As System.EventArgs) Handles Bt_calcul.Click
If Form4_Ticket.Dtgdv_ticket.ColumnCount = 0 Then
MsgBox("Veuillez choisir une entité et lancer une recherche svp")
Exit Sub
Else
Dim pdfTable As New PdfPTable(Form4_Ticket.Dtgdv_ticket.ColumnCount)
pdfTable.DefaultCell.Padding = 3
pdfTable.HorizontalAlignment = Element.ALIGN_CENTER
pdfTable.DefaultCell.NoWrap = True
For Each column As DataGridViewColumn In Form4_Ticket.Dtgdv_ticket.Columns
Dim cell As New PdfPCell(New Phrase(column.HeaderText))
cell.BackgroundColor = New iTextSharp.text.BaseColor(240, 240, 240)
pdfTable.AddCell(cell)
Next
Dim i As Integer = 0
For Each row As DataGridViewRow In Form4_Ticket.Dtgdv_ticket.Rows
If Not Form4_Ticket.Dtgdv_ticket.Rows.Count = i + 1 Then
For Each cell As DataGridViewCell In row.Cells
If Not cell.Value.ToString = vbNullString Then
Dim cellPDF As New PdfPCell(New Phrase(cell.Value.ToString()))
pdfTable.AddCell(cellPDF)
Else
Exit For
End If
Next
i = i + 1
Else
Exit For
End If
Next
Dim folderPath As String = "C:\Users\degecom\Desktop\PDF TEST"
If Not Directory.Exists(folderPath) Then
Directory.CreateDirectory(folderPath)
End If
Using stream As New FileStream(folderPath & "\test.pdf", FileMode.Create)
Dim pdfDoc As New Document(PageSize.A2, 10.0F, 10.0F, 10.0F, 0.0F)
PdfWriter.GetInstance(pdfDoc, stream)
pdfDoc.Open()
pdfDoc.Add(pdfTable)
pdfDoc.Close()
stream.Close()
End Using
AxAcroPDF1.src = "C:\Users\degecom\Desktop\PDF TEST\test.pdf"
End If
End Sub |
De plus quand j'essai de modifier la taille des bordures, donc par exemple je fais ça juste après la création du Header pour qu'il n'y est que le Header qui prenne c'est modification mais cela ne fonctionne pas quand même (Après test je peux mettre ceci partout ça ne change jamais rien)
pdfTable.DefaultCell.BorderWidth = 3
Voilà j'aimerais prendre la main sur mon tableau mais je ne vois pas de doc bien fournis en vb.net.
Je vous remercie par avance de vos réponses (:
Partager