I'm trying to print a single-page PDF with a specific dimension onto a label (or ribbon). Let's say for this example the dimensions are 0.63" wide and 11.81" long.
I'm using QZ Tray to handle printing directly from the browser.
The problem
The printer has default size parameters defined on the computer, and if I try printing my PDF directly using QZ Tray's pixel printing the size of the PDF is ignored, and instead the "default" size is used.
I switched to QZ Tray's raw printing in EPL format with the q
and Q
parameters added to the command so the size of the media is adjusted.
This results in the following data being used for printing:
const data = [
'\nN\n',
'q' + pdfData.width.dots + '\n',
'Q' + pdfData.height.dots + ',00\n',
{
type: 'raw', format: 'pdf', flavor: 'base64', data: pdfData.file,
options: { language: "EPL" }
},
'\nP1\n';
];
qz.print(config, data).catch(function (e) {
console.error(e);
});
Even though I can now successfully override the printer's default size, it appears the PDF is not aligned correctly anymore (an empty label is "printed" instead).
There have been some instances in which I did see something being printed "outside" of the label (I'm printing using thermal transfer).
I have also played around with the pageSize options for the PDF in the printer configuration, but these seem to have no impact, or at least result in the same blank label being printed.
Question
Is there a way in QZ Tray which allows me to ensure the PDF is alligned propperly on the label. Or is there another way to approach this issue?
Note
The PDF is the only content on the label and the page size is the exact size that the label should be.