-
Notifications
You must be signed in to change notification settings - Fork 281
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
Promise looping support #161
Comments
Drafted into the API via d234a38 The print method now has an altered signature to allow for 4 overloaded versions:
The method also groups all print data assigned to configs under a map before printing, so any multiples of a config in the array will print associated data as a multi-page document, rather than all separate print jobs directed at that printer. |
@klabarge can you please test this feature out so that we can close the bug report? The most important feature is to verify that our promise loop example works exactly the same as the new API feature. The new API feature allows the |
@klabarge bump. |
I've begun testing this and it seems to fallback to function printPDF() {
var config = getUpdatedConfig();
var opts = getUpdatedOptions(true);
var printData1 = [
{ type: 'pixel', format: 'pdf', flavor: 'file', data: 'assets/pdf_sample.pdf', options: opts }
];
var printData2 = [
{ type: 'pixel', format: 'html', flavor: 'file', data: 'https://google.com', options: opts }
];
qz.print(config, [printData1, printData2]).catch(displayError);
} |
The var printData = [
{ type: 'pixel', format: 'pdf', flavor: 'file', data: 'assets/pdf_sample.pdf', options: opts },
{ type: 'pixel', format: 'html', flavor: 'file', data: 'https://google.com', options: opts }
];
qz.print(config, printData).catch(displayError); But this is still invalid, as we currently don't support a mixture of different formats. |
Then I think we designed it wrong. Currently our examples show |
Our examples also show With the current implementation for It sounds like instead, you want Current implementation matches what you have documented in the wiki, each |
Changed over to array of data-arrays under 530463c |
I tested the below three scenarios, all worked flawlessly. The last unit test mixed raw and pixel printing. 1 config : many datafunction printPDF() {
var config = qz.configs.create('PDFWriter');
var printData1 = [
{ type: 'pixel', format: 'pdf', flavor: 'file', data: 'assets/pdf_sample.pdf' }
];
var printData2 = [
{ type: 'pixel', format: 'html', flavor: 'file', data: 'https://google.com' }
];
var printData3 = [
{ type: 'pixel', format: 'image', flavor: 'file', data: 'assets/img/image_sample.png' }
];
qz.print(config, [printData1, printData2, printData3]).catch(displayError);
} many configs : 1 datafunction printPDF() {
var size = {width: 4, height: 6};
var config1 = qz.configs.create("PDFWriter", {orientation: 'landscape', jobName: 'config1_landscape'});
var config2 = qz.configs.create("PDFWriter", {size: size, jobName: 'config2_size'});
var config3 = qz.configs.create("PDFWriter", {rotation: 15, jobName: 'config3_rotation'});
var printData1 = [
{ type: 'pixel', format: 'pdf', flavor: 'file', data: 'assets/pdf_sample.pdf' }
];
qz.print([config1, config2, config3], printData1).catch(displayError);
} many configs : many datafunction printPDF() {
var size = {width: 4, height: 6};
var config1 = qz.configs.create("PDFWriter", {orientation: 'landscape', jobName: 'config1_landscape'});
var config2 = qz.configs.create("PDFWriter", {size: size, jobName: 'config2_size'});
var config3 = qz.configs.create("PDFWriter", {rotation: 15, jobName: 'config3_rotation'});
var config4 = qz.configs.create("zebra");
var printData1 = [
{ type: 'pixel', format: 'pdf', flavor: 'file', data: 'assets/pdf_sample.pdf' }
];
var printData2 = [
{ type: 'pixel', format: 'html', flavor: 'file', data: 'https://google.com' }
];
var printData3 = [
{ type: 'pixel', format: 'image', flavor: 'file', data: 'assets/img/image_sample.png' }
];
var printData4 = [
'\nN\n',
'q609\n',
'Q203,26\n',
'B5,26,0,1A,3,7,152,B,"1234"\n',
'A310,26,0,3,1,1,N,"SKU 00000 MFG 0000"\n',
'A310,56,0,3,1,1,N,"QZ PRINT APPLET"\n',
'A310,86,0,3,1,1,N,"TEST PRINT SUCCESSFUL"\n',
'A310,116,0,3,1,1,N,"FROM SAMPLE.HTML"\n',
'A310,146,0,3,1,1,N,"QZ.IO"\n',
{ type: 'raw', format: 'image', flavor: 'file', data: 'assets/img/image_sample_bw.png', options: { language: 'EPL', x: 150, y: 300 } },
'\nP1,1\n'
];
qz.print([config1, config2, config4, config3], [printData1, printData2, printData4, printData3]).catch(displayError);
} |
If any of the file in printData is unavailable the printing is getting braked and not proceeding with the preceding items. |
@harikesh409 please try |
Tried giving it as a single value and as an array also but still it is not moving to the next values. qz.print(configs,data, true) If I give like this it is working but if I pass as [resumeOnError=true], as per https://qz.io/api/qz it is not working. |
Check this if (typeof arguments[2] === 'boolean') {
resumeOnError = arguments[2];
if (arguments.length >= 5) {
signatures = arguments[3];
signaturesTimestamps = arguments[4];
}
} else if (arguments.length >= 4) {
signatures = arguments[2];
signaturesTimestamps = arguments[3];
}
//ensure values are arrays for consistency
if (signatures && !Array.isArray(signatures)) { signatures = [signatures]; }
if (signaturesTimestamps && !Array.isArray(signaturesTimestamps)) { signaturesTimestamps = [signaturesTimestamps]; }
} the value of |
Sorry, it's: qz.print(configs,data, /* resumeOnError */ true); My comment with it being an object was not correct. |
Edit:
This feature is 2.1.0+, relevant commits: 6671317, 91984dd, 91984dd
The wiki provides detailed instructions for constructing and itterating through a promise loop however this could easily become part of the base API.
Proposal:
config
objectsdata
objectsfail-on-error
(break the chain) orresume-on-error
(continue the chain) behaviorExample:
The text was updated successfully, but these errors were encountered: