Private Sub ButtonEnvoyer_Click
env.CheckAndRequest(env.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
CustomListView1.sv.Height=3000dip
Dim bmp As B4XBitmap=CustomListView1.sv.Snapshot
pdf.Initialize
pdf.StartPage(595, 3500) 'A4 size
Dim Bitmap1 As Bitmap
Bitmap1.Initialize(File.DirAssets,"logoR.png")
Dim DestRect As Rect
DestRect.Initialize(10, 10, 500, 139)
pdf.Canvas.DrawBitmap(Bitmap1, Null, DestRect)
pdf.Canvas.DrawText("Anomalie(s) de ronde:", 270, 190, Typeface.DEFAULT_BOLD, 20 / GetDeviceLayoutValues.Scale , Colors.Black, "CENTER")
' Ajouter le texte de l'EditText au PDF
' Récupérer le texte du TextEdit
Dim text As String = ACEditText1.Text
' Diviser le texte en utilisant la regex "\s{10}"
Dim lines() As String = Regex.Split(CRLF, text)
pdf.Canvas.DrawText(lines, 300, 220, Typeface.DEFAULT, 14 / GetDeviceLayoutValues.Scale, Colors.Black, "CENTER")
pdf.Canvas.DrawText("Ronde Salle de Lecture:", 270, 250, Typeface.DEFAULT_BOLD, 20 / GetDeviceLayoutValues.Scale , Colors.Black, "CENTER")
DestRect.Initialize(110, 270, 0, 0)
DestRect.Width = bmp.Width / bmp.Scale
DestRect.Height = bmp.Height / bmp.Scale
pdf.Canvas.DrawBitmap(bmp, Null, DestRect)
pdf.FinishPage
Dim OrigFormat As String=DateTime.DateFormat 'save orig date format
DateTime.DateFormat="dd MMM yyyy"
Dim MyDate As String=DateTime.Date(DateTime.Now)
'CheckBox
Dim Periode As String
Periode=""
If CheckBox1.Checked=True Then
Periode="AM"
Else If CheckBox2.Checked=True Then
Periode="PM"
End If
Dim DateSelect As String=btnDate.xLBL.Text
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "Ronde Salle de Lecture - " & DateSelect & " - " & Periode & ".pdf", False)
pdf.WriteToStream(out)
out.Close
pdf.Close
Dim FileName As String = "Ronde Salle de Lecture - " & DateSelect & " - " & Periode & ".pdf"
'copy the shared file to the shared folder
DateTime.DateFormat=OrigFormat 'return to orig date format
File.Copy(File.DirRootExternal, FileName, Starter.Provider.SharedFolder, FileName)
Dim email As Email
email.To.Add("mail@mail.com")
email.Subject = "Ronde Salle de Lecture"
email.Attachments.Add(Starter.Provider.GetFileUri(FileName))
Dim in As Intent = email.GetIntent
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
StartActivity(in)
End If
End Sub