cordova-plugin-printer icon indicating copy to clipboard operation
cordova-plugin-printer copied to clipboard

Printing to "(null)"

Open luckyboy07 opened this issue 7 years ago • 13 comments

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>

17499836_1352079598164259_1952535023_o

luckyboy07 avatar Mar 27 '17 07:03 luckyboy07

Android is working, I've same problem in IOS 10.3. It's working with Ionic 1!

Someone solve the problem?

alpinea310 avatar Jun 13 '17 07:06 alpinea310

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?

dsjdigital avatar Nov 15 '17 08:11 dsjdigital

@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 avatar Nov 11 '18 03:11 laalex

@laalex Connect your iPad to your machine, use Xcode to build and run your app and check the debug output when printing.

dsjdigital avatar Nov 11 '18 16:11 dsjdigital

@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 avatar Nov 11 '18 17:11 laalex

@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.

dsjdigital avatar Nov 12 '18 07:11 dsjdigital

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.

katzer avatar Jan 02 '19 14:01 katzer

@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?

katzer avatar Jan 02 '19 14:01 katzer

Ant updates on this? Having the same issue as I tried to print it by passing the printerId instead of choosing the printer

kennethross avatar Jan 28 '19 12:01 kennethross

@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 avatar Feb 13 '19 11:02 kennethross

@kennethross All the ipp:// addresses that are returned after picking a printer do work for me. Also with physical printers.

katzer avatar Feb 13 '19 14:02 katzer

I can also print with hardcoded network URL like ipp://SEC30CDA73C4694.local.:631/ipp/print without picking the printer first. It works as expected...

katzer avatar Feb 13 '19 14:02 katzer

@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?

iborschca avatar Jan 16 '22 04:01 iborschca