title: Write canvas in pdf and save it in storage android studio, doesn't work
body: <p>i have a probleme, i want to create a pdf and save him in download path on the phone, but it seems like there is an error and i don't know how to figure it out.</p>
  <p>Can anyone help me please ? (I already have the permission for access storage, i think :/ ).</p>
  <p>This is my code --&gt;</p>
  <p><strong>fun createPdf</strong></p>
  <pre><code>fun createPdf(
      text: String,
      context: Context
  ) {
      val myPDFdocument = PdfDocument()
      val myPaint = Paint()
      val myPageInfo1 = PdfDocument.PageInfo.Builder(1240, 1754, 1).create()
      val myPage1 = myPDFdocument.startPage(myPageInfo1)
      val canvas = myPage1.canvas
  
      canvas.drawText(text, 40F, 50F, myPaint)
      myPDFdocument.finishPage(myPage1)
  
      val file = File(context.externalCacheDir!!.absolutePath, &quot;/FirstPdf.pdf&quot;)
      try {
          myPDFdocument.writeTo(FileOutputStream(file))
      } catch (e: IOException) {
          e.printStackTrace()
      }
  
      myPDFdocument.close()
  }
  </code></pre>