forked from tojocky/node-printer
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
corrected broken implementation of printDirect with buffer data for n…
…ode v.4.x.x tojocky#95
- Loading branch information
Showing
7 changed files
with
72 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Windows does not support PDF formats, but you can use imagemagick-native to achieve conversion from PDF to EMF. | ||
|
||
var printer = require("../lib"), | ||
fs = require('fs'), | ||
path = require('path'), | ||
filename = process.argv[2], | ||
printername = process.argv[3]; | ||
|
||
if(process.platform == 'win32') { | ||
throw 'Not yet supported for win32' | ||
} | ||
|
||
if(!filename || filename == '-h') { | ||
throw 'PDF file name is missing. Please use the following params: <filename> [printername]' | ||
} | ||
|
||
filename = path.resolve(process.cwd(), filename); | ||
console.log('printing file name ' + filename); | ||
|
||
fs.readFile(filename, function(err, data){ | ||
if(err) { | ||
console.error('err:' + err); | ||
return; | ||
} | ||
console.log('data type is: '+typeof(data) + ', is buffer: ' + Buffer.isBuffer(data)); | ||
printer.printDirect({ | ||
data: data, | ||
type: 'PDF', | ||
success: function(id) { | ||
console.log('printed with id ' + id); | ||
}, | ||
error: function(err) { | ||
console.error('error on printing: ' + err); | ||
} | ||
}) | ||
}); | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters