Open justin3rd5Auburn opened 10 years ago
Does it open the PDF file in the browser at all?
In Chrome i get a grey page that says Failed to load PDF Document and Firefox just sits there on a black page.
Yeah, then I doubt its actually generating the full pdf file then. Try running npm test
. Do they all pass?
I bet it's due to the changes you've made to the tool document schema. Have you tried it on a clean clone without the tool schema changes?
Otherwise, have you made the necessary changes to the toolReport.js
route and the pdf/toolReport.html
view?
^CJustins-MacBook-Pro:BigEvent JustinBaldwin$ npm test
BigEvent@0.1.0 test /Users/JustinBaldwin/Dropbox/BigEvent mocha --reporter spec
geocoder
✓ should be imported successfully
✓ should have a send method
✓ should be able to make requests (699ms)
✓ should get the coordinates of Auburn University (314ms)
pdfgen
✓ should be initialized successfully (1209ms)
✓ should return error when given invalid html parameter
✓ should return error when given invalid path parameter
◦ should render a PDF given a string of HTML:
phantom stderr: 2013-11-15 14:21:15.633 phantomjs[4732:507] CoreText performance note: Client called CTFontCreateWithName() using name "Times New Roman" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.
phantom stderr: 2013-11-15 14:21:15.634 phantomjs[4732:507] CoreText performance note: Set a breakpoint on CTFontLogSuboptimalRequest to debug.
phantom stderr: 2013-11-15 14:21:15.637 phantomjs[4732:507] CoreText performance note: Client called CTFontCreateWithName() using name "Times New Roman" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.
7 passing (3s)
2 failing
why does it work in safari?
also all log() calls show that the path is successful server side.
not on a clean clone, but it wasn't working before the changes. Yes I have updated all those routes.
Ok I commented out the fs.unlink() code so that the file wouldn't be deleted. I opened it in adobe reader and it looks correct. Is it possible that fs.unlink() is being called too quickly?
I don't think so. I just tried it on Firefox in Windows and it worked fine. The errors its returning in the tests make me think that has something to do with it. Maybe Mac fonts or something. I don't think fs.unlink is to blame unless you changed how it was being called.
Try this:
The following line appears in both of the failing tests. Comment it out and see if they pass.
stats.size.should.equal(10394);
As long as you still have this within the onSuccess
callback, then it will only be called after the file has been completely sent.
fs.exists(tempFilename, function (exists) {
if (exists) {
fs.unlink(tempFilename, function(unlinkErr) {
if(unlinkErr)
{
log('GET: Unlink Error: %s', unlinkErr);
}
});
}
});
When you pull up the javascript console in the browser are there any errors?
the test passed after commenting out those lines. I have always gotten those errors and it used to work and still works in safari
Okay, it would make sense for it to work in Safari and Chrome, but not Firefox because both Safari and Chrome are webkit browsers, and PhantomJS the headless browser under the hood of the pdfgen module is also based on webkit. I don't know why it wouldn't work on Chrome though. Do you have Adobe Reader installed?
yeah thats why it opens in safari
From Everything I can find this is a core Objective-c warning, but thats all its supposed to be is a warning.
The file is created correctly I have verified that. Chrome and firefox just can't load it.
You can try using res.download
instead of res.sendfile
which will download the pdf instead of rendering it in the browser plugin. You can make sure that the file is at least being received by Chrome and Firefox correctly and narrow it down to their built in PDF renderers.
Oh, wait, have you ran npm install
recently?
Try doing
$ rm -rfv node_modules
$ npm install
I ran npm install this morning
ok i cleared the node_modules and reinstalled as you mentioned above and nothing changed. I changed to res.download and it opened properly in firefox and safari. Chrome downloaded a file but i couldn't open it. It said it was damaged and couldn't be repaired.
Did you try to open the file from within Chrome? Try copying the downloaded PDF to your desktop and open it there.
When you used res.download
with Firefox, did it open in the browser? Or did it open externally?
Well I doing a search for some of the errors you posted above I was able to find https://github.com/ariya/phantomjs/issues/11418 on the phantomjs repo.
Apparently, these warnings started when OS X Mavericks came out. I am assuming that is what you're running OS X 10.9? The issue comments claim that PhantomJS still works despite these warnings but it may be causing this obscure problem no one else has ran into yet. I haven't found any code using PhantomJS quite like I have so its definitely possible.
It may be the case that if the server was running on a Win/Linux system, it would render fine for users running Mac OS X 10.9 regardless of their browser. That will be hard to test with us separated. I may go up to the Mac lab at Shelby and see if I can run it off my Windows system and see it it works on a Mac client in all the different browsers.
Also make sure that you have all the latest software updates for OS X from the Mac App Store. On the issue thread someone mentioned that after updating OS X and doing a fresh npm install
(removing node_modules
first) that the warnings and issues stopped for them.
it opened externally in firefox, but opening it in finder and then clicking on it yields the same result for chrome.
I just checked and I'm completely up to date on my mac.
Go to chrome://plugins
in Chrome and see if the Chrome PDF Viewer
plugin is enabled, or if some other plugin is, like Adobe's.
And in Firefox go to about://plugins
. They should both have their own PDF viewer which is enabled. If the Adobe Reader plugin is enabled for either browser, then try disabling the Adobe Reader plugin for each browser.
Also see if you're able to open this sample PDF from my Dropbox in Chrome or Firefox
Ok so I don't see an Adobe Reader plugin for either browser. I see an Adobe Acrobat NPAPI Plug-in, Version 10.1.8 - Version: 10.1.8. If I disable chromes default viewer it says it can't load the Acrobat plugin. Firefox doesn't show a built in pdf viewer it uses the acrobat one by default. Here is another kicker. I can open your sample pdf just fine in chrome but not in firefox with everything as it originally was.
The more I read and try the more I believe these are browser issues on a mac. I don't believe this has anything to do with our code. It always works in Safari which uses adobe's plugin. Chrome and Firefox for mac don't seem to even have this plugin at this time.
Ok so on my mac I have noticed that only safari will always load the pdf for the tool report. Firefox and Chrome both have trouble loading it. It is being generated I can see that. I just don't understand why these two browsers more times than not can't load it.