Skip to content

Instantly share code, notes, and snippets.

@Odepax
Last active September 15, 2019 08:59
Show Gist options
  • Save Odepax/e7016b9babf1fdf26e09e8895a78dac5 to your computer and use it in GitHub Desktop.
Save Odepax/e7016b9babf1fdf26e09e8895a78dac5 to your computer and use it in GitHub Desktop.
Page-basis PDF2PNG converter for Firefox.
// Note: the PDF must be image-based. Makes it not generic, but very usefull in some situations.
// Put this in the console:
// EXE: (function (pageId) { ... })("page3");
;(function(pageId = "page1") {
const canvas = document.getElementById(pageId)
const image = new Image()
image.src = canvas.toDataURL("image/png")
document.body.innerHTML = null
document.body.appendChild(image)
})(/* Indicate page id (as "page#") here */);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment