Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Using PDF.js under JSP (Tomcat)(Rendeing PDF file using PDF.js)
Using PDF.js under JSP (Tomcat) [message #1806199] Mon, 06 May 2019 05:58 Go to next message
Mark Novem Grisola is currently offline Mark Novem GrisolaFriend
Messages: 14
Registered: November 2017
Junior Member
Hello Andre,

Good day..

I am using PDF.js to render a pdf file, i did follow your suggestion on last post. I successfully generated a pdf file and placed it on the UI server but when i try to load and display it using pdf.js ("ClientSessionProvider.currentSession().getDesktop().openUri("pdfjs/web/viewer.html?file=test.pdf", OpenUriAction.POPUP_WINDOW)) it wont display. But when i try it on apache server it works smoothly. The scout v9.0 can not minify the pdf.js i guess, that is may be the cause of errors as stated on https://github.com/mozilla/pdf.js/issues/2479 . If you have extract time please help me out. Have a look at on these errors it might help to figure it out the problem.

2019-05-06 04:36:46,008 ERROR [qtp829149076-12] org.eclipse.scout.rt.ui.html.UiServlet - Exception while processing request -Ex: java.io.IOException: Failed running org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.MinifyJsWithYui
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.runInClassLoader(ScriptProcessor.java:97)
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.minifyJs(ScriptProcessor.java:77)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.minifyContent(ScriptFileBuilder.java:326)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.compileAndMinifyContent(ScriptFileBuilder.java:307)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.processLibrary(ScriptFileBuilder.java:152)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.buildScript(ScriptFileBuilder.java:95)
at org.eclipse.scout.rt.ui.html.res.loader.ScriptFileLoader.loadResource(ScriptFileLoader.java:131)
at org.eclipse.scout.rt.ui.html.res.loader.AbstractResourceLoader.loadResource(AbstractResourceLoader.java:53)
at org.eclipse.scout.rt.ui.html.res.loader.ScriptFileLoader.loadResource(ScriptFileLoader.java:125)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.resolveResourceFromCache(ResourceRequestHandler.java:136)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.handleGet(ResourceRequestHandler.java:65)
at org.eclipse.scout.rt.ui.html.AbstractUiServletRequestHandler.handle(AbstractUiServletRequestHandler.java:26)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequestInternal(UiServlet.java:256)
at org.eclipse.scout.rt.ui.html.UiServlet.lambda$1(UiServlet.java:220)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequiresNew(TransactionProcessor.java:100)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:129)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:71)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:156)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequest(UiServlet.java:220)
at org.eclipse.scout.rt.ui.html.UiServlet.doGet(UiServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.access$0(AbstractHttpServlet.java:1)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.wrap(AbstractHttpServlet.java:49)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.service(AbstractHttpServlet.java:38)
at org.eclipse.scout.rt.ui.html.UiServlet.service(UiServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:867)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.lambda$0(ServletFilterHelper.java:159)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/javax.security.auth.Subject.doAs(Subject.java:423)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.continueChainAsSubject(ServletFilterHelper.java:155)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handleRequest(TrivialAccessController.java:103)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handle(TrivialAccessController.java:78)
at adn.gov.ph.govservices.ui.html.UiServletFilter.doFilter(UiServletFilter.java:62)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:502)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.runInClassLoader(ScriptProcessor.java:89)
... 67 common frames omitted
Caused by: org.mozilla.javascript.EvaluatorException: Compilation produced 971 syntax errors.
at org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.MinifyJsWithYui$1.runtimeError(MinifyJsWithYui.java:44)
at org.mozilla.javascript.Parser.parse(Parser.java:396)
at org.mozilla.javascript.Parser.parse(Parser.java:340)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:314)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:539)
at org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.MinifyJsWithYui.run(MinifyJsWithYui.java:52)
... 72 common frames omitted
MDC[principal=marknovemg, httpUri=, uiSession=, clientSession=, jobName=, cid=4161ad0d-e00e-4a81-80c9-687a177722f6]
2019-05-06 04:37:00,636 INFO [qtp829149076-17] org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder - Building script ScriptSource[requestPath=/pdfjs-dist/web/viewer.css, url=file:/home/mov/git/scout_v9.0/gsms-repository/govservices.ui.html/target/classes/WebContent/pdfjs-dist/web/viewer.css, fileType=STYLESHEET, nodeType=LIBRARY] theme=default m_minify=true -Ex: MDC[principal=marknovemg, httpUri=, uiSession=, clientSession=, jobName=, cid=a0260d1e-5149-4999-8fce-15edd5cd4d8b]
2019-05-06 04:37:01,351 ERROR [qtp829149076-17] org.eclipse.scout.rt.ui.html.UiServlet - Exception while processing request -Ex: java.io.IOException: Failed to parse CSS content with LESS
at org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.CompileCssWithLess.run(CompileCssWithLess.java:30)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.runInClassLoader(ScriptProcessor.java:89)
at org.eclipse.scout.rt.ui.html.scriptprocessor.ScriptProcessor.compileCss(ScriptProcessor.java:64)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.compileContent(ScriptFileBuilder.java:317)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.compileAndMinifyContent(ScriptFileBuilder.java:305)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.processLibrary(ScriptFileBuilder.java:152)
at org.eclipse.scout.rt.ui.html.script.ScriptFileBuilder.buildScript(ScriptFileBuilder.java:95)
at org.eclipse.scout.rt.ui.html.res.loader.ScriptFileLoader.loadResource(ScriptFileLoader.java:131)
at org.eclipse.scout.rt.ui.html.res.loader.AbstractResourceLoader.loadResource(AbstractResourceLoader.java:53)
at org.eclipse.scout.rt.ui.html.res.loader.ScriptFileLoader.loadResource(ScriptFileLoader.java:125)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.resolveResourceFromCache(ResourceRequestHandler.java:136)
at org.eclipse.scout.rt.ui.html.res.ResourceRequestHandler.handleGet(ResourceRequestHandler.java:65)
at org.eclipse.scout.rt.ui.html.AbstractUiServletRequestHandler.handle(AbstractUiServletRequestHandler.java:26)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequestInternal(UiServlet.java:256)
at org.eclipse.scout.rt.ui.html.UiServlet.lambda$1(UiServlet.java:220)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequiresNew(TransactionProcessor.java:100)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:129)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:71)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:156)
at org.eclipse.scout.rt.ui.html.UiServlet.handleRequest(UiServlet.java:220)
at org.eclipse.scout.rt.ui.html.UiServlet.doGet(UiServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.access$0(AbstractHttpServlet.java:1)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.wrap(AbstractHttpServlet.java:49)
at org.eclipse.scout.rt.server.commons.servlet.AbstractHttpServlet.service(AbstractHttpServlet.java:38)
at org.eclipse.scout.rt.ui.html.UiServlet.service(UiServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:867)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.lambda$0(ServletFilterHelper.java:159)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/javax.security.auth.Subject.doAs(Subject.java:423)
at org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper.continueChainAsSubject(ServletFilterHelper.java:155)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handleRequest(TrivialAccessController.java:103)
at org.eclipse.scout.rt.server.commons.authentication.TrivialAccessController.handle(TrivialAccessController.java:78)
at adn.gov.ph.govservices.ui.html.UiServletFilter.doFilter(UiServletFilter.java:62)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:502)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.asual.lesscss.LessException: Syntax Error: Cannot read property "numerator" from undefined (line 552, column 2) near
left: -200px;
left: calc(-1 * var(--sidebar-width));
}
at com.asual.lesscss.compiler.RhinoCompiler.parseLessException(RhinoCompiler.java:132)
at com.asual.lesscss.compiler.RhinoCompiler.compile(RhinoCompiler.java:83)
at com.asual.lesscss.LessEngine.compile(LessEngine.java:102)
at com.asual.lesscss.LessEngine.compile(LessEngine.java:92)
at org.eclipse.scout.rt.ui.html.scriptprocessor.internal.impl.CompileCssWithLess.run(CompileCssWithLess.java:27)
... 72 common frames omitted



