How can I convert html file to pdf
-
wrote on 15 Mar 2023, 10:20 last edited by
I am trying to convert html file saved on my drive to pdf file, I have followed this link https://doc.qt.io/qt-6/qtwebengine-webenginewidgets-html2pdf-example.html
But here they have used url but I need a html file to pdf convertor. I tried loading from the file, But the pdf seems empty.Can anybody help me here to solve the issue. I am new to Qt I am totally getting lost.
-
I am trying to convert html file saved on my drive to pdf file, I have followed this link https://doc.qt.io/qt-6/qtwebengine-webenginewidgets-html2pdf-example.html
But here they have used url but I need a html file to pdf convertor. I tried loading from the file, But the pdf seems empty.Can anybody help me here to solve the issue. I am new to Qt I am totally getting lost.
wrote on 15 Mar 2023, 14:56 last edited by JonB@Bhavith-C
There are several ways you might do this. But if you are happy with that example code you can use it to read the HTML from a local file via a suitable URL. Where that code goesm_view->load(QUrl::fromUserInput(m_inputPath));
you should be able to change it to use QUrl QUrl::fromLocalFile(const QString &localFile) on, say, the full path to a specified local file.
2/2