html-to-pdf-convertor icon indicating copy to clipboard operation
html-to-pdf-convertor copied to clipboard

Some questions about weird issues in the sample/library

Open AndroidDeveloperLB opened this issue 1 year ago • 0 comments

  1. The sample project requires some removal of stuff before building it. I had to remove all from "afterEvaluate" inside the file publish-module.gradle . Why was it added?
  2. Even though the app targets API 33, it still uses WRITE_EXTERNAL_STORAGE, which means it can't access the files of the file system, and then it complains it doesn't have this permission. Weird that it even needs it though, because I think it writes only into its own folder. I had to add MANAGE_EXTERNAL_STORAGE permission into the manifest and grant it myself. I don't think the app needs any storage permission... Why was it added?
  3. The output file isn't deleted on beginning, so if I change the HTML and run again, it won't be created anymore. Can you please check it out?
  4. I've noticed that in the library, it uses progress to check when it's done in WebChromeClient.onProgressChanged , but I don't think this is the right thing to do. I think it's more official to use WebViewClient.onPageFinished , or even better: WebView.postVisualStateCallback. Aren't those better?
  5. I failed to use image files that are not in the assets folder. Can you please show how it's done?

For example, instead of what the sample shows (to reach files in an assets folder), I wanted to reach this path, which is more dynamic and allows to reach newly generated files :

val file = File(filesDir, "sample_image.png")
assets.open("images/sample_image.png").use {
    it.copyTo(FileOutputStream(file))
}

It should be possible: https://developer.android.com/develop/ui/views/layout/webapps/load-local-content

What would I put in the "setBaseUrl" parameter, and would it be possible to set it in the HTML content itself?

AndroidDeveloperLB avatar Nov 12 '23 23:11 AndroidDeveloperLB