Please nominate your Qt Champions for 2021!

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:

    QPrinter lab_printer;
    lab_printer.setPrinterName( "QL-570-2" );

    // I'm using the provided sample roll of 29x90mm labels.
    lab_printer.setPaperSize( QSizeF( 29, 90 ), QPrinter::Millimeter );

    lab_printer.setOrientation( QPrinter::Landscape );

    // The supplied ODT template used these margins.
    lab_printer.setPageMargins( 0.11, 0.05, 0.11, 0.05, QPrinter::Inch );

    stringstream lab_html;
    lab_html << "<html><body>"
    "<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"
    "<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"
    "<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"
    "<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"

    QTextDocument lab_doc;

    lab_doc.setHtml( lab_html.str().c_str() );

    lab_doc.print( &lab_printer );

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

    ! output in "Portrait" orientation)!

    Unfortunately, the output in landscape mode is not correct:

    ! output in "Landscape" orientation)!

    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?



Log in to reply