Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot specify the correct size for printing

We have acquired a brother QL-700 printer recently and we are doing some sticker printing through this machine.

The paper that we have been feeding is a 62mm-wide sticker roll without "length" restriction.

The issue is, no matter how I do (I've tried Book, PrintRequestAttributeSet), I couldn't use Java to tells the printer dialog window to use the correct paper size for the printer. I couldn't make it, for example, exact 62mm × 40mm as we needed. It always "snap" to a nearest paper as it like:

Here is the code in question:

PrinterJob job = PrinterJob.getPrinterJob();
PageFormat pf = job.defaultPage();
Paper p = pf.getPaper();
p.setSize(UnitConv.mm2pt(62), UnitConv.mm2pt(40));
p.setImageableArea(0, 0, UnitConv.mm2pt(62), UnitConv.mm2pt(40));
pf.setPaper(p);
pf.setOrientation(PageFormat.LANDSCAPE);

job.setPrintable(this, pf);

if (job.printDialog()) {
    try {
        job.print();
    } catch (Exception PrintException) {
        PrintException.printStackTrace();
    }
}



I can confirm that the printer can print at any length as we like, as shown in the screenshot below (Using Brother's P-touch editor). Notice although it's adjustable, but the 36mm was preset by the software itself:

So Question:

How to force the "length" of the paper to be exact 40mm?

Relevant: custom paper size for labelprinter (Brother QL 570)

Edit

I did a media size query (code) and here is the list of media that it can support:

17 mm x 54 mm: width = 0.67; height = 2.12
17 mm x 87 mm: width = 0.67; height = 3.42
23 mm x 23 mm: width = 0.9066535; height = 0.9066535
iso-b10: width = 1.2204725; height = 1.7322835
29 mm x 90 mm: width = 1.14; height = 3.5366535
38 mm x 90 mm: width = 1.4966536; height = 3.5366535
39 mm x 48 mm: width = 1.5366535; height = 1.8833464
52 mm x 29 mm: width = 1.1366535; height = 2.0466535
iso-b8: width = 2.440945; height = 3.464567
62 mm x 29 mm: width = 1.1366535; height = 2.44
62 mm x 100 mm: width = 2.44; height = 3.93
12 mm Dia: width = 0.47334644; height = 0.47334644
23 mm x 23 mm: width = 0.9066535; height = 0.9066535
58 mm Dia: width = 2.2933464; height = 2.2933464
12 mm: width = 0.47334644; height = 3.9366536
29 mm: width = 1.14; height = 3.9366536
38 mm: width = 1.4966536; height = 3.9366536
50 mm: width = 1.9666536; height = 3.9366536
54 mm: width = 2.1266534; height = 3.9366536
62 mm x 100 mm: width = 2.44; height = 3.93
12 mm x2: width = 0.82665354; height = 3.9366536
54 mm: width = 2.1266534; height = 3.9366536
38 mm x2: width = 2.8733466; height = 3.9366536
50 mm x2: width = 3.8133464; height = 3.9366536
54 mm x2: width = 3.9366536; height = 4.0933466
62 mm x2: width = 3.9366536; height = 4.76
29 mm: width = 1.14; height = 3.9366536
29 mm x3: width = 3.18; height = 3.9366536
38 mm x3: width = 3.9366536; height = 4.25
50 mm x3: width = 3.9366536; height = 5.66
54 mm x3: width = 3.9366536; height = 6.06
62 mm x3: width = 3.9366536; height = 7.08
38 mm: width = 1.4966536; height = 3.9366536
29 mm x4: width = 3.9366536; height = 4.2
38 mm x4: width = 3.9366536; height = 5.6266537
50 mm x4: width = 3.9366536; height = 7.5066533
54 mm x4: width = 3.9366536; height = 8.026653
62 mm x4: width = 3.9366536; height = 9.4
29 mm x 90 mm: width = 1.14; height = 3.5366535
38 mm x 90 mm: width = 1.4966536; height = 3.5366535
Small Address Label: width = 1.1366535; height = 2.44
17 mm x 54 mm: width = 0.67; height = 2.12
62 mm x 100 mm: width = 2.44; height = 3.93
62 mm x 100 mm: width = 2.44; height = 3.93
17 mm x 87 mm: width = 0.67; height = 3.42
17 mm x 54 mm: width = 0.67; height = 2.12
Binder 3 cm - Spine: width = 1.14; height = 8.226653
Binder 5 cm - Spine: width = 2.44; height = 8.226653
58 mm Dia: width = 2.2933464; height = 2.2933464
12 mm Dia: width = 0.47334644; height = 0.47334644
23 mm x 23 mm: width = 0.9066535; height = 0.9066535
23 mm x 23 mm: width = 0.9066535; height = 0.9066535
62 mm x 184 mm Postage Label: width = 2.44; height = 7.24
Binder 5 cm - Spine: width = 2.44; height = 8.226653

Edit (April 2017)

Just to update the status of this question. In the end I solved it by using python, and an open source utility brother_ql that it send jobs to the usb port directly without even using the firmware provided by brother. It works perfectly fine and solved my issue.

like image 510
Lionel Chan Avatar asked Nov 10 '16 09:11

Lionel Chan


People also ask

Why is my printer printing on the wrong size?

Check the paper size setting to make sure it matches the paper you want to print. Some printers have an option to ignore the error and continue printing. If you choose to ignore the error, the margins on your printout might not be proportional to the edges of the paper. In the program you want to print from, click File, and then click Print.

How do I select the correct paper size for printing?

Click Advanced, if necessary, and then click Paper Size. Figure : Selecting the correct paper size Select the paper size that matches the size and type of paper loaded in the printer tray, and then click OK. If there are no matching paper sizes, select the size from the list that is closest to the size of the paper loaded in the tray.

How do I control the size of a print?

There are couple of ways to control the size of a print: Select the paper size and then load the appropriate paper into the printer to accomodate the print Select Paper size as Letter, Select type as Plain or Photo Paper, and then Select the PRINT SIZE (right column)

How do I add a custom size to my printer?

In the meantime, let's try to add the custom size on your printer properties and see if it address the problem. To do that, follow these steps: Right-click the Windows key, then click Control Panel. Go to Devices and Printers. Select the appropriate Printer.


1 Answers

there's no better way to answer like here

then also don't confuse height and length and width, the paper class in java takes width and height not length

 public void setSize(double width, double height) {
    mWidth = width;
    mHeight = height;

you might also want to consider this

   /**
 * Sets the imageable area of this <code>Paper</code>.  The
 * imageable area is the area on the page in which printing
 * occurs.
 * @param x the X coordinate to which to set the
 * upper-left corner of the imageable area of this <code>Paper</code>
 * @param y the Y coordinate to which to set the
 * upper-left corner of the imageable area of this <code>Paper</code>
 * @param width the value to which to set the width of the
 * imageable area of this <code>Paper</code>
 * @param height the value to which to set the height of the
 * imageable area of this <code>Paper</code>
 */
public void setImageableArea(double x, double y,
                             double width, double height) {
    mImageableArea = new Rectangle2D.Double(x, y, width,height);
}

those are just some of the methods inside the paper class you might want to take a look at when it comes to implementation more so the parameters.. hope it helps :)

like image 144
sea Avatar answered Sep 28 '22 10:09

sea