Difficulty with WebView

noclass1980

Active Member
Licensed User
Longtime User
Hi, need some advice on the following problem:
I wanted to create a pdf from a table that wasn't produced using a database. Erel suggested I look at the DBUtils and borrow some code from the ExecuteHTML sub. In the attached, I have been able to generate an HTML table from my table data and open a WebView with the table data showing; so far, so good. The problem is then creating a BitMap from the WebView - the WebView.CaptureBitmap returns a NULLPOINTER exception. Other posts suggested the format might be:

B4X:
dim img as BitMap
img.initialize3(WebView1.CaptureBitMap)

and I've also seen

B4X:
img=WebView1.CaptureBitMap

but both cause the NULLPOINTER problem. I also tried to initialize the image bitmap with a bitmap file and the replacing it with CaptureBitMap approach but that didn't work either.

if the Bitmap is initialised with an image file, the pdfwriter part of the code successfully saves the image as a pdf so the problem appears to lie somewhere around line 158 with the WebView1.CaptureBitMap code. Would be grateful for any suggestions. Thanks.
 

Attachments

  • Webviewzip2.zip
    24.6 KB · Views: 218
Last edited:

noclass1980

Active Member
Licensed User
Longtime User
It doesn't really show an error message on the logs as I remember, just the red NULLPOINTER message in the local variables and the app pauses during running in debug mode. I can't run the app tonight so will post it midday(ish) tomorrow. Thanks for looking though.
 
Upvote 0

noclass1980

Active Member
Licensed User
Longtime User
webview erro log

Hi, I've run the app again with the same failure at line 156. I've attached a copy of the log for information. I don't know if this is relevant but the second line of the nullpointer error log is:

at anywheresoftware.b4a.samples.dbutils.main._pdfbutton_click(main.java:792)

I had the dbutils module inserted in the app during the early development but then deleted it after I'd used the code in dbutils.ExecuteHTML in the main module in sub "pdfbutton_Click" so could the missing module be the cause?

I look forward to your comments. Thanks
 

Attachments

  • WebviewHTMLTableLog.txt
    3.9 KB · Views: 230
Last edited:
Upvote 0

noclass1980

Active Member
Licensed User
Longtime User
Seems like WebView is not yet ready. You should use the WebView PageFinished event and save the bitmap there.

ok, I'll try that. Is the Webview_PageFinished event automatically raised when it's finished? and should I use

B4X:
pdfimage.InitializeMutable(WebView1.width, WebView1.height) pdfimage=WebView1.CaptureBitmap

or

B4X:
pdfimage.Initialize3(WebView1.CaptureBitmap)

thanks for the prompt response.
 
Upvote 0

noclass1980

Active Member
Licensed User
Longtime User
Upvote 0
Top