How to use use Generic/Text only printers with Qt? (Both Linux and Windows)
-
Hi,
I need to use dot matrix printer in my Qt program. But there is limited resources about printing. By the way all the documents and samples for graphic printing.
I set the Epson LX-300 printer as Generic/Text only printer on Win 10. But I can not use it with below code. Page is empty. I need to print invoice line by line. Not as graphic like pdf or any others.void MainWindow::on_pushButton_4_clicked()
{QTextDocument doc; doc.setHtml( "<p>A QTextDocument can be used to present formatted text " "in a nice way.</p>" "<p align=center>It can be <b>formatted</b> " "<font size=+2>in</font> <i>different</i> ways.</p>" "<p>The text can be really long and contain many " "paragraphs. It is properly wrapped and such...</p>" ); QPrinter printer; doc.print(&printer);
}
P.S. I need to use my program on both Linux and Windows platforms. So it must be good solution for the both of these if possible...
Regards,
Mucip:) -
Hi,
Did you try to use QPrintPreviewDialog to see what you should get ?
-
Hi,
Unfortunately I am still trying to understand QPrintPreviewDialog mechanism! And I can not find a enough time today.
But in any case, with the same code I can write Epson LX-350 printer on windows platform. I can see this on the page.
But the paper comes empty when I set the default printer as Generic/Text.By the way, Is there a tool like FastReport with Qt? Because FastReport was printing on the dot matrix printers too.
P.S.: I will send the result here when I test with QPrintPreviewDialog.
Regards,
Mucip:) -
There are several: QtRPT, CuteReport, LimeReport, NCReport etc.
-
Hi,
I will try this way:
I will make all output as pdf file like below way,printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName("test.pdf"); printer.setPaperSize(QSizeF(2, 2), QPrinter::Inch);
I will try to change paper size because I need to use Width 15cm x Hight 16 cm continuous form. I hope this will solve my problem. So I do not need to use Generic/text only printer if I can change the paper size in QT while sending the document. Because I don't know why but I can not change the paper size of Epson LX-350 in windows control panel. But I can change other printers like Canon. This is really strange!... :(
Regards,
Mucip:)