diff options
| author | Moss Heim <moss.heim@qt.io> | 2024-05-27 17:08:34 +0200 |
|---|---|---|
| committer | Moss Heim <moss.heim@qt.io> | 2024-06-03 07:52:31 +0000 |
| commit | ece3b065828bc6ca09dd2ad8654b48cdaddf1178 (patch) | |
| tree | 1e0673a15f07bf80e3bd3f66ad97d57fe8306f57 /src/core/api/qwebenginepage.cpp | |
| parent | 8fa02a184ea53989425865c8e98c399faceea66e (diff) | |
Add QWebEngineFrame::printToPdf
Provide API calls to (1) save to file (QString) and (2) get the bytes
in a callback.
Pick-to: 6.8
Change-Id: I0ff44a25328b99080491b8c3b36a7b632c065131
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/api/qwebenginepage.cpp')
| -rw-r--r-- | src/core/api/qwebenginepage.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp index 7c6a53d0f..d7ab70305 100644 --- a/src/core/api/qwebenginepage.cpp +++ b/src/core/api/qwebenginepage.cpp @@ -275,15 +275,17 @@ void QWebEnginePagePrivate::loadFinished(QWebEngineLoadingInfo info) } void QWebEnginePagePrivate::printToPdf(const QString &filePath, const QPageLayout &layout, - const QPageRanges &ranges) + const QPageRanges &ranges, quint64 frameId) { - adapter->printToPDF(layout, ranges, filePath); + adapter->printToPDF(layout, ranges, filePath, frameId); } void QWebEnginePagePrivate::printToPdf(std::function<void(QSharedPointer<QByteArray>)> &&callback, - const QPageLayout &layout, const QPageRanges &ranges) + const QPageLayout &layout, const QPageRanges &ranges, + quint64 frameId) { - adapter->printToPDFCallbackResult(std::move(callback), layout, ranges); + adapter->printToPDFCallbackResult(std::move(callback), layout, ranges, /*colorMode*/ true, + /*useCustomMargins*/ true, frameId); } void QWebEnginePagePrivate::didPrintPageToPdf(const QString &filePath, bool success) @@ -1692,7 +1694,7 @@ void QWebEnginePagePrivate::printRequested() This signal is emitted when the JavaScript \c{window.print()} method is called on \a frame. If the frame is the main frame, \c{printRequested} is emitted instead. - \sa printRequested(), printToPdf() + \sa printRequested(), printToPdf(), QWebEngineFrame::printToPdf() */ void QWebEnginePagePrivate::printRequestedByFrame(quint64 frameId) @@ -2330,7 +2332,7 @@ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &layo #if QT_CONFIG(webengine_printing_and_pdf) Q_D(QWebEnginePage); d->ensureInitialized(); - d->printToPdf(filePath, layout, ranges); + d->printToPdf(filePath, layout, ranges, WebContentsAdapter::kUseMainFrameId); #else Q_UNUSED(filePath); Q_UNUSED(layout); @@ -2362,7 +2364,7 @@ void QWebEnginePage::printToPdf(const std::function<void(const QByteArray&)> &re if (resultCallback && result) resultCallback(*result); }; - d->printToPdf(std::move(wrappedCallback), layout, ranges); + d->printToPdf(std::move(wrappedCallback), layout, ranges, WebContentsAdapter::kUseMainFrameId); #else Q_UNUSED(layout); Q_UNUSED(ranges); |
