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: 613
  • CloudPrint_Lib_2.0.zip
    4.2 KB · Views: 666
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Longtime User
All these Cloud printing services I have tried want you to be printing either a photo, webpage or text file.

How can I send printer commands to them.

Think of my App as Microsoft Word and I want to print pretty headings, boxes, diagrams, etc.

How can I send these printer commands to the printer using one of these services?

Any help here?

BobVal
 

Tayfur

Well-Known Member
Licensed User
Longtime User
Thank you for your lib. it is very nice.
I used android 5.1.1. and added CP app. And your app works very nicve. :)

I have some questions.

  1. How can I detection "Cloud Print APP (CPA)"? is My app read some error when user has not CPA.
  2. is My app read some error when user phone dont support Printer (like android 4.0)?
 

MitchBu

Well-Known Member
Licensed User
Longtime User
Hi NJDude,

Very nice job.

I have a question, though. Is there any way to control the margins ? On an HP Envy 100 printer, the same picture with Gallery prints with margins of 1/8th" to 2/8th", whereas with your class I end up with a margin on top of one inch and a half, and one inch on every side.
 

NJDude

Expert
Licensed User
Longtime User
I don't think this lib will allow to set margins, whatever you get is whatever the Print App allows, in some cases I've noticed that some extra settings might appear depending on the printer, I don't really have an answer.
 
Last edited:

johndb

Active Member
Licensed User
Longtime User
The current CloudPrint library fails with Android 7.X (Nougat). The app doesn't crash, it just states "Failed to submit print job". I am using this library in various apps and it runs well on Android 6 and below. Does anyone else have this problem? Devices reporting the problem are Google Pixel XL.

Thanks,

John
 

DonManfred

Expert
Licensed User
Longtime User
Did you checked the unfiltered log for errors?
 
Top