Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error of use printer.printDirect #116

Closed
jin-pan opened this issue Feb 16, 2016 · 7 comments
Closed

error of use printer.printDirect #116

jin-pan opened this issue Feb 16, 2016 · 7 comments

Comments

@jin-pan
Copy link

jin-pan commented Feb 16, 2016

i build the module with nw.js 0.12.3 (winXP-32) use nw-gyp0.13.0 and node.js 5.4.1.
my test code is :

`var printer = require("node_printer");

console.log('default printer name: ' + (printer.getDefaultPrinterName() || 'is not defined on your computer'));

printer.printDirect({
    data:"some text" // or simple String: "some text"

//  , printer:'PDFCreator' // printer name, if missing then will print to default printer

    , type: 'RAW' // type: RAW, TEXT, PDF, JPEG, .. depends on platform

    , success:function(jobID){console.log("sent to printer with ID: "+jobID);}
    , error:function(err){console.log(err);}
});`

the "printer.getDefaultPrinterName()" can return the printer name of "PDFCreator".
but it catch error when "printer.printDirect".
the error show in cosole is:
"
Uncaught TypeError: Expected 5 arguments
(anonymous function)
"

what's wrong of it??

@tojocky
Copy link
Owner

tojocky commented Feb 16, 2016

Use type: "TEXT"

On Tue, 16 Feb 2016, 08:47 jin-pan notifications@github.com wrote:

i build the module with nw.js 0.12.3 (winXP-32) use nw-gyp0.13.0 and
node.js 5.4.1.
my test code is :

`var printer = require("node_printer");

console.log('default printer name: ' + (printer.getDefaultPrinterName() ||
'is not defined on your computer'));

printer.printDirect({
data:"some text" // or simple String: "some text"

// , printer:'PDFCreator' // printer name, if missing then will print to default printer

, type: 'RAW' // type: RAW, TEXT, PDF, JPEG, .. depends on platform

, success:function(jobID){console.log("sent to printer with ID: "+jobID);}
, error:function(err){console.log(err);}

});`

the "printer.getDefaultPrinterName()" can return the printer name of
"PDFCreator".
but it catch error when "printer.printDirect".
the error show in cosole is:
"
Uncaught TypeError: Expected 5 arguments
(anonymous function)
"

what's wrong of it??


Reply to this email directly or view it on GitHub
#116.

@jin-pan
Copy link
Author

jin-pan commented Feb 16, 2016

I use every options of the type for test,The error still occur.
and I use node.js 4.3.0 to rebuild the module, It is not useful too.

and i use another pdf pinter:

my test code is:

=========================================================
=========================================================
var printer = require("node_printer"),
    util = require('util');
console.log("supported formats are:\n"+util.inspect(printer.getSupportedPrintFormats(), {colors:true, depth:10}));
console.log('default printer name: ' + (printer.getDefaultPrinterName() || 'is not defined on your computer'));
printer.printDirect({data:"print from Node.JS buffer" // or simple String: "some text"
    //, printer:'Foxit Reader PDF Printer' // printer name, if missing then will print to default printer
    , type: 'TEXT' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
    , success:function(jobID){
        console.log("sent to printer with ID: "+jobID);
    }
    , error:function(err){console.log(err);}
});

=========================================================
=========================================================

the console show:

supported formats are:
[ �[32m'RAW'�[39m,
  �[32m'XPS_PASS'�[39m,
  �[32m'RAW'�[39m,
  �[32m'NT EMF 1.006'�[39m,
  �[32m'NT EMF 1.007'�[39m,
  �[32m'NT EMF 1.008'�[39m,
  �[32m'TEXT'�[39m,
  �[32m'RAW'�[39m,
  �[32m'RAW [FF appended]'�[39m,
  �[32m'RAW [FF auto]'�[39m,
  �[32m'NT EMF 1.003'�[39m,
  �[32m'NT EMF 1.006'�[39m,
  �[32m'NT EMF 1.007'�[39m,
  �[32m'NT EMF 1.008'�[39m,
  �[32m'TEXT'�[39m ]

default printer name: Adobe PDF
Uncaught TypeError: Expected 5 arguments
(anonymous function)

Help!!!

@jin-pan
Copy link
Author

jin-pan commented Feb 17, 2016

Hi,tojocky:

if i use this:

printer.printDirect(1,1,1,1,1,1,1);

the error catch is:
Uncaught TypeError: Argument 0 must be a string or Buffer

so i think the error is on arguments passing and receiving.

Please help to give same advise about the error.

@tojocky
Copy link
Owner

tojocky commented Apr 7, 2016

Strange, only you have this issue.
You can try to remove this line:
https://github.com/tojocky/node-printer/blob/master/src/node_printer_win.cc#L669

Recompile and let me know what do you have.

@jin-pan
Copy link
Author

jin-pan commented Feb 13, 2017

oh! one year is pass!
few days ago,when i view this project and find it had some update.
So,I try it again.
long time is pass and my Win xp is remake again.
and i build this printer with Win xp sp3/ vs2010/node5.12.0.
finally,the job is done.

thank you tojocky. you are a good gay!

@jin-pan jin-pan closed this as completed Feb 13, 2017
@0x6B386F
Copy link

0x6B386F commented Aug 2, 2017

same problem here.

@JeffJassky
Copy link

Setting my default printer fixed this for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants