diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 3830a3ea24ac14c18218620bac55228836c1a2a5..f5350f5354c6d18c37fc839eedab00cb693b2802 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -1309,6 +1309,10 @@ void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId
     QPageLayout pageLayout(layoutSize, layoutOrientation, QMarginsF(0.0, 0.0, 0.0, 0.0));
 
     d->adapter->printToPDF(pageLayout, filePath);
+#else
+    Q_UNUSED(filePath);
+    Q_UNUSED(pageSizeId);
+    Q_UNUSED(orientation);
 #endif
 }
 
@@ -1326,6 +1330,9 @@ void QQuickWebEngineView::printToPdf(const QJSValue &callback, PrintedPageSizeId
     quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout);
     d->m_callbacks.insert(requestId, callback);
 #else
+    Q_UNUSED(pageSizeId);
+    Q_UNUSED(orientation);
+
     // Call back with null result.
     QJSValueList args;
     args.append(QJSValue(QByteArray().data()));
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index f769ea0f4f82c8ba10a6bb4e23f895c301f876fd..16e9438c9b61362b736847790ccc2f2d4889d825 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -1957,6 +1957,9 @@ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &page
     }
 #endif
     d->adapter->printToPDF(pageLayout, filePath);
+#else
+    Q_UNUSED(filePath);
+    Q_UNUSED(pageLayout);
 #endif // if defined(ENABLE_PDF)
 }
 
@@ -1990,6 +1993,7 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res
     quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout);
     d->m_callbacks.registerCallback(requestId, resultCallback);
 #else // if defined(ENABLE_PDF)
+    Q_UNUSED(pageLayout);
     d->m_callbacks.invokeEmpty(resultCallback);
 #endif // if defined(ENABLE_PDF)
 }
@@ -2025,6 +2029,7 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re
     quint64 requestId = d->adapter->printToPDFCallbackResult(printer->pageLayout(), printer->colorMode() == QPrinter::Color);
     d->m_callbacks.registerCallback(requestId, resultCallback);
 #else // if defined(ENABLE_PDF)
+    Q_UNUSED(printer);
     d->m_callbacks.invokeDirectly(resultCallback, false);
 #endif // if defined(ENABLE_PDF)
 }