Android Question Create Pdf and add an image centered on page

mike1967

Active Member
Licensed User
Longtime User
hello, i use this code for generate a pdf from panel screenshot :
code:
Sub WobbleMenu1_Tab4Click
    svList.Height=200%y
    Pannello.Height=200%y
    
    Dim filename As String="scheda.pdf"
    WobbleMenu1.SetVisible(False,False)
    Dim pdf As PdfDocument
    pdf.Initialize
    pdf.StartPage(595, 842) 'A4 size
    Dim bmp As B4XBitmap = Pannello.Snapshot
    Dim dest As Rect
    dest.Initialize(10, 10, 0, 0)
    dest.Width = bmp.Width / bmp.Scale
    dest.Height = bmp.Height / bmp.Scale
    pdf.Canvas.DrawBitmap(bmp, Null, dest)
    pdf.FinishPage
    Dim out As OutputStream = File.OpenOutput(provider.SharedFolder, filename, False)
    pdf.WriteToStream(out)
    out.Close
    pdf.Close
    svList.Height = 65%y
    Pannello.Height=100%y

    Dim in As Intent
    in.Initialize(in.ACTION_VIEW, "")
    provider.SetFileUriAsIntentData(in, filename)
    in.SetType("application/pdf")
    StartActivity(in)
    
    WobbleMenu1.SetVisible(True,True)
End Sub

How i can centered the image added to pdf ?
Thanks in advanced
 
Top