I Trying print Html using qwebenginepage but not working i searched a lot to resolve this problem but didn't found the answer .
i was use QTextBrowser But when print it change style of page so i trying with qwebenginepage
QWebEnginePage *view = new QWebEnginePage;
QFile file("/home/hackerpoint/Desktop/some.html");
if(file.open(QIODevice::Text | QIODevice::ReadOnly)){
QString html = file.readAll();
QPrinter print(QPrinter::HighResolution);
print.setPageSize(QPrinter::A4);
print.setFullPage(true);
print.setOutputFormat(QPrinter::PdfFormat);
print.setOutputFileName("somefile.pdf");
view->setHtml(html);
if(&QWebEnginePage::loadFinished){
view->print(&print , [=](bool){});
}
else {
qInfo() << "Html Not loaded";
}
}
and this the error
1 QPrinter::toPage() const
2 QtWebEngineCore::PrinterWorker::print()
3 QtWebEngineCore::PrinterWorker::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *)
4 QObject::event(QEvent *)
5 QApplicationPrivate::notify_helper(QObject *, QEvent *)
6 QApplication::notify(QObject *, QEvent *)
7 QCoreApplication::notifyInternal2(QObject *, QEvent *)
8 QCoreApplicationPrivate::sendPostedEvents(QObject *, int, QThreadData *)
9 postEventSourceDispatch(_GSource *, int ( *)(void *), void *)
10 g_main_context_dispatch
11 ___lldb_unnamed_symbol354$$libglib-2.0.so.0
12 g_main_context_iteration
13 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
14 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
15 QThread::exec()
16 QThreadPrivate::start(void *)
17 start_thread
18 __GI___clone