tsmorgan/shots

Getting an error

chrisadesign opened this issue · 9 comments

Hey,

trying to use the tool for the first time and I'm getting an error, seems like it's looking for an image of the first page I've listed (plus -full.png) in the folder I've created but isn't generating it first. Any ideas?

Error output...

node pdf.js sms170302
Reading file /Users/chrishanson/Desktop/shots-master/sms170302/data.json
generating screenshots ############
adding to PDF #fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open 'sms170302/home-full.png'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Function.PDFImage.open (/Users/chrishanson/Desktop/shots-master/node_modules/pdfkit/js/image.js:30:21)
at PDFDocument.module.exports.image (/Users/chrishanson/Desktop/shots-master/node_modules/pdfkit/js/mixins/images.js:27:26)
at createPDF (/Users/chrishanson/Desktop/shots-master/pdf.js:139:11)
at /Users/chrishanson/Desktop/shots-master/pdf.js:88:11
at ChildProcess.exithandler (child_process.js:220:5)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)

Hi Chris

Really sorry about this. I'm just looking into it now. If the PNG files aren't being created then I'm guessing that's a webkit2png issue.

If you type which webkit2png in the terminal does it respond with a file path? If so.... if you try webkit2png --version what version does it return? I've got 0.7 here so maybe there's something changed in newer versions.

The bit of the code that creates the PDF just assumes that the PNG files exist so that's why you're getting a no such file type error. Those #'s mean that it's at least read the data file and attempted to generate all your screenshots, so I think if we can work out where webkit2png is going wrong you should be on your way.

Actually also if you could post your data.json file that'd be useful :)

Hi Tom, thanks for getting back to me.

webkit2png seems fine, it's version 0.7 too

$ webkit2png
Usage: webkit2png [options] [http://example.net/ ...]
Examples:
webkit2png http://google.com/ # screengrab google
webkit2png -W 1000 -H 1000 http://google.com/ # bigger screengrab of google
webkit2png -T http://google.com/ # just the thumbnail screengrab
webkit2png -TF http://google.com/ # just thumbnail and fullsize grab
webkit2png -o foo http://google.com/ # save images as "foo-thumb.png" etc
webkit2png - # screengrab urls from stdin
webkit2png /path/to/file.html # screengrab local html file
webkit2png -h | less # full documentation

data.json file:

{
"webPath": "http://localhost:3000/",
"output": "smsredesign-screens.pdf",
"keepPNGs": true,
"browserWidth": 960,
"resize" : {
"full_width": 1280,
"thumb_width": 320
},
"pages": [
"home",
"users",
"ao-start",
"ao-name",
"ao-dob",
"ao-address",
"ao-position",
"ao-contact",
"ao-nationality",
"ao-nationality-3",
"ao-check-answers",
"ao-confirm"
]
}

Right so basically the pdf.js just issues a webkit2png commands that looks like this:

webkit2png -W 960 -TF http://localhost:3000/home -o sms170302/home -s 1 --ignore-ssl-check

Can you try running that in terminal and seeing whether a PNG gets created. You'll probably have to make sure you're in the same folder (ie. the one above sms170302) when you run it. Maybe that'll fail in an instructive way.

Sorry just saw this, I don't have my laptop with me, I'll run it Monday and get back to you.

Sorry for the delay, ran the command and...

$ webkit2png -W 960 -TF http://localhost:3000/home -o sms170302/home -s 1 --ignore-ssl-check
Fetching http://localhost:3000/home ...
2017-03-16 15:23:30.850 Python[39883:19440375] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
... something went wrong: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Oof! Right I see. Looks like it's this security thing Apple added to try and force you onto HTTPS. Did you update your webkit2png before trying it? I've put a warning on the front page of the repo, maybe not prominently enough. :(

If you type which webkit2png in the terminal you should find where the script lives. You just need to edit that file. There's instructions on what to add and where. It's just an extra line or two but it means that it doesn't mind connecting to plain HTTP servers again.

I'm hoping this is what's going on. If you've already done all that and there's still an issue ping me back! :)

That's done it - I should have thought to do that, saw it when I first ran through the instructions but ignored it as I'm not on El Capitan and stupid didn't think it's anything form then on.

Thanks for your help though, and the tool too :)

Woohoo! Excellent. No problem. :)