<img src="image.png" />
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private sh As Shell
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
End Sub
Sub Button1_Action
Dim out As OutputStream = File.OpenOutput(File.DirApp, "image.png", False)
MainForm.RootPane.Snapshot.WriteToStream(out)
out.Close
Dim params As List
params.Initialize
'params.Add("printername=novapdf")
params.Add("file=template.html")
sh.Initialize("sh", "printhtml.exe", params)
sh.WorkingDirectory = File.DirApp
sh.Run(-1)
End Sub
Sub sh_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log("Success=" & Success & ", StdOut=" & StdOut & ", StdErr=" & StdErr)
End Sub
You should create a template file. It should point to the image:
Now in your code you should save the snapshot to this image and print the template:B4X:<img src="image.png" />
B4X:Sub Process_Globals Private fx As JFX Private MainForm As Form Private sh As Shell End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 MainForm.RootPane.LoadLayout("1") 'Load the layout file. MainForm.Show End Sub Sub Button1_Action Dim out As OutputStream = File.OpenOutput(File.DirApp, "image.png", False) MainForm.RootPane.Snapshot.WriteToStream(out) out.Close Dim params As List params.Initialize 'params.Add("printername=novapdf") params.Add("file=template.html") sh.Initialize("sh", "printhtml.exe", params) sh.WorkingDirectory = File.DirApp sh.Run(-1) End Sub Sub sh_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String) Log("Success=" & Success & ", StdOut=" & StdOut & ", StdErr=" & StdErr) End Sub
Program started.
Success=true, StdOut=HTMLPRINT 4.0.0.19 - Copyright 2013
Unable to load HTML from file 'template.html'. The file does not exist.
, StdErr=
Hi all,
I've error this,how to get rid of this. Assume I've added my picture at Files Tab already(my picture is bigger than permit posting.)
The template file is a standard html file. You can leave it as is if you want to print the image.
If you like you can use File.WriteText to build it programmatically.