(event, args, directFinalize)
| 2367 | |
| 2368 | //TODO Use canvas to export images if math is not used to speedup export (no capturePage). Requires change to export3.html also |
| 2369 | function exportDiagram(event, args, directFinalize) |
| 2370 | { |
| 2371 | if (event != null && event.senderFrame != null && |
| 2372 | !validateSender(event.senderFrame)) return null; |
| 2373 | |
| 2374 | var browser = null; |
| 2375 | |
| 2376 | try |
| 2377 | { |
| 2378 | browser = new BrowserWindow({ |
| 2379 | webPreferences: { |
| 2380 | preload: `${__dirname}/electron-preload.js`, |
| 2381 | backgroundThrottling: false, |
| 2382 | contextIsolation: true, |
| 2383 | disableBlinkFeatures: 'Auxclick', // Is this needed? |
| 2384 | // Electron 42 offscreen DPR defaults to 1; force 2 so post-capture img.resize() downsamples [jgraph/drawio-desktop#2422] |
| 2385 | offscreen: { deviceScaleFactor: 2 }, |
| 2386 | }, |
| 2387 | show : false, |
| 2388 | frame: false, |
| 2389 | enableLargerThanScreen: true, |
| 2390 | transparent: args.format == 'png' && (args.bg == null || args.bg == 'none'), |
| 2391 | parent: windowsRegistry[0] //set parent to first opened window. Not very accurate, but useful when all visible windows are closed |
| 2392 | }); |
| 2393 | |
| 2394 | browser.loadURL(`file://${codeDir}/export3.html`); |
| 2395 | |
| 2396 | const contents = browser.webContents; |
| 2397 | var from = args.from; |
| 2398 | var to = args.to; |
| 2399 | var pdfs = []; |
| 2400 | |
| 2401 | contents.on('did-finish-load', function() |
| 2402 | { |
| 2403 | //Set finalize here since it is call in the reply below |
| 2404 | function finalize() |
| 2405 | { |
| 2406 | browser.destroy(); |
| 2407 | }; |
| 2408 | |
| 2409 | if (directFinalize === true) |
| 2410 | { |
| 2411 | event.finalize = finalize; |
| 2412 | } |
| 2413 | else |
| 2414 | { |
| 2415 | //Destroy the window after response being received by caller |
| 2416 | ipcMain.once('export-finalize', finalize); |
| 2417 | } |
| 2418 | |
| 2419 | function renderingFinishHandler(e, renderInfo) |
| 2420 | { |
| 2421 | if (!validateSender(e.senderFrame)) return null; |
| 2422 | |
| 2423 | if (renderInfo == null) |
| 2424 | { |
| 2425 | event.reply('export-error'); |
| 2426 | return; |
no test coverage detected