I have a lot of dialog in vaadin flow which I want let user print them. I know how to print the whole page as below code but I want only the dialog above the page be printed.
Button btnPrint = new Button( "Print…" );
btnPrint .addClickListener( ( ClickEvent < Button > clickEvent ) ->
{
// this Prints the current page
UI.getCurrent().getPage().executeJs( "print();" );
} );
I did also tried this with java script but no success.
window.printPartOfPage = function (divPrintId) {
console.log("Inside printPartOfPage");
var printContent = document.getElementById(divPrintId);
var WinPrint = window.open('', '', 'letf=100,top=100,width=600,height=600');
WinPrint.document.write(printContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
Any Idea how to do it?