I am following this example: How to print from QWebEngineView:
QWebEnginePage page;
QString outputPath="/home/output.pdf";
QString inputPath="/home/input.html";
QObject::connect(&page, &QWebEnginePage::loadFinished, [&page](){page.printToPdf(outputPath); qDebug()<<123;});
page.load(QUrl::fromLocalFile(inputPath));
The code executed without error, but there is no PDF printed, and no debug message either (the slot never executed?).
What am I missing?
QWebEnginePage::printToPdfsays:QWebEnginePage::pdfPrintingFinishedsays:This outputs:
This means there's no problem with loading the HTML file, since it got to the printing.
Check for writing permission using
QFileInfo::isWritable:Use
QDir::homePath()to get the absolute path of the user's home directory:This outputs: