B4A Library CloudPrint - Library

This library will allow you to add printing capabilities to your apps using CloudPrint.

This is an alternative solution to the one on THIS post.

Requirements:

1- A printer connected to CloudPrint, see the setup instructions HERE.

2- The CloudPrint app installed on your device.

3- Copy the CloudPrint.xml and CloudPrint.jar to your additional libraries directory.

Usage:
B4X:
'Initialize the library
Private print As CloudPrint

print.Initialize

'To print a document do this:
print.SendToCloudPrint("Test file", File.DirDefaultExternal, "Sample_Document.txt")

'To print a website
print.SendWebViewToCloudPrint("My Website", WebView1)

'To see your print queue
print.ShowPrintJobs

That's it!!

NOTES:

* This lib is not compatible with KitKat (KitKat has printing built in but I've been unable to get it to work, stay tuned).

* You CANNOT print documents saved on DirAssets, DirInternal or DirInternalCache.

* Make sure you have the most current CloudPrint app installed.

A sample project is attached.

Thank you.
 

Attachments

  • CloudPrint_Lib_Sample.zip
    10.2 KB · Views: 480
  • CloudPrint_Lib_2.0.zip
    4.2 KB · Views: 528
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, NJ.

Downloaded v2 of the library. The old error disappeared. New error comes up - "No printing services installed" (see Error screen). Click OK on this screen gets the "Unfortunately CloudPrint Sample has stopped".

The second screen shows on the same TF103 tablet the Printing Services installed.

I am able to print from WPS Office and Gmail.

Best regards.

Sandy

TF103Error.png TF103Settings.png
 

NJDude

Expert
Licensed User
Longtime User
Then it seems there's nothing I can do, the code I added it's supposed to ID if the print services are installed properly and displays the proper messages, I tested the code on my devices and also Genymotion and it works, WPS office and GMail must be using their own way, I'm just using the CloudPrint services provided by Google via the app or the device.
 

tdocs2

Well-Known Member
Licensed User
Longtime User
NJ,

Same TF103 printing b4x.com... I was going to send you a video but the forum does not allow it (mp4).

So here are 3 screenshots:


B4xPrint1.png B4xPrint2.pngTF103Settings.png


Hope this helps.

Sandy

PS: V2 Lib continues to work in the other devices I have.
 

NJDude

Expert
Licensed User
Longtime User
There's something weird with that device and the built-in printing services, that's all I can tell you.

Just curious, what version of CloudPrint you have on your device?
 
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, NJ.

There's something weird with that device and the built-in printing services, that's all I can tell you.

Can you give me a clue? I will work on this since as you know, I have an interest in printing. ASUS is a premier mainstream company and the TF103 is a brand new product. How would you know if the problem does not happen in another tablet? The TF103 I have is stock; It is not rooted; I have not replaced ROM's, I have not upgraded other than what ASUS provides via OTA.

I do not want to be difficult... And I think your library is a great contribution.

Sandy
 

NJDude

Expert
Licensed User
Longtime User
You're not being difficult, I'm also intrigued, like I said on my previous post, please tell me what version of CloudPrint you have on that device (the current one is 1.11b)
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Here it is:

CloudPrintVersion.png

Obviously, it is not 1.11b. I am not the expert - you are, and I respect your knowledge. Should the Lib account for this?

I am going to Google Play an update and see what happens...

Sandy

PS: Cool utility app :)
 

tdocs2

Well-Known Member
Licensed User
Longtime User
NJ,

Updated and success on the TF103.

Suggestion: the error message from the library should be: Requires Cloud Print 1.11b or whatever level the lib requires? Not "No Printing Services Detected".



CloudVersion1_11onTF103.png


Do you know why Cloud Print was not updated automatically in the TF103? I forgot where to look this up.... Some apps require permissions to update... Others are automatically updated.

Thank you.

Sandy
 

NJDude

Expert
Licensed User
Longtime User
I cannot set a specific version since it works on other devices, that TF103 was "special" and the message "No printing services installed" it's the right message in this case.

The automatic updates will work only on certain apps, and in some cases won't work, this is due to the way Android handles permissions, in some cases, if new permissions are added or updated you will see "Manual update" in Google Play, so, you should check all your installed apps from time to time and upgrade them accordingly.
 

tdocs2

Well-Known Member
Licensed User
Longtime User
We, the participants of this forum, are developers developing for an end user. What would an end user make of "No printing services installed" when he/she sees, as I did, that the Printing Service is installed? As opposed to "Your Cloud Print Service may need to be updated. Go to Google Play and update."

The TF103 was shipped with an older version of Cloud Print, which is part of the Google print Framework, and never updated. And that could apply to a lot of tablets which do not have OTA. 70 to 75% of the world runs on Android (52%in the US) and there must be a 100+ brands of tablets.

And interesting enough, all the other apps were printing, as I showed you, with Cloud Print v0.92....

And I continue to raise the issue because printing is an essential function. You see more and more "BIG Company APPS" with printing capabilities as a matter of course...

AND I still do not see why there are not 500 posts on this thread!
 

NJDude

Expert
Licensed User
Longtime User
Ok, here's the deal, the reason for the message "No printing services installed" is because some devices have an incomplete version of CloudPrint, I have one of those devices which is why I was able to fix the library, for a moment I though that was the problem in your case, and if you read previous posts, I suggested to make sure the more recent version of the app was installed. The other apps were printing because those apps have their own printing routine and like I explained before this library depends on the CloudPrint services directly.
 
Last edited:

TheMightySwe

Active Member
Licensed User
Longtime User
Hi, is there anyway to get a confirmation or poll the cloudprint app if a document has been printed?
 

TheMightySwe

Active Member
Licensed User
Longtime User
As far as I know, there's no such confirmation, once the job has been sent it will show on the print queue as done, that's all.


In the cloudprint app, there is a column for "Printed", thats why I ask. But maybe thats just for show?
 

le_toubib

Active Member
Licensed User
Longtime User
Hi
I agree with tdocs2 on how come there s no 500 posts here. This library is extremely useful.
I'm using the library to print a Webview, however my office cloud printer was turned off, so the app has sent 25 copies of the Job to the printer!!!! , i tried to send another job to my Google Drive, and it actually send 25 copies of the html file (in png format)
I'm in lollipop htc, hp printer, latest cloud print.
What am I doing wrong?
P. S : i had to force the user to install cloud print on the first install of my app to make things easier.
 

schemer

Active Member
Licensed User
Longtime User
Does this still work? I have been trying to get it to work with an Epson WP-4530 Cloud Ready printer and am having no luck. The v2.0 app and additional library files are installed and the app runs on my device, but I can't get it to print. I am logged on and set the printer up but still no luck. I went to the Google App Store only to read a bunch of people complaining that the Cloud Printer doesn't work now, but it used to. Any other good alternatives?
Thanks,
schemer
 
Top