1

A new Programmer here.

I was searching about open a PDF file with vaading. I can open it in the browser or download it without problem, but i need to open in a tab of my application, or at least open it in the predefined pdf reader and the Desktop class is not an option.

Can anyone help me? I only saw browser options, and now i was in war with the WT PDF Viewer class trying it.

Thank you a lot!

5
  • If you PDF is already available as downloadable file under some URL of your web application, then you can simply add an Anchor (Vaadin Flow) or Link (Vaadin 8) component to your UI that points to that URL. The browser will open a PDF viewer automatically. Commented Nov 6, 2018 at 11:45
  • hi! thank you for your response, but it is not for an URL is a temporal file that i create from jasper with the code. JasperPrint jrprint = JasperFillManager.fillReport(report, parameters, beanCollection); ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); JasperExportManager.exportReportToPdfStream(jrprint, byteArray); Commented Nov 6, 2018 at 12:53
  • If you are using Vaadin 8, one possibility is to use Embedded since accepts Resource as parameter see API here vaadin.com/api/framework/8.6.0/com/vaadin/ui/Embedded.html and Resource here vaadin.com/api/framework/8.6.0/com/vaadin/server/Resource.html You probably would use StreamResource. Commented Nov 6, 2018 at 13:23
  • sorry for not been expecific enough, is vaadin 7 Commented Nov 6, 2018 at 14:13
  • According to this question, it should be possible to use StreamResource also in Vaadin 7. There should be further documentation somewhere on the net. Vaadin 7 is old though. Commented Nov 6, 2018 at 15:00

1 Answer 1

1

If you are using Vaadin 7 & 8, one possibility is to use Embedded since accepts Resource as parameter see API for Vaadin 8 here https://vaadin.com/api/framework/8.6.0/com/vaadin/ui/Embedded.html and Resource here https://vaadin.com/api/framework/8.6.0/com/vaadin/server/Resource.html You probably would use StreamResource .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.