Closed ahuang11 closed 1 month ago
Attention: Patch coverage is 8.69565%
with 21 lines
in your changes missing coverage. Please review.
Project coverage is 55.72%. Comparing base (
cc86118
) to head (bf50af8
). Report is 9 commits behind head on main.
Files with missing lines | Patch % | Lines |
---|---|---|
lumen/views/base.py | 8.69% | 21 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Was really rather hoping this could happen on the frontend.
I'm not sure it's possible to do with frontend.
Did some testing with https://docs.profiling.ydata.ai/latest/examples/census/census_report.html
Uncaught SecurityError: Failed to read a named property 'print' from 'Window': Blocked a frame with origin "null" from accessing a cross-origin frame.
at openAndPrintIframe (testdl.html:17:38)
at HTMLButtonElement.onclick (testdl.html:10:44)
(Same issue if I save the census_report.html locally)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Iframe Print Example</title>
</head>
<body>
<iframe id="myIframe" src="https://docs.profiling.ydata.ai/latest/examples/census/census_report.html" width="600" height="400"></iframe>
<button onclick="openAndPrintIframe()">Open and Print Iframe</button>
<script>
function openAndPrintIframe() {
var iframe = document.getElementById('myIframe');
console.log(iframe);
if (iframe) {
iframe.contentWindow.focus();
iframe.contentWindow.print();
} else {
console.error("Iframe not found");
}
}
</script>
</body>
</html>
However, I can't automate the two step process
var newWindow = window.open(iframe.src);
newWindow.onload = function() {
newWindow.print();
};
import panel as pn
pn.extension()
iframe = pn.pane.HTML( '' )
button = pn.widgets.Button(name="Print Iframe", button_type="primary")
js_callback = """ var iframe = document.getElementById("myIframe"); if (iframe) { var newWindow = window.open(iframe.src); } else { console.error("Iframe not found"); } """
button.js_on_click(args={}, code=js_callback)
layout = pn.Column(iframe, button)
layout.show()
Would appreciate ideas
Requires weasyprint and PyPDF2 because weasyprint alone had empty pages in between and I couldnt figure out which CSS element was triggering that.
https://github.com/user-attachments/assets/8fe3e749-21b6-4262-b973-e3a96ce7e841
Requires (preferably under conda install section)
I think this method is preferable over selenium because this includes data/images from HTML tabs
example pdf profile_report (7).pdf
And it's also tested on deployment