This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-28
Channels
- # admin-announcements (2)
- # alda (5)
- # arachne (4)
- # beginners (49)
- # boot (92)
- # capetown (3)
- # cider (9)
- # cljs-dev (6)
- # cljs-edn (1)
- # cljsjs (29)
- # cljsrn (4)
- # clojure (65)
- # clojure-android (1)
- # clojure-berlin (2)
- # clojure-chicago (2)
- # clojure-gamedev (2)
- # clojure-greece (11)
- # clojure-india (1)
- # clojure-japan (1)
- # clojure-new-zealand (2)
- # clojure-quebec (2)
- # clojure-russia (49)
- # clojure-spec (73)
- # clojure-uk (38)
- # clojurescript (118)
- # clojutre (4)
- # community-development (17)
- # cursive (3)
- # data-science (1)
- # datascript (1)
- # datomic (17)
- # emacs (6)
- # euroclojure (2)
- # events (2)
- # immutant (30)
- # keechma (11)
- # leiningen (4)
- # luminus (2)
- # off-topic (19)
- # om (14)
- # onyx (28)
- # planck (9)
- # re-frame (11)
- # reagent (35)
- # ring-swagger (4)
- # schema (4)
- # slack-help (6)
- # spacemacs (2)
- # specter (11)
- # testing (4)
- # untangled (88)
- # utah-clojurians (2)
- # vim (2)
- # yada (9)
So, I’m trying to work with a mozilla’s PDF rendering library, PDFjs via a cljsjs package — and when following their example, I keep getting an error .getPage is not a function. I’m having a hard time figuring out how to debug this.
(-> (.getDocument js/PDFJS "/onlisp.pdf")
(.then (fn [pdfFile] (.getPage pdfFile 1)))
(.then (fn [page] (.getViewport page 1))))
their code PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf) {
//
// Fetch the first page
//
pdf.getPage(1).then(function getPageHelloWorld(page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
//
// Prepare canvas using PDF page dimensions
//
var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
//
// Render PDF page into canvas context
//
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
});
@conaw: are you using advanced
optimizations?
@conaw: the issue might be that this function is missing from the externs for the CLJSJS package
you can easily check that by grepping for getPage
in the compiled js file
oh well, ignore what I said
if the error is .getPage is not a function.
that shouldn't apply
if the error would be .xys is not a function
that could mean that your call to getPage
has been optimized-away
the thing that is confusing me is, there seem to be a bunch of ways that I could be getting this error — it’s calling .getPage on a promise and not the returned object was my first fear, or the library itself doesn’t have an error message for when I request a pdf that doesn’t exist
so, in the examples, the pdfjs folks have you set some workers up in a file in resources, I checked that file’s location, and it looked like it was the place this error is coming from
@martinklepsch: is it possible this is a problem with the cljsjs packagage?
also, as I’m beginning in the lisp/clojure world, if you have any tips to improve my code, please let me know 🙂
@leo.ribeiro: what db are you using?
@tmtwd: oh sorry.. I missed the most important information haha… it’s mysql
@leo.ribeiro: can you try changing line 75 map to mapv?
@leo.ribeiro: You might also want to look at this function to make a transaction roll back: https://clojure.github.io/java.jdbc/#clojure.java.jdbc/db-set-rollback-only!
@danlebrero: sorry… I had leave to lunch
@hrathod: thank you, I will give it a shot
@danlebrero: what’s the difference here between mapv rather than map?
@danlebrero: LOL it worked… I got it… it’s something to do in laziness and db contexts right? by the way thank you very much
@leo.ribeiro: that is correct :) laziness is sometimes a curse
to undo laziness, there is also http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/doall
@hrathod: if I use doall it realize all the possible lazy objects inside that, including nesting maps?
@leo.ribeiro: For that, I am not sure. Sorry.
@leo.ribeiro: doall just realizes the lazy seq passed as param.
@leo.ribeiro: if the elements of the lazy seq are themselves lazy seqs, they will not be realized.