But all I get is a MsgBox with
----
Unfortunately, HP ePrint has stopped Report OK
----
I routinely print to the same printer from the same title iOS app I already created in another tool, and what happens is, the printer "wakes up" and I never saw the same kind of dialog.
Something seems to be missing in the code to bring the printer up :
B4X:
Dim i As Intent
i.Initialize("org.androidprinting.intent.action.PRINT", "file://" & File.Combine(Dir, FileName)) 'make sure that the file is in the external storage
i.SetType("text/plain")
StartActivity(i)
I would appreciate some help in that matter. If I cannot print, this is a definite show stopper
In the bottom of the logs window you have a checkbox to filter the logs, thus showing only B4X related logs, unchecking it will show you ALL the system logs...
PS. Been here for about a year, I like it very much
Now, since I must go through a WebView, I will need to generate a picture to print with precision.
I looked at the SimpleDrawFunctions SourceCode example. If I can use the same kind of commands to draw to a picture, I can probably create a good printing document.
So my basic questions are :
- Is possible to create a picture and draw to it instead of a view ?
- Where can I find the corresponding set of commands and properties ?
- How will I save the picture to disk to use it in WebView ?
OK. Since apparently it is not possible to control margins with cloud printing, I tried to go back to this way.
Unfortunately, I cannot find back my previous project, so I tried this in a button :
B4X:
File.WriteString(File.DirRootExternal, "String.txt", _
"This is some string" & CRLF & "and this is another one.")
Msgbox(File.ReadString(File.DirRootExternal, "String.txt"), "")
Dim i As Intent
i.Initialize("org.androidprinting.intent.action.PRINT", "file://" & File.Combine(File.DirRootExternal, "String.txt")) 'make sure that the file is in the external storage
i.SetType("text/plain")
StartActivity(i)
It triggers the error :
Error occurred on line: 86 (Main)
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=org.androidprinting.intent.action.PRINT dat=file:///storage/emulated/0/String.txt typ=text/plain flg=0x20000 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1801)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1499)
at android.app.Activity.startActivityForResult(Activity.java:3954)
at android.app.Activity.startActivityForResult(Activity.java:3901)
at android.app.Activity.startActivity(Activity.java:4225)
at android.app.Activity.startActivity(Activity.java:4193)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:698)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:753)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:343)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:5214)
at android.view.View$PerformClick.run(View.java:20978)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)