Attached file is for additional information that might be helpful. Hope you can help me again..


Sincerely,

Mark

[Updated on: Tue, 07 May 2019 03:53]

Report message to a moderator

Re: Using PDF.js under JSP (Tomcat) [message #1806256 is a reply to message #1806199] Tue, 07 May 2019 04:18 Go to previous messageGo to next message
Mark Novem Grisola is currently offline Mark Novem GrisolaFriend
Messages: 14
Registered: November 2017
Junior Member
Good day..

I downloaded yuicompressor-2.4.8.jar form https://github.com/yui/yuicompressor/releases and perform: java -jar yuicompressor-2.4.8.jar build/pdf.js -o -v pdf.min.js . Multiple syntax errors was displayed. So, it is really related to minify process on why i can not use PDF.js on scout_v9.0,.. Is there any solution to this? please help me.

sincerely,
Mark

[Updated on: Tue, 07 May 2019 04:19]

Report message to a moderator

Re: Using PDF.js under JSP (Tomcat) [message #1806257 is a reply to message #1806256] Tue, 07 May 2019 05:33 Go to previous messageGo to next message
Mark Novem Grisola is currently offline Mark Novem GrisolaFriend
Messages: 14
Registered: November 2017
Junior Member
Oh my goodness, I just solved it. I just making things difficult but the answer is just right under my nose.
From:
ClientSessionProvider.currentSession().getDesktop().openUri("http://localhost:8082/pdf/web/viewer.html?file=IntakeSheet.pdf", OpenUriAction.NEW_WINDOW);
Remarks: error during rendering process. errors are related to pdf.js
To:
ClientSessionProvider.currentSession().getDesktop().openUri("http://localhost:8082/IntakeSheet.pdf", OpenUriAction.NEW_WINDOW);
Remarks: PDF file displayed smoothly on a new webpage tab. This is without the need of pdf.js, right, since web browser itself has a built-in support for displaying pdf file.

But the best way which currently i used is by using BinaryResource which was suggested by Andre on my first post:
File pdf = new File(pathReport);
BinaryResource br = new BinaryResource(pdf.getName(), report);
ClientSessionProvider.currentSession().getDesktop().openUri(br, OpenUriAction.NEW_WINDOW);


Thanks to Andre for the help.

Sincerely,
Mark

[Updated on: Tue, 07 May 2019 08:09]

Report message to a moderator

Re: Using PDF.js under JSP (Tomcat) [message #1806358 is a reply to message #1806257] Wed, 08 May 2019 06:31 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 59
Registered: September 2012
Location: Baden-D├Ąttwil, Switzerla...
Member
Hi Mark

I'm glad you found a solution all by yourself :) But just in case someone else stumbles across this thread: Yes, YUI has troubles with modern JS files. Since YUI is no longer maintained, Scout will no longer use it from version 10 on. But in the meantime you can always minify your JS/CSS files with an external minifier of your choice (for instance UglifyJS). Then simply place the minified version of the file in the same folder as the non-minified version. When Scout loads a script resource the servlet will (in production mode) automatically check, if there's a minified version. Here's how the folder-structure looks like, for our (internal) PDF viewer:

/src/main/resources/
  /WebContent
    /res
      /pdf-js.1.10.88
        pdf.js
        pdf.js.map
        pdf.min.js      
        pdf.worker.js
        pdf.worker.js.map
        pdf.worker.min.js


This way you can by-pass Scout's ScriptProcessor and also YUI.


Eclipse Scout Homepage | Documentation | GitHub

[Updated on: Wed, 08 May 2019 06:31]

Report message to a moderator

Re: Using PDF.js under JSP (Tomcat) [message #1808173 is a reply to message #1806257] Tue, 18 June 2019 13:38 Go to previous messageGo to next message
steven rosick is currently offline steven rosickFriend
Messages: 1
Registered: June 2019
Junior Member
Hi Mark,

thanks for your good solution, it was also very helpful for me.

But i have an additional question: What is your way to get the report pdf-file on the server?

I only have an blob-Field wich contain the pdf. This i temporary store on server with manual delete. In my eyes, this is not the best solution.

regards,

Steven
Re: Using PDF.js under JSP (Tomcat) [message #1810100 is a reply to message #1806358] Wed, 31 July 2019 04:57 Go to previous messageGo to next message
Mark Novem Grisola is currently offline Mark Novem GrisolaFriend
Messages: 14
Registered: November 2017
Junior Member
Hello Andre,

Good day! I was really worried about the scout YUI issue but not until you mentioned that version 10 will address the matter :D so glad. It's been a while since I have not open my account, due to a large scout project we're working on. Thanks for the information Andre, i'll share it to some whom may across that YUI issue.

Sincerely,

Mark
Re: Using PDF.js under JSP (Tomcat) [message #1810101 is a reply to message #1808173] Wed, 31 July 2019 05:58 Go to previous message
Mark Novem Grisola is currently offline Mark Novem GrisolaFriend
Messages: 14
Registered: November 2017
Junior Member
Hello Steve,

Good day! Sorry if my reply is too late, too busy on large scout project. But if in case you still want to know my method here it is.
1.) Using JasperStudio, i created & designed my report forms ( .jrmxl format)
2.) On client side (UI), i placed all my .jrmxl files:
...ui.html/
src/
main/
resources/
/WebContent
/res *or you can create another folder to separate it to "res" folder
report1.jrxml
report2.jrxml
...
/temp
3.) On scout server: fill.in with data the report you want to use/generate:
public JasperPrint createReport( ... ) {
JasperPrint jasperPrint;
// create a map to pass parameters to the report
HashMap<String, Object> parameter = new HashMap<String, Object>();

try {
//Note: this setup is good only for development, it must be change on deployment because the file structure might be different.
String s = "........ui.html/src/main/resources/WebContent/pswd/jrxml_forms/IntakeSheetForm_v1.0.0.jrxml"; // provide the complete path.
JasperReport report = JasperCompileManager.compileReport(s);
........
........
........
// let Jasper Reports use our already defined SQL Connection
jasperPrint = JasperFillManager.fillReport(report, parameter, SQL.getConnection());

return jasperPrint;
}
catch (JRException e) {
throw new ProcessingException("An error occured during the creation of the report.", e);
}
4.) On the client side (UI) where the report generation is needed:
...
...
if( form.isFormStored() ){
byte report = BEANS.get(IFormService.class).createReport( formData );

File tmpPath = new File(".....ui.html/src/main/resources/WebContent/pswd/temp"); // Path to where the generated reports will be temporarily stored
File tmpFile;
String extension = ".pdf";
String name = "";

// get e unique temporary name
tmpFile = File.createTempFile(name, extension, tmpPath);
FileOutputStream fo = new FileOutputStream(tmpFile);

fo.write(contents);
fo.close();

// let the vm handle the deletion of the temp file
tmpFile.deleteOnExit();

File pdf = new File(tmpFile.toString());
BinaryResource bs = new BinaryResource(pdf.getName(), report);
ClientSessionProvider.currentSession().getDesktop().openUri(bs, OpenUriAction.NEW_WINDOW);
}

So, basically that is how I do it Steve with the help of Scout team, though it seems i might stumble on some problem (path related problem) when on production mode but i had a possible solution ready for that scenario.

If you still have some questions Steve, i will be glad to hear it :) it help me improve my understanding also.

Sincerely,

Mark
Previous Topic:Move the Menu of Desktop into Outline
Next Topic:Tablefield - Tablefield data not shown on a tab in a groupbox
Goto Forum:
  


Current Time: Fri Oct 18 08:50:34 GMT 2019

Powered by FUDForum. Page generated in 0.02156 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top