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. How to print text on multiple pages?
Forum Updated to NodeBB v4.3 + New Features

How to print text on multiple pages?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 930 Views 2 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.
  • A Offline
    A Offline
    adutzu89
    wrote on last edited by
    #1

    I am trying to print the details of a form but I am not sure how to do it if the information needs to be split on multiple pages.
    Am using QImage with QPainter to make a picture using drawText and then send it QPrinter to print it.
    The issue is to make the entire QImage need to send to QPainter, I don't know how I can calculate QRect's height based on the QString provided.

    Any ideeas?

    artwawA 1 Reply Last reply
    0
    • A Offline
      A Offline
      adutzu89
      wrote on last edited by
      #2

      Went with making a html document and simply printing that using WebEnginePage.

      1 Reply Last reply
      0
      • A adutzu89

        I am trying to print the details of a form but I am not sure how to do it if the information needs to be split on multiple pages.
        Am using QImage with QPainter to make a picture using drawText and then send it QPrinter to print it.
        The issue is to make the entire QImage need to send to QPainter, I don't know how I can calculate QRect's height based on the QString provided.

        Any ideeas?

        artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by
        #3

        @adutzu89 Hi.
        First thing: why are you using QImage? You can just draw text on the Painter using drawText. This way is simpler - text will be divided into pages as it goes.
        Apart from that you can request new page explicitly by calling printer.newPage().
        With QImage things complicate a bit, since print size depends on image DPI and page DPI - you can either scale the image to fit certain size you have on the page or calculate the size using DPI of the image and DPI of a printer/page.

        For more information please re-read.

        Kind Regards,
        Artur

        A 1 Reply Last reply
        1
        • artwawA artwaw

          @adutzu89 Hi.
          First thing: why are you using QImage? You can just draw text on the Painter using drawText. This way is simpler - text will be divided into pages as it goes.
          Apart from that you can request new page explicitly by calling printer.newPage().
          With QImage things complicate a bit, since print size depends on image DPI and page DPI - you can either scale the image to fit certain size you have on the page or calculate the size using DPI of the image and DPI of a printer/page.

          A Offline
          A Offline
          adutzu89
          wrote on last edited by
          #4

          @artwaw Hi and thanks for answering,
          To be honest that's what I thought to be the best course because I will also need add some small images inline with some of the text.

          artwawA 1 Reply Last reply
          0
          • A adutzu89

            @artwaw Hi and thanks for answering,
            To be honest that's what I thought to be the best course because I will also need add some small images inline with some of the text.

            artwawA Offline
            artwawA Offline
            artwaw
            wrote on last edited by artwaw
            #5

            @adutzu89 In addition, you can have more control over the format using QTextDocument - it requires a bit of a practice but is really powerful class.

            For more information please re-read.

            Kind Regards,
            Artur

            A 1 Reply Last reply
            1
            • artwawA artwaw

              @adutzu89 In addition, you can have more control over the format using QTextDocument - it requires a bit of a practice but is really powerful class.

              A Offline
              A Offline
              adutzu89
              wrote on last edited by
              #6

              @artwaw

              I understand, will try to look into it in the nearest future, thank you very much.

              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