cordova-plugin-printer
cordova-plugin-printer copied to clipboard
Printing to "(null)"
Can anyone please tell me what was the cause of this problem? i'm using ios and i struggled of what the causes of this problem was.? the value is null.. Thank you.. here is my code in ts. ` this.printer.isAvailable().then((onsuccess: any) => {
let options: PrintOptions = {
name: 'MyDocument',
printerId: 'printer007',
duplex: true,
landscape: true,
grayscale: true
};
let contents = document.getElementById('printid');
this.printer.print(contents,options).then((value: any) => {
console.log('value:', value);
}, (error) => {
console.log('error:', error);
});
}, (err) => {
console.log('err:', err)
});`
and html
<div id="printid"> <qrcode [qrdata]="generate" [size]="250" [level]="'M'"></qrcode> </div>
Android is working, I've same problem in IOS 10.3. It's working with Ionic 1!
Someone solve the problem?
My solution was to replace the printerId as followes (I discovered this by using XCode as debugger to find out the ipp-address is different than the output from the plugin's picker):
// Assuming that sPrinterUri is your "printerId" variable
if(sPrinterUri.indexOf('.local.:') > -1)
{
var aPrinterUriParts = sPrinterUri.split('/');
sPrinterUri = aPrinterUriParts[(aPrinterUriParts.length - 1)]+'._ipp._tcp.local';
}
Hope this helps!
However, this may solve the printing issue but not the 'Printing to "(null)"' alert, which I want to get rid off as well. Any ideas on that?
@djsdigital can you please explain how did you found out the uri of the printer? How you debugged this? I have the same issue and I need to know the printer uri. Thanks
@laalex Connect your iPad to your machine, use Xcode to build and run your app and check the debug output when printing.
@dsjdigital Thanks. I've did this and I get something like: CITIZEN\032SYSTEMS\032CX-02\032@\032raspberry._ipps._tcp.local. For some reason by using the pop-up from iOS it prints correctly but it doesn't when I provide this URL to the printer. The UIPicker returns an URL like follows: ipps://raspberry.local.:631/printers/... but this URL doesn't work as well.
As I can see from the above output the octal character \032 is actually a SUB char. Which I don't know how to provide in the URL of the printer.
I always get the "Failed to Contact printer" error.
Have any idea on how should I get the right URL from the printer or how to provide it to the plugin? For sure it's working since I'm able to print from my app when selecting the printer. It's just an issue with the right URL of it when passing it to the plugin.
@laalex try using the URL "raspberry._ipps._tcp.local". Otherwise I'm not sure what to do with this octal character. Any chance to check and perhaps change this name? In my experience, "special" characters in the printer's name (even spaces and dashes) don't work.
The error itself means that the OS cannot connect to the printer as specified by printerId
. That should be a valid network URL to the printer.
@laalex If you have something like \032
in your string than its an encoding issue. Does the string comes from your code or as a return result from the plugin?
Ant updates on this? Having the same issue as I tried to print it by passing the printerId instead of choosing the printer
@dsjdigital Hi I'm still having an issue on passing the url after I select the url. this is my printer url after I select it, ipp://Mac-Mini-Aspire-2.local.:49312/printers/fuji. I tried to use fuji._ipp._tcp.local but still it won't work. Appreciate your help.
@katzer , can help with this problem?
@kennethross All the ipp://
addresses that are returned after picking a printer do work for me. Also with physical printers.
I can also print with hardcoded network URL like ipp://SEC30CDA73C4694.local.:631/ipp/print
without picking the printer first. It works as expected...
@dsjdigital Thanks. I've did this and I get something like: CITIZEN\032SYSTEMS\032CX-02\032@\032raspberry._ipps._tcp.local. For some reason by using the pop-up from iOS it prints correctly but it doesn't when I provide this URL to the printer. The UIPicker returns an URL like follows: ipps://raspberry.local.:631/printers/... but this URL doesn't work as well.
As I can see from the above output the octal character \032 is actually a SUB char. Which I don't know how to provide in the URL of the printer.
I always get the "Failed to Contact printer" error.
Have any idea on how should I get the right URL from the printer or how to provide it to the plugin? For sure it's working since I'm able to print from my app when selecting the printer. It's just an issue with the right URL of it when passing it to the plugin.
Did you manage to solve the problem? For me using the pop-up from iOS it prints well but it doesn't when I provide the URL to the printer. May be it establishes some connection after pop-up but since it doesn't have it after - it fails to print using the printer URL?