Insert an URL by using QPainter and QPdfWriter
-
Hello guys, i'm developing a software to render quotes in a pdf as shown bellow.
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!
-
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.
-
Hello guys, i'm developing a software to render quotes in a pdf as shown bellow.
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!
@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.
-
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.
@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!