无法指定正确的打印尺寸 [英] Cannot specify the correct size for printing

查看:221
本文介绍了无法指定正确的打印尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们购买了

这是有问题的代码:

PrinterJob 作业 = PrinterJob.getPrinterJob();PageFormat pf = job.defaultPage();纸 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);如果(job.printDialog()){尝试 {作业.打印();} catch (Exception PrintException) {PrintException.printStackTrace();}}



我可以确认打印机可以按我们喜欢的任何长度打印,如下面的屏幕截图所示(使用 Brother 的 P-touch 编辑器).注意虽然是可调的,但是36mm是软件自己预设的:

问题:

如何强制纸张的length"精确到40mm?

相关:标签打印机的自定义纸张尺寸 (Brother QL 570)>

编辑

我进行了媒体尺寸查询(代码),以下是它可以支持的媒体列表:

17 毫米 x 54 毫米:宽度 = 0.67;高度 = 2.1217 毫米 x 87 毫米:宽度 = 0.67;高度 = 3.4223 毫米 x 23 毫米:宽度 = 0.9066535;高度 = 0.9066535iso-b10:宽度= 1.2204725;高度 = 1.732283529 毫米 x 90 毫米:宽度 = 1.14;高度 = 3.536653538 毫米 x 90 毫米:宽度 = 1.4966536;高度 = 3.536653539 毫米 x 48 毫米:宽度 = 1.5366535;高度 = 1.883346452 毫米 x 29 毫米:宽度 = 1.1366535;高度 = 2.0466535iso-b8:宽度 = 2.440945;高度 = 3.46456762 毫米 x 29 毫米:宽度 = 1.1366535;高度 = 2.4462 毫米 x 100 毫米:宽度 = 2.44;高度 = 3.9312 毫米直径:宽度 = 0.47334644;高度 = 0.4733464423 毫米 x 23 毫米:宽度 = 0.9066535;高度 = 0.906653558 毫米直径:宽度 = 2.2933464;高度 = 2.293346412 毫米:宽度 = 0.47334644;高度 = 3.936653629 毫米:宽度 = 1.14;高度 = 3.936653638 毫米:宽度 = 1.4966536;高度 = 3.936653650 毫米:宽度 = 1.9666536;高度 = 3.936653654 毫米:宽度 = 2.1266534;高度 = 3.936653662 毫米 x 100 毫米:宽度 = 2.44;高度 = 3.9312 毫米 x2:宽度 = 0.82665354;高度 = 3.936653654 毫米:宽度 = 2.1266534;高度 = 3.936653638 毫米 x2:宽度 = 2.8733466;高度 = 3.936653650 毫米 x2:宽度 = 3.8133464;高度 = 3.936653654 毫米 x2:宽度 = 3.9366536;高度 = 4.093346662 毫米 x2:宽度 = 3.9366536;高度 = 4.7629 毫米:宽度 = 1.14;高度 = 3.936653629 毫米 x3:宽度 = 3.18;高度 = 3.936653638 毫米 x3:宽度 = 3.9366536;高度 = 4.2550 毫米 x3:宽度 = 3.9366536;高度 = 5.6654 毫米 x3:宽度 = 3.9366536;高度 = 6.0662 毫米 x3:宽度 = 3.9366536;高度 = 7.0838 毫米:宽度 = 1.4966536;高度 = 3.936653629 毫米 x4:宽度 = 3.9366536;高度 = 4.238 毫米 x4:宽度 = 3.9366536;高度 = 5.626653750 毫米 x4:宽度 = 3.9366536;高度 = 7.506653354 毫米 x4:宽度 = 3.9366536;高度 = 8.02665362 毫米 x4:宽度 = 3.9366536;高度 = 9.429 毫米 x 90 毫米:宽度 = 1.14;高度 = 3.536653538 毫米 x 90 毫米:宽度 = 1.4966536;高度 = 3.5366535小地址标签:宽度 = 1.1366535;高度 = 2.4417 毫米 x 54 毫米:宽度 = 0.67;高度 = 2.1262 毫米 x 100 毫米:宽度 = 2.44;高度 = 3.9362 毫米 x 100 毫米:宽度 = 2.44;高度 = 3.9317 毫米 x 87 毫米:宽度 = 0.67;高度 = 3.4217 毫米 x 54 毫米:宽度 = 0.67;高度 = 2.12活页夹 3 厘米 - 脊柱:宽度 = 1.14;高度 = 8.226653活页夹 5 厘米 - 脊柱:宽度 = 2.44;高度 = 8.22665358 毫米直径:宽度 = 2.2933464;高度 = 2.293346412 毫米直径:宽度 = 0.47334644;高度 = 0.4733464423 毫米 x 23 毫米:宽度 = 0.9066535;高度 = 0.906653523 毫米 x 23 毫米:宽度 = 0.9066535;高度 = 0.906653562 毫米 x 184 毫米邮资标签:宽度 = 2.44;高度 = 7.24活页夹 5 厘米 - 脊柱:宽度 = 2.44;高度 = 8.226653

编辑(2017 年 4 月)

只是为了更新这个问题的状态.最后我使用 python 和一个开源实用程序 brother_ql 解决了这个问题,它将工作发送到甚至不用兄弟提供的固件,直接usb口.它运行良好并解决了我的问题.

解决方案

没有比 here

那也不要混淆height和length和width,java中的paper类取的是width和height而不是length

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

你可能还想考虑这个

/*** 设置此<code>Paper</code> 的可成像区域.这* 可成像区域是页面上打印的区域* 发生.* @param x 要设置的 X 坐标* 此<code>Paper</code> 的可成像区域的左上角* @param y 要设置的 Y 坐标* 此<code>Paper</code> 的可成像区域的左上角* @param width 设置宽度的值* 此<code>Paper</code> 的可成像区域* @param height 设置高度的值* 此<code>Paper</code> 的可成像区域*/公共无效setImageableArea(双x,双y,双倍宽度,双倍高度){mImageableArea = new Rectangle2D.Double(x, y, width,height);}

这些只是paper类中的一些方法,您可能想在实现更多时查看,因此参数..希望它有帮助:)

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.

解决方案

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 :)

这篇关于无法指定正确的打印尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