-
Notifications
You must be signed in to change notification settings - Fork 92
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
Only prompting to download #3
Comments
I am having a similar issue. I was able to get the electron-pdf-window to display the PDF document when it came from a web address (http, https), but when it is a local file, it only prompts to download. Is there anyway to force the viewing of a local PDF? |
@selabie68 I am not sure if you are still having the issue with handling local files, but I was able to resolve it on my end. The electron-pdf-window Change this } else if (url.match(/^file:\/\//i)) {
const fileUrl = url.replace(/^file:\/\//i, '') to this } else if (url.match(/^file:\/\/\//i)) {
const fileUrl = url.replace(/^file:\/\/\//i, '') |
how are the URLs that are failing look? from the above it seems it is on windows where paths don't begin with |
@mrcatj this solution wouldn't work on unix though. what if you remove the third |
@gerhardberger I tried as you suggested and it seemed to work, I took out the extra From } else if (url.match(/^file:\/\//i)) {
const fileUrl = url.replace(/^file:\/\//i, '') New function function stripChar(url) {
if (url.match(/^file:\/\/\//i)) {
return url.replace(/^file:\/\/\//i, 'file://')
} else {
return url
}
} from the construct loadURL (url) {
const newUrl = stripChar(url)
isPDF(newUrl).then(isit => {
if (isit) {
super.loadURL(`file://${
path.join(__dirname, 'pdfjs', 'web', 'viewer.html')}?file=${newUrl}`)
} else {
super.loadURL(newUrl)
}
}).catch(() => super.loadURL(url))
} I am now encountering a new problem. If the directory to the PDF has spaces or the filename has If a If a space exists in the path/filename, it appears to convert to a |
@mrcatj try out the new version, now the URI is encoded, maybe it fixes the space character problem. |
Unfortunately it seems to not work. I updated to your latest and had my original issue. Made changes to eliminate the leading Here is the top of the download box, showing the string passed to it. The original file name has spaces: Here is a different file with |
On Mac works fine, and when I add "file://" the file is downloaded. |
I would like to know if you have solved this problem, I am looking for a desperate solution, thanks to everyone |
I have the same issue on mac… weirdly enough, in development it works, in production it prompts to download… |
I am attempting to have the plugin load a pdf file after it is downloaded to a temporary location but it just prompts to save the file.
My Code Example:
The text was updated successfully, but these errors were encountered: