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. Insert an URL by using QPainter and QPdfWriter

Insert an URL by using QPainter and QPdfWriter

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 577 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.
  • O Offline
    O Offline
    Omicron91
    wrote on last edited by
    #1

    Hello guys, i'm developing a software to render quotes in a pdf as shown bellow.

    alt text

    I would like to know if is there a way to draw text with HTML code or something else to display an URL. I know I can achieve this by using QTextDocument instead QPdfWriter, however, I would like to continue working with pdfwriter.

    Thanks in advance!

    artwawA 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      I don't think its possible since it using Qpainter and hence its pure text and not
      a PDF type of interactive.

      But looking around in the code , i saw
      void QPdfEngine::drawHyperlink(const QRectF &r, const QUrl &url)

      but it seems we cant access it.

      1 Reply Last reply
      0
      • O Omicron91

        Hello guys, i'm developing a software to render quotes in a pdf as shown bellow.

        alt text

        I would like to know if is there a way to draw text with HTML code or something else to display an URL. I know I can achieve this by using QTextDocument instead QPdfWriter, however, I would like to continue working with pdfwriter.

        Thanks in advance!

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

        @Omicron91 Hi, the right (I think) way to go about this is to create properly structured QTextDocument with links and such and then do QTextDocument::print() on QPrinter set to print as pdf.

        For more information please re-read.

        Kind Regards,
        Artur

        1 Reply Last reply
        1
        • O Offline
          O Offline
          Omicron91
          wrote on last edited by Omicron91
          #4

          Solved!

          I managed it using a QTextDocument to store a Rich Text, then the painter::translate() and QTextDocument ::drawContents() methods to insert the content in my pdf file.

          alt text

          @artwaw The way to create a report by using html will be ok if I could add css style, but the subset embbedded in Qt is very poor. I was looking the option of using QWebEngine which allow you to create a web view with html and css files, but you need to compile it with MSVC and for some reason it doesn't work as well for me as MinGW.

          Thanks everyone!

          1 Reply Last reply
          1

          • Login

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