Questions on producing pdf files.
-
The first question is how to producing pdf files from QGraphicsScene with "copyable/searchable" text?
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, with the ability to copy my text string, or it is impossible and I need to create QTextDocument instead?
@
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();
@And the second question:
suppose we have QPixmap items on the scene, how can I control the quality and a compression codec in generated pdf file by the method of first question?I suppose there are a way similar to "codecs" approach to read specific image format, so may be I need to implement such plugin to store, for example, JBIG2 compressed pixmaps, into generated pdfs? Am I wrong? Any suggestions, code snippets appreciated.