2016-11-10 13 views
10

最近、brother QL-700プリンタを取得しました。このマシンでいくつかのステッカー印刷を行っています。印刷に適切なサイズを指定できません

私たちが供給している紙は、長さが制限されていない62mm-wide sticker rollです。

問題は、どのようにしても(私はBookPrintRequestAttributeSetを試しました)、Javaを使用してプリンタの正しいサイズの用紙を使用するようプリンタのダイアログウィンドウに指示することができませんでした。私はそれを作ることができませんでした、例えば、正確に62mm × 40mm必要でした。

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(); 
    } 
} 



私は、プリンタが任意の長さで印刷できることを確認することができます

ここ

は、問題のコードです:それは好きなようにそれは常に最も近い紙に「スナップ」下記のスクリーンショット(ブラザーのP-touchエディタの使用)に示されているように、私たちが好きなように。お知らせそれは調整可能だが、36mmは、ソフトウェア自体によって予め設定されたものの:

そこで質問:

正確な40ミリメートルであることを紙の「lengthを」強制的にどのように?

関連: custom paper size for labelprinter (Brother QL 570)

編集

私は、メディアサイズのクエリ(code)を行なったし、ここでそれがサポートできるメディアのリストは以下のとおりです。

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 

編集( 2017年4月)

この質問のステータスを更新するだけです。最後に私はpythonとオープンソースユーティリティbrother_qlを使って、兄が提供するファームウェアを使用せずに直接USBポートにジョブを送信することで解決しました。それは完璧に動作し、私の問題を解決しました。

答えて

1

、その後も高さと長さと幅を混同しないでくださいhere

のように答えるには良い方法はありません、Javaで紙のクラスは、幅と高さを要しない長さ

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

あなたにもお勧めしますこれを考慮する

/** 
* 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); 
} 

これはペーパークラス内のメソッドのほんの一部ですが、インプリより多くのパラメータを調整してください。 助けて欲しいです:)

+1

ありがとうございました。プリンタの問題は、設定したサイズに関係なく、プリンタサービスは、62mm x * mmサイズの用紙を印刷することができるため、プリンタでは正しくない最も近い次元に常に「スナップ」しているようです。彼らが提供したソフトウェアは、それが実行できることを証明しましたが、Javaではできませんでした。どういうわけか、正しい組み合わせが得られないか、Javaサービスがそれをサポートしていないかのいずれかです。 –

0

私は多くの時間を見てきましたPapersetSizeパラメータが保持されているピクセルサイズを渡しています。をmm2pxのように変更しようとしますか?

PrinterJob job = PrinterJob.getPrinterJob(); 
PageFormat pf = job.defaultPage(); 
Paper p = pf.getPaper(); 
int resolution = 72; // dpi 
p.setSize(UnitConv.mm2px(62, resolution), UnitConv.mm2px(40, resolution)); 
p.setImageableArea(0, 0, UnitConv.mm2px(62, resolution), UnitConv.mm2px(40, resolution)); 
pf.setPaper(p); 
pf.setOrientation(PageFormat.LANDSCAPE); 

job.setPrintable(this, pf); 

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

運がよかったです。それはまだ最も近い変種 "58mm Dia"を選択しています。 –

0

あなたは​​を提出しながら、PrintRequestAttributeを使用する必要があります。カスタム印刷メディアサイズが機能しない場合は、検出されたメディアサイズをquery codeで使用し、要求属性セットに最適なサイズを選択することができます。

@Test 
public void testMyPrinteService() { 
    // select default or specific one here 
    PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); 

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

    Printable myPrintable = null ;//some printable new MyPrintable(1); 
    PrintRequestAttributeSet printReqAttrs = new HashPrintRequestAttributeSet(); 
    PrintRequestAttribute jobPrinArea = new MediaPrintableArea(0, 0, 64, 40, MediaPrintableArea.MM); 
    printReqAttrs.add(jobPrinArea); 

    if (job.printDialog(printReqAttrs)) { 
     try { 
      job.setPrintable(myPrintable, pf); 
      job.setPrintService(printService); 
      //pass specific attributes to printer 
      job.print(printReqAttrs); 
     } catch (Exception PrintException) { 
      PrintException.printStackTrace(); 
     } 
    } 
} 

は、この情報がお役に立てば幸いです。

+0

これを行うと、Javaのデフォルトのプロンプトが表示されますが、プリンタはジョブを取得することを拒否し、その場でキャンセルします。私はこの方法で印刷することはできません:(http://imgur.com/Hj77T7H –