iOS Question PDF problem with label text

kisoft

Well-Known Member
Licensed User
Longtime User
I create a PDF document with this code.
B4X:
    Dim cvs As Canvas
    cvs.InitializePDF(File.DirDocuments, "1.pdf", 612, 792)
    cvs.DrawColor(Colors.White)
    Dim lbl As Label
    lbl.Initialize("")
    lbl.SetLayoutAnimated(0, 1, 0, 0,100, 300)
    lbl.Multiline = True
    lbl.TextColor = Colors.Black
    lbl.Text ="gfsdsfgdgdgsdgfdsgsdgdsgdsgdskgdsklgjdfslkdsjlkdslkdslkdskdskljskldskldskldsklgskldgsldkfgjkldsffgjfsldkgjskldgjsldkgjslkgjsklgjsk"
    
    Dim r As Rect
    r.Initialize(10, 10, 110, 310)
    cvs.DrawView(lbl, r)
    
    cvs.Release
    WKWebView1.LoadUrl("file://" & File.Combine(File.DirDocuments, "1.pdf"))
 
    Dim avc As ActivityViewController
    avc.Initialize("avc", Array(CreateFileUrl(File.DirDocuments, "1.pdf")))
    avc.Show(pg4, pg4.RootPanel)
However, I get this result
 

Attachments

  • test.png
    test.png
    68.7 KB · Views: 227

kisoft

Well-Known Member
Licensed User
Longtime User
I would like the PDF file to be in A4 format. I set it as in the code below and the effect seems to be correct.
B4X:
    Dim cvs As Canvas
'    cvs.InitializePDF(File.DirDocuments, "1.pdf", 612, 792)
    cvs.InitializePDF(File.DirDocuments, "1.pdf", 595, 842) ' size format A4
    cvs.DrawColor(Colors.White)
    Dim lbl As Label
    lbl.Initialize("")
    lbl.SetLayoutAnimated(0, 1, 0, 0, 595, 842)
    lbl.Multiline = True
    lbl.TextColor = Colors.Black
    lbl.Font=Font.CreateNew(10)
    lbl.Text = "text"
   
    Dim r As Rect
    r.Initialize(30,0,565,820)
    cvs.DrawView(lbl, r)
    cvs.Release
    WKWebView1.LoadUrl("file://" & File.Combine(File.DirDocuments, "1.pdf"))
    Dim avc As ActivityViewController
    avc.Initialize("avc", Array(CreateFileUrl(File.DirDocuments, "1.pdf")))
    avc.Show(pg4, pg4.RootPanel)
 
Upvote 0
Top