We are encountering a problem with the pdfium module in WebKit during Playwright testing. The provided sample code is designed to inform the client side once both the document and pdfium.wasm has been successfully loaded. This code ensures that both the pdfium module and the DOM are fully loaded before proceeding.
<!DOCTYPE html>
<html lang="en">
<head>
<script src="pdfium.js"></script>
<script>
window.createDivElement = function (value) {
var divElement = document.createElement("div");
divElement.textContent = value;
divElement.style = "Left:20px;Width: 300px; Height:50px"
document.body.appendChild(divElement);
}
document.addEventListener("DOMContentLoaded", function () {
let pageLoaded = false;
let moduleLoaded = false;
window.createDivElement("Start DOM Loading...");
// Module. onRuntimeInitialized will be called from pdfium.js to notify the user for further process
Module.onRuntimeInitialized = async _ => {
moduleLoaded = true;
window.createDivElement("PDFIUM Module Loaded...");
checkIfEverythingWasLoaded();
};
function checkIfEverythingWasLoaded() {
if (pageLoaded && moduleLoaded) {
window.createDivElement("Both Page and M odule loaded...");
}
}
window.onload = function (e) {
window.createDivElement("Page Loaded...");
pageLoaded = true;
checkIfEverythingWasLoaded();
}
});
</script>
</head>
<body>
@RenderBody()
<script src="_framework/blazor.server.js"></script>
</body>
</html>
Please find the blazor sample: WEBKIT~1739968950.zip
The table below illustrates the outcomes of executing the aforementioned code in both Chrome and WebKit. In the case of WebKit (Playwright), the Module.onRuntimeInitialized event fails to trigger, preventing us from proceeding with subsequent steps to read the document.
For image reading, we utilized pdfium.wasm, loading only the pdfium.js file into the application. The pdfium.js file, in turn, loads the pdfium.wasm file independently and notifies the success handler for further processing. This mechanism functions correctly in major browsers such as Chrome, Edge, Firefox, and Safari. However, it encounters an issue in the webkit environment.
Upon closer examination, we found that within the
pdfium.js file, WebAssembly.instantiateStreaming is employed to read the .wasm
file. However, in Safari, this method fails to return either a success or
failure handler.
Can anyone redirect us if you have
any idea on this?
Note :
We used the below comment to run the application in WebKit with Node version v16.20.1
--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/bbc43b2a-63d1-48ce-97f1-bebc289e7585n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/CACwGi-4hRiJ6sFKUvbc%2BmpnHX7dxt-z4_bfqn0DkfyzpPKw3uQ%40mail.gmail.com.