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

Can't loadURL from blob #11

Open
Fiorello opened this issue Mar 30, 2017 · 8 comments
Open

Can't loadURL from blob #11

Fiorello opened this issue Mar 30, 2017 · 8 comments

Comments

@Fiorello
Copy link

Fiorello commented Mar 30, 2017

Hi,
i'm trying to load a pdf file from a blob without success.
With a real url it's work, with blob url it render a blank page without error.
My code:
`const filePath = path.join(dirPath, files[0]);

  Utils.decryptStream(filePath, password, (error, content) => {

    const blob = new Blob([content], {type: 'application/pdf'});

    const objectURL = URL.createObjectURL(blob);

    const currentWindow = remote.getCurrentWindow();

    // console.log(objectURL);
    PDFWindow.addSupport(currentWindow);

    currentWindow.loadURL(objectURL);

  });

});`

Can anyone help me please?

@ronsc
Copy link

ronsc commented Jun 13, 2017

+1

@codedeus
Copy link

codedeus commented Nov 20, 2017

What i did to get it working for me was to convert the blob to a base64 dataurl and then write the dataurl to a pdf file using node filesystem api and then reading the url to the saved pdf

`fs.writeFile('the name of the pdf you want to save',new Buffer(data, "base64"), (err) => {

 if (err) throw err;
 console.log('The file has been saved!');
 win.loadURL('path to the saved file');

});`

@burtonator
Copy link

I'm having the same issue.

Note that the same code on the latest Chrome works fine.

Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Worker': Error: Protocol "blob:" not supported. Expected "https:" could not be cloned.
    at O.postMessage (file:///home/burton/projects/polar-bookshelf/pdfviewer/web/pdf.viewer.js:1:15528)
    at l (file:///home/burton/projects/polar-bookshelf/pdfviewer/web/pdf.viewer.js:1:12217)
    at file:///home/burton/projects/polar-bookshelf/pdfviewer/web/pdf.viewer.js:1:13060
    at <anonymous>
pdf.viewer.js:1 Uncaught (in promise) Error: An error occurred while loading the PDF.
    at pdf.viewer.js:1
    at <anonymous>

@joshuaballas
Copy link

Still an issue a year later...

Electronjs doesn't support blobs yet in their native pdf viewer either. Pretty much the main way businesses open PDFs isn't support by either of these repos.

@burtonator
Copy link

Try this:

https://github.com/burtonator/polar-bookshelf

Polar loads the PDF via HTTP into Electron to bypass this problem

@joshuaballas
Copy link

@burtonator I gave this a look and it looks promising, but I can't find any documentation on how to set it up.

@burtonator
Copy link

I'm doing another release this morning. It's basically just download and install. The README.md in the home directory explains how to install - near the bottom.

Create an issue in that repo if you are confused about anything.

@joshuaballas
Copy link

joshuaballas commented Jul 19, 2018

@burtonator I ended up making an Issue on there. If this is something I have to install in order to use, that is not something our company can use. This needs to be something implemented directly into my project.

EDIT: Turned out to be an app and not an API. Not an alternative in this instance.

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

No branches or pull requests

5 participants