B4J Question Printing Google Charts

Harris

Expert
Licensed User
Longtime User
https://developers.google.com/chart/interactive/docs/printing

The link above provides an example. However, it keeps compounding the page with a "Printable version" link for each chart I render (and stuffing the console log with new image data).

I would like to add a button to form - "Print this Chart" - taking the current chart view and saving it to a file (or output to another browser page) - so the user could then Print it.

JS confounds me... as always...

Thanks
 

jmon

Well-Known Member
Licensed User
Longtime User
the easy way is to do a screenshot with to do a snapshot of the webview that displays the charts. You could load the webview in a pane and the call this:
B4X:
Dim FileName as String = "c:/temp.png"
Dim img As Image = ap.Snapshot
Dim Output As OutputStream = File.OpenOutput(File.GetFileParent(FileName), File.GetName(FileName), False) 
img.WriteToStream(Output)
Output.Close
Just before calling this function, you could resize your mainform to the size you want to export your image.
That will save a png of your charts.

Print with this library : https://www.b4x.com/android/forum/threads/b4j-print-javafx8.49836/#content
Also the example provided can print the form.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
the easy way is to do a screenshot with to do a snapshot of the webview that displays the charts. You could load the webview in a pane and the call this:
B4X:
Dim FileName as String = "c:/temp.png"
Dim img As Image = ap.Snapshot
Dim Output As OutputStream = File.OpenOutput(File.GetFileParent(FileName), File.GetName(FileName), False)
img.WriteToStream(Output)
Output.Close
Just before calling this function, you could resize your mainform to the size you want to export your image.
That will save a png of your charts.

Print with this library : https://www.b4x.com/android/forum/threads/b4j-print-javafx8.49836/#content
Also the example provided can print the form.

Thanks. I shall try and report back...
 
Upvote 0
Top