KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My code produces pdf by rendering QGraphicsScene content onto properly initialized QPrinter. While dealing with application such text can be edited, copied into clipboard etc. How can I produce pdf from QGraphicsScene, where my text string can be also copied, or it is impossible and I need to create QTextDocument for such tasks? QGraphicsTextItem* textItem = new QGraphicsTextItem ( text ); textItem->setPlainText ( text ); textItem->setTextInteractionFlags ( Qt::TextEditorInteraction ); textItem->setFlags( QGraphicsItem::ItemIsSelectable | textItem->flags() ); scene->addItem( textItem ); QPrinter pdfPrinter; pdfPrinter.setOutputFormat( QPrinter::PdfFormat ); pdfPrinter.setPaperSize( QSize(scene->width(), scene->height()), QPrinter::Point ); pdfPrinter.setFullPage(true); pdfPrinter.setOutputFileName( path ); QPainter pdfPainter; pdfPainter.begin( &pdfPrinter); scene->render( &pdfPainter ); pdfPainter.end();
Tags (comma-separated)
Save Edits
Cancel