java - pdf.js: PDF file from servlet which requires a variable -
i using pdf.js view pdf files in gwt application. i've implemented viewer product of build operation described on readme.
when use viewer static pdf, works fine. when supply link servlet serves pdf however, pdf viewer doesn't load.
works fine
http://127.0.0.1:8888/pdfjs/web/viewer.html?file=http://127.0.0.1:8888/staticpdf.pdf
doesn't work
http://127.0.0.1:8888/pdfjs/web/viewer.html?file=http://127.0.0.1:8888/api/getpdf?noderef=001
http://127.0.0.1:8888/api/getpdf?noderef=001 yields pdf file. servlet has worked.
this won't work, because pdf.js#getdocument proceeds make call without parameters, while servlet needs noderef:
get http://127.0.0.1:8888/api/getpdf?noderef http/1.1 200 ok content-type: application/pdf content-length: 0 how implement java servlet , pdf.js able view pdf file given noderef? (only servlet knows how turn noderef pdf, need path pdf remain hidden)
i've been thinking along lines of api/getpdf/001, have no idea how catch on tomcat server, , if possible.
it turns out thinking within pdf.js had been tinkering hours, , question has changed dozen times because kept finding new leads.
however, i've found simple solution.
- instead of accessing servlet
/getpdf?noderef=001, access/getpdf/001 - my servlet mapping
/getpdf/*
the servlet contains following new code in doget:
string noderef = request.getpathinfo().substring(1); this omits need basic get parameters in url, @ least in format ?a=1&b=2, , works fine pass variable servlet returns pdf file using pdf.js.
edit: have editted question title reflect situation stumble upon problem may find answer here.
Comments
Post a Comment