How does Electron print PDF documents?

requirements are PDF resources on a dynamic given network. Electron implements preview printing and direct printing without preview. At present, the two methods are basically the same except that the display window is not displayed and the show property of BrowserWindow is different
function print ()
{

.
if(printWindow)
{
   printWindow.webContents.print({silent: true, printBackground: true});
}

}
printWindow = new BrowserWindow ({show: true,width: 800, height: 800);
/ / pdfUrl is the address of the network PDF file
printWindow.loadURL (pdfUrl);
printWindow.setMenu (null);
printWindow.webContents.on ("did-finish-load", () = > {

)
   // 
   setTimeout(print,3000);
});

problems encountered
(1) Printing needs to be done after the PDF is displayed, otherwise the print is blank. The test found that the PDF document was not finished loading during the execution of the "did-finish-load" event, so I used a timer, but the size and network speed of the network resource PDF will affect the loading time of the PDF. If the timer uses a fixed value too small, sometimes the load is not complete, and if it is too large, the user experience is not good. Is there any way to know whether the PDF document is loaded or not?
(2) after the PDF is loaded, you must click on the middle of the PDF of the display window when printing, otherwise the printed file will contain the header and footer of the PDF. When the window shows incomplete PDF, there will be problems in paging and display.
the following picture shows the error printing result when you do not click on the middle of the PDF. Is there any great help to see how to solve the above two problems

Mar.25,2021

the first question can be truncated before printing.
I'll go back and try the second question

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7b8d5b-8b03.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7b8d5b-8b03.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?