Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2016 09:01
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Imagine you could convert all kind of things to all kind of different things, e.g. taking a screenshot of a dom element or converting another website to a screenshot. Forks & comments much appreciated! #nobackend #dreamcode
// convert a dom element to a PDF and download it
convert( $('.invoice') ).to( 'invoice.pdf' ).download()
// alternatively
download( convert( $('.invoice') ).to( 'invoice.pdf' ) )
// convert another website to a png and show it on the page
convert( '' ).toImage().then( $('.screenshots').append )
// attach a file to an email
subject: "Hello, World!",
text: "This mail has been sent from the frontend",
to: "",
attachments: [
convert( '' ).to("screenshot.png")
Copy link

I like that - looks really clean. So download() and save()

How does it handle different MIME types, or is that not applicable in a node.js scenario?

Copy link

gr2m commented Sep 2, 2013

not sure about a node.js scenario, I did it all with a browser environment in mind, and there I expect the right mime types to be sent as headers

Copy link

I would suggest for file format conversions and anything to do with pictures and files. All the above functional abstractions are covered using REST API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment