Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/src/main/java/android/print/PdfExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package android.print

import android.content.ContentResolver
import android.content.Context
import android.util.Log
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.documentfile.provider.DocumentFile
import com.philkes.notallyx.utils.nameWithoutExtension

private const val TAG = "PdfExtensions"

/**
* Needs to be in android.print package to access the package private methods of
* [PrintDocumentAdapter]
Expand All @@ -21,6 +24,16 @@ fun Context.printPdf(file: DocumentFile, content: String, pdfPrintListener: PdfP
val adapter = webView.createPrintDocumentAdapter(file.nameWithoutExtension!!)
contentResolver.printPdf(file, adapter, pdfPrintListener)
}

@Suppress("DEPRECATION")
override fun onReceivedError(
view: WebView?,
errorCode: Int,
description: String?,
failingUrl: String?,
) {
Log.w(TAG, "PDF WebView load error $errorCode: $description @ $failingUrl")
Comment thread
Crustack marked this conversation as resolved.
}
Comment thread
Crustack marked this conversation as resolved.
}
}

Expand Down