tojocky / node-printer

Native node.js printer
1.52k stars 438 forks source link

implementing print file on Windows #183

Open cmnstmntmn opened 7 years ago

cmnstmntmn commented 7 years ago

as i can see here node_printer_win.cc, PrintFile is not yet implemented.

as @tojocky suggested on some other issues, there are few links to start:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd145226(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/dd162624(v=vs.85).aspx

kiuKisas commented 7 years ago

can't we use printDirect as explain on this issue : #174 ?

cmnstmntmn commented 7 years ago

@kiuKisas nope. i even try with pdfium. not raw or emf stream works.

xioxin commented 6 years ago

Try postscript

I print PDF on windows

    function printPdf(pdfData) {
        let fileId = guid();
        let pdfPath = tempPath+'/'+fileId+'.pdf';
        fs.writeFileSync(pdfPath,pdfData);
        execFile(`${__dirname}/bin/win64/pdftops`, ['-paper','A4',pdfPath], null, function (error, stdout, stderr) {
            console.log(error, stdout, stderr);
            fs.unlinkSync(pdfPath);
            let psData = fs.readFileSync(psPath,'utf8');
            fs.unlinkSync(psPath);
            printer.printDirect({
                data:psData,
                printer:printer.getDefaultPrinterName(), // printer name
                options:{
                },
                type: 'RAW',
                success:function(jobID){
                    console.log('jobid',jobID);
                },
                error:function(err){
                    console.log('joberr',err);
                }
            });

        });
    }
cmnstmntmn commented 6 years ago

@xioxin can't make it work. nothing goes to the printer.

xioxin commented 6 years ago

Install PostScript version driver

cmnstmntmn commented 6 years ago

@xioxin if i select XPS2GDI it prints the ps file content, without rendering it.

cmnstmntmn commented 6 years ago

@xioxin pff, can't install de adobe ps driver on windows 10

xioxin commented 6 years ago

I'm using a HP printer,https://support.hp.com/us-en/drivers/selfservice/hp-universal-print-driver-series-for-windows/503548/model/503550