Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Questions on producing pdf files.
Forum Updated to NodeBB v4.3 + New Features

Questions on producing pdf files.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    ngry1
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved