June 3, 2011

jasontiller jasontiller
Lab Rat
1 posts

Can’t change page orientation printing to Brother label printer in Linux

 

Hi, All, :)

My application (Ubuntu 10.04) needs to print a label. I bought the Brother QL-570 on the strength of a few positive reports of its Linux compatibility. I installed the CUPS driver and had no problem printing a test page.

However, when I try to print from Qt, the orientation of the text is incorrect. The output is formatted using simple HTML into a QTextDocument, which is printed on a QPrinter. An excerpt of this code:

  1.    QPrinter lab_printer;
  2.    lab_printer.setPrinterName( "QL-570-2" );
  3.  
  4.    // I'm using the provided sample roll of 29x90mm labels.
  5.    lab_printer.setPaperSize( QSizeF( 29, 90 ), QPrinter::Millimeter );
  6.  
  7.    lab_printer.setOrientation( QPrinter::Landscape );
  8.  
  9.    // The supplied ODT template used these margins.
  10.    lab_printer.setPageMargins( 0.11, 0.05, 0.11, 0.05, QPrinter::Inch );
  11.  
  12.    stringstream lab_html;
  13.    lab_html << "<html><body>"
  14.        "<p>1: a b c d e f g h i j k l m n o p q r s t u v w x y z"
  15.        "<p>2: a b c d e f g h i j k l m n o p q r s t u v w x y z"
  16.        "<p>3: a b c d e f g h i j k l m n o p q r s t u v w x y z"
  17.        "<p>4: a b c d e f g h i j k l m n o p q r s t u v w x y z"
  18.        "</body></html>";
  19.  
  20.    QTextDocument lab_doc;
  21.  
  22.    lab_doc.setHtml( lab_html.str().c_str() );
  23.  
  24.    lab_doc.print( &lab_printer );

The output in portrait mode is what you’d expect:

Label output in

Unfortunately, the output in landscape mode is not correct:

Label output in

I’ve verified that when printing to another printer (a Xerox Phaser) I can successfully print in landscape orientation.

Has anyone else tried to use this printer in Linux? Brother provides an SDK, but its Windows-only.

I’m considering trying a Dymo, which has a Linux-based SDK. Has anyone tried Dymos?

Thanks!

—-Jason

0 replies

 
  ‹‹ Qt internal window      Sorry, total Qt newbe question... ››

You must log in to post a reply. Not a member yet? Register here!