Giter VIP home page Giter VIP logo

Comments (4)

tojocky avatar tojocky commented on June 14, 2024

OS?
Could you post the script here?
What is the output?

Any other info would help us find the issue.

from node-printer.

q2dg avatar q2dg commented on June 14, 2024

Fedora 20, Linux 3.14.6 (64 bits).
The script is a light variant of your basic example:

var printer = require("printer")
var printerName="Stylus-DX7400"
console.log(printer.getPrinter(printerName))
console.log("---------------------")
console.log(printer.getSupportedPrintFormats(printerName))
console.log("---------------------")
console.log(printer.getSupportedJobCommands(printerName))
console.log("---------------------")
printer.printDirect({
data:new Buffer("I will be written"),
printer: printerName,
type: "RAW" ,
success:function(jobID){
console.log("Job sent with ID: " + jobID)
var jobInfo = printer.getJob(printerName, jobID)
console.log("Job info:" + JSON.stringify(jobInfo, null, 2))
},
error:function(err){console.log(err)}
})

And the output is:

{ name: 'Stylus-DX7400',
isDefault: true,
options:
{ copies: '1',
'device-uri': 'usb://EPSON/Stylus%20DX7400?serial=4C3632303346CB2F66&interface=1',
finishings: '3',
'job-hold-until': 'no-hold',
'job-priority': '50',
'job-sheets': 'none,none',
'marker-change-time': '0',
media: 'iso_a4_210x297mm',
'number-up': '1',
'printer-commands': 'AutoConfigure,Clean,PrintSelfTestPage',
'printer-info': 'EPSON Stylus DX7400',
'printer-is-accepting-jobs': 'true',
'printer-is-shared': 'true',
'printer-location': 'minuevofedora-dominio',
'printer-make-and-model': 'Epson Stylus DX7400 - CUPS+Gutenprint v5.2.9 Simplified',
'printer-state': '3',
'printer-state-change-time': '1402955900',
'printer-state-reasons': 'none',
'printer-type': '8556556',

'printer-uri-supported': 'ipp://localhost:631/printers/Stylus-DX7400' } }

[ 'AUTO', 'COMMAND', 'JPEG', 'PDF', 'POSTSCRIPT', 'RAW', 'TEXT' ]

[ 'CANCEL' ]

Job sent with ID: 179
Job info:{
"id": 179,
"name": "node print job",
"printerName": "Stylus-DX7400",
"user": "q2dg",
"format": "RAW",
"priority": 50,
"size": 1,
"status": [
"PRINTING"
],
"completedTime": "1970-01-01T00:00:00.000Z",
"creationTime": "2014-06-16T21:58:48.000Z",
"processingTime": "2014-06-16T21:58:48.000Z"
}

All seems to be ok, but printer doesn't do ANYTHING. It's very strange

Thanks for your interest

from node-printer.

tojocky avatar tojocky commented on June 14, 2024

I can see 2 issues:

  1. data format issue: By sending raw data to printer means that you sending command(s) directly. I don't think for this printer is published a command language. You have to use driver rather than direct commands.
  2. Encode issue: New Bufer("some text") without the second parameter means will be encoded in utf8. Check which charcode does your printer support.

As a solution try to send a "TEXT" format data without Buffer, like:

var printer = require("printer")
var printerName="Stylus-DX7400"
console.log(printer.getPrinter(printerName))
console.log("---------------------")
console.log(printer.getSupportedPrintFormats(printerName))
console.log("---------------------")
console.log(printer.getSupportedJobCommands(printerName))
console.log("---------------------")
printer.printDirect({
data:"I will be written", // no new Buffer
printer: printerName,
type: "TEXT" , // TEXT instead of RAW
success:function(jobID){ 
console.log("Job sent with ID: " + jobID) 
var jobInfo = printer.getJob(printerName, jobID)
console.log("Job info:" + JSON.stringify(jobInfo, null, 2))
},
error:function(err){console.log(err)}
})

If you really want to send a RAW data format, then check first printer manual, which command language it does support. I couldn't find any language published for this printer.

The Idea of RAW data format is to print barcodes, payment receipts, etc., are common for termal printers where a command language is published.

from node-printer.

q2dg avatar q2dg commented on June 14, 2024

YES!!!! YES!!! YES!!!
You were right!!!
It works!!
Thanks a lot!!!

Now I must learn how to print external files, like Pngs, Odts, Pdfs... because I think it's the most useful functionality (in fact, you know I opened another issue about the lack of this king of examples...I will try to get some working codes to share them).

I close the issue!
Thanks!!

from node-printer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.