0

I am working on saving a webview as a pdf in compose android . Have this function that launches the android print manager which works for me . I am looking to add a functionality where i can automatically pop the backstack to the previous screen after the webview has been successfully saved . Is it possible to add a click listener to the save pdf button on the print manager screen to track if it was successful and go back ? This is my code

fun saveAsPdf(
     webView: WebView,
     context: Context?,
     printJobName: String = printJobDescription,
     
 ) {
     (context?.getSystemService(Context.PRINT_SERVICE) as PrintManager).let { printManager ->

         val printAdapter = webView.createPrintDocumentAdapter(printJobName)

         printManager.print(
             printJobName,
             printAdapter,
             PrintAttributes
                 .Builder()
                 .setMediaSize(
                     PrintAttributes.MediaSize.ISO_A4
                 )
                 .build()
         )
     }
}

I tried tracking the state of the printjob with

printJob.isSuccessful

and

printJob.isFailed

but those are not working for me. Any help would be appreciated

Sergei Kozelko
  • 691
  • 4
  • 17

0 Answers0