0

I have a POS application in kotlin. Currently I can print from url but I need to use third party service like rawbt

    private fun prepPrintWebView(name: String): WebView? {
        val result: WebView = getWebView()!!
        result.webViewClient = object : WebViewClient() {
            override fun onPageFinished(view: WebView, url: String) {
                print(
                    name, view.createPrintDocumentAdapter(),
                    PrintAttributes.Builder().build()
                )
            }
        }
        return result
    }

    private fun getWebView(): WebView? {
        if (wv == null) {
            wv = WebView(requireContext())
        }
        return wv
    }

    private fun print(
        name: String, adapter: PrintDocumentAdapter,
        attrs: PrintAttributes
    ): PrintJob? {
        val intent = Intent(context, PrintJobMonitorService::class.java)
        requireActivity().startService(intent)
        return mgr!!.print(name, adapter, attrs)
    }

I want to print a receipt from the url and send this to the USB printer directly without any third party service.

I tried many libraries but nothing worked for me.

blurfus
  • 13,485
  • 8
  • 55
  • 61

0 Answers0