1. Black Friday Sale - 50% off

    B4A Standard for $29 instead of $59!
    Buy Now
    Dismiss Notice

Android Question Write and Open PDF

Discussion in 'Android Questions' started by Kiran Raotole, Sep 9, 2018.

Tags:
  1. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I want to open PDF file,
    Its shows message :: Can't open file trying saving the file on device and then opening it.
    I written this code :

    Code:
    Dim pdf As PdfDocument
        pdf.Initialize
        pdf.StartPage(
    595842'A4 size
        pdf.Canvas.DrawLine(22593 , 840Colors.Blue, 4)
        pdf.Canvas.DrawText(
    "Hello"100100Typeface.DEFAULT_BOLD, 30 / GetDeviceLayoutValues.Scale , Colors.Yellow, "CENTER")
        pdf.FinishPage
        
    File.Copy(File.DirAssets,"1.pdf",File.DirDefaultExternal,"1.pdf")
        
    Dim out As OutputStream = File.OpenOutput(File.DirDefaultExternal, "1.pdf"True)
        pdf.WriteToStream(out)
        
    Dim intent As Intent
        
    intent.Initialize(intent.ACTION_VIEW,"1.pdf")
        
    intent.SetType("application/pdf")
        
    intent.WrapAsIntentChooser("Choose PDF Viewer")
        
    StartActivity(intent)

        out.Close
        pdf.Close
    Whats problem?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You need to use FileProvider to share the pdf file.
     
  3. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I have to open pdf file not to share it.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    It is exactly the same.
     
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