Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use data URLs to display locally generated PDFs #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tgreiser
Copy link

Example, use pdfMake.js to generate PDFs, and stream them to the viewer window. This appears to bypass the cross-platform issues involved with using file URLs. Tested on Windows 10.

In renderer thread, generate a PDF and send the data URL via IPC
    const {ipcRenderer} = require('electron');
    pdfMake.create(pdf).getDataUrl(function(result) {
        ipcRenderer.send('asynchronous-message', result);
    });

In main thread, works as normal:
    var pdfWindow = null;
    const {ipcMain} = require('electron')
    ipcMain.on('asynchronous-message', (event, url) => {
        pdfWindow = new PDFWindow({
            width: 1024,
            height: 768,
          });
        log.info('Opening a PDFWindow');
        pdfWindow.loadURL(url);
    });

@Brainbusted
Copy link

Hi, still getting a save dialog box. any advice?
save_dialog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants