iOS Question canvas.drawview

Discussion in 'iOS Questions' started by Lyndon, Aug 4, 2018.

  1. Lyndon

    Lyndon Member Licensed User

    Hi I am trying to create a pdf with several layout items and later draw text from an sqlite.
    I am struggling to understand how to draw a multi line label to the canvas?

    Can I create the label with text in the designer, position the label,set visible to false, and then drawview that label to the canvas, using the left,top,height,bottom values for Rect, from the label properties in the designer ?

    The code below fails to draw the LblAddress label..

    Code:
    Dim rect As Rect
        logo = 
    LoadBitmap(File.DirAssets, "47A.png")
        pcvs.InitializePDF(
    File.DirDocuments, "3.pdf"612792)
        
    rect.Initialize(200,0,500,100)
        pcvs.DrawBitmap(logo, 
    rect)
        
    rect.Initialize(300,110,500,300)
        pcvs.DrawView(LblAddress,
    rect)
        pcvs.Release
    Thank you
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Lyndon

    Lyndon Member Licensed User

    Hi Erel and thanks for your reply, However I am still struggling, in the following code you will see I am trying as you suggested. I am trying to draw to a pdf file.
    Code:
    public Sub show
        page1.Initialize(
    "Page1")
        page1.Title = 
    "Create"
        page1.RootPanel.Color = 
    Colors.White
        page1.RootPanel.LoadLayout(
    "CreateQoute")
        Main.NavControl.ShowPage(page1)
        Main.NavControl.ToolBarVisible = 
    True
                                    
        
    DateTime.DateFormat = "dd/MM/yy"
        
    Dim rect As Rect
        logo = 
    LoadBitmap(File.DirAssets, "47A.png")
        pcvs.InitializePDF(
    File.DirDocuments, "3.pdf"612792)
        
    rect.Initialize(ImageView1.Left,ImageView1.Top,ImageView1.Width,ImageView1.Height)
        
    'rect.Initialize(0,0,Panel1.Width,Panel1.Height)
        pcvs.DrawBitmap(logo, rect )
        
    rect.Initialize(LblAddress.Left,LblAddress.Top,LblAddress.Width,LblAddress.Height)
        
    'pcvs.DrawView(Panel1,rect)
        Dim lbl As Label
        lbl.Initialize(
    "")
        lbl.Text = 
    " hello world"
        pcvs.DrawView(lbl, 
    rect)
        Panel1.AddView(lbl,LblAddress.Left,LblAddress.Top,LblAddress.Width,LblAddress.Height)
        pcvs.Refresh
        pcvs.Release
    End Sub
    After the drawview I have addview to draw the local label to the panel, this works fine, but the lable is not being written to the pdf.

    Any help appreciated.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Example:
    Code:
    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       Page1.Initialize(
    "Page1")
       Page1.Title = 
    "Page 1"
       Page1.RootPanel.LoadLayout(
    "1")
       NavControl.ShowPage(Page1)
       
    Dim cvs As Canvas
       cvs.InitializePDF(
    File.DirDocuments, "1.pdf"612792)
       cvs.DrawColor(
    Colors.Red)
       
    Dim lbl As Label
       lbl.Initialize(
    "")
       lbl.SetLayoutAnimated(
    0100100300)
       lbl.Multiline = 
    True
       lbl.TextColor = 
    Colors.Blue
       lbl.Text = 
    $"j dsfkl jsdlkf sdf
    sjdlfk sdk lfjsdlfkjsdf
    sdfjlksd fjlskdfj lskd f
    sdfj lsdfj lskdf jlsdf "$

       
    Dim r As Rect
       r.Initialize(
    1010110310)
       cvs.DrawView(lbl, r)
       cvs.Release
       WebView1.LoadUrl(
    "file://" & File.Combine(File.DirDocuments, "1.pdf"))
    End Sub
    The layout file includes a single WebView named WebView1.
     
  5. Lyndon

    Lyndon Member Licensed User

    Many thanks Erel that works.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice