PDA

View Full Version : Printing issue



msk
25th May 2009, 14:07
I am Interested in printing some text on a Pre-Printed Document.
how am i supposed to align the text & print it on the Document ?

faldzip
25th May 2009, 14:27
take a look at QTextDocument and QTextEdit (which uses QTextDocument).
Another thing would be to use QGraphicsView where your QGraphicsScene would have the existing content as background and then you can use QGraphicsTextItem to position some additional text, and at the end you can render scene to the printer.
Hope that I understood you right :]

msk
25th May 2009, 14:41
The "Pre-Printed Document" am i referring to is a Pre-Printed Paper , ie some printing has been done on a paper sheet , now i need to print some additional text at some desired locations on the paper.

faldzip
25th May 2009, 14:57
So you can take a look at this example: http://doc.qtsoftware.com/4.5/demos-textedit.html and you can find it in Qt Examples & Demos -> Demonstrations -> Text Edit.

As for the solution with QGraphicsView you can make something like page preview with QGraphicsTextItems in it, and make some of these items be editable and maybe movable

lni
25th May 2009, 16:25
Use a typewriter ;)

msk
26th May 2009, 15:08
@Ini : No need of Typewriter ! ;)

i found a solution.i used QPainter::drawText() to align the text at a desired location on the Pre-Printed form (paper)

Here is the Code :

QPrinter printer(QPrinter::HighResolution);
printer.setPaperSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setFullPage(true);
QPainter painter(&printer);
QPointF pt;
pt.setX(20 * (printer.width()/printer.widthMM()));
pt.setY(20 * (printer.height()/printer.heightMM())) ;

painter.drawText ( pt, "prints at 20mm X 20mm");

----

Thanks all , for Replying .:)