izuzak / atom-pdf-view

Support for viewing PDF files in Atom.
https://atom.io/packages/pdf-view
MIT License
106 stars 30 forks source link

Failed to correctly render first page #102

Closed pedro93 closed 8 years ago

pedro93 commented 8 years ago

Hi, I am using atom to write a latex document, however the very frontpage does not seem to be rendered in the pdf viewer. Using the default previewer in my mac the file output is as expected.

The atom previewer:

screen shot 2015-12-31 at 18 13 07

vs my previewer:

screen shot 2015-12-31 at 18 13 35

No errors or warnings are given.

izuzak commented 8 years ago

Can you upload that PDF somewhere and link to it here? It's kind of hard to investigate anything with nothing to go on, as I'm sure you understand. Also, you haven't mentioned which version of Atom you're using, which version of this package, which version of OS you're running, and whether this affect any other files (generated from latex or not). Providing more details would be helpful.

izuzak commented 8 years ago

Happy to reopen the issue once you provide more information :v:

pedro93 commented 8 years ago

Thanks for looking into this!

As requested here is the information: Pdf file - https://feupload.fe.up.pt/get/1cG14LYWo67DEY8 Atom version: 1.3.2 OS version: OS X Yosemite (10.10.5) Version output:

~ $ apm -v
apm  1.4.1
npm  2.13.3
node 0.10.40
python 2.7.10
git 2.4.9

This issue was only detected after generating the pdf from the latex code, though I have rendered a few other latex projects and this is first time it happened. Haven't found this issue with any other pdf files. Happy to provide any additional information if need be.

P.S: Found the following error in the atom dev console, perhaps it may help you

Uncaught (in promise) EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".

    at Function (native)
    at Object.PDFFunction_constructPostScriptFromIR [as constructPostScriptFromIR] (file:///Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.worker.js:5977:16)
    at Object.PDFFunction_fromIR [as fromIR] (file:///Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.worker.js:5659:23)
    at Function.ColorSpace_fromIR [as fromIR] (file:///Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.worker.js:6901:45)
    at Function.ColorSpace_parse [as parse] (file:///Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.worker.js:6859:23)
    at next (file:///Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.worker.js:11495:28)
    at file:///Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.worker.js:11590:19
izuzak commented 8 years ago

Thanks! I'm seeing that problem as well -- reopening so that I can close it with a pull request which should fix things.

izuzak commented 8 years ago

So, it seems that the first page was triggering some behavior in the pdf.js library which needs to dynamically evaluate code. That's not allowed in Atom by default, so a workaround needs to be used (in the form of the "loophole" library). Couldn't get that to work in the version of pdf.js that was being used for some reason, so I ended up upgrading to a new version of pdf.js which caused new problems. After some jiggery-pokery -- I think this should work now and nothing should be broken.

I've published a new version just now -- can you give it a try and see if things are working for you?

pedro93 commented 8 years ago

Just updated the package, the following Atom log was given:

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.3.2 System: Mac OS X 10.10.5 Thrown From: pdf-view package, v0.38.0

Stack Trace

Uncaught Error: Unknown action from worker: ready

At /Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.js:236

Error: Unknown action from worker: ready
    at error (/Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.js:236:9)
    at Worker.messageHandlerComObjOnMessage (/Users/pedrosilva/.atom/packages/pdf-view/node_modules/pdfjs-dist/build/pdf.js:1525:7)

Commands

     -1:07.3.0 tree-view:toggle (atom-workspace.workspace.scrollbars-visible-when-scrolling)
     -0:05.5.0 latex:build (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "themes": [
      "atom-dark-ui",
      "sublime-default-syntax"
    ],
    "disabledPackages": [
      "double-click-tree-view",
      "metrics"
    ],
    "openEmptyEditorOnStart": false,
    "packagesWithKeymapsDisabled": [
      "tree-view"
    ]
  },
  "pdf-view": {}
}

Installed Packages

# User
auto-indent, v0.5.0
autohide-tree-view, v0.25.1
build, v0.52.0
emmet, v2.3.17
language-latex, v0.6.1
latex, v0.28.2
linter, v1.11.3
pdf-view, v0.38.0
project-manager, v2.6.5
sublime-default-syntax, v0.2.7
sync-settings, v0.6.0
tab-close-double-click, v1.0.1

# Dev
No dev packages
izuzak commented 8 years ago

Strange -- I'm not seeing that. Can you describe what exactly you did to trigger that error? Starting from the moment you opened Atom? Do you see that error when you just open other PDF files?

pedro93 commented 8 years ago

I had to restart Atom, it seems to be working. Thank you very much for fixing this :pray: Perhaps something in the atom core had to reboot. If any error pops up, I will be sure to say it. You may close the issue

izuzak commented 8 years ago

Ahh, great :D :sweat_smile: Thanks for letting me know.