Reputation: 11
I'm experiencing a strange issue with the SWT browser widget. I developed a multipage application using the "transition composite" widget from opal widgets. In my last window I need to display a pdf. I've been looking for free open source solutions on the web, and the only one I could fine was IcePdf but the renderization of the page was not great. Then I found out I could use the browser widget to diplay a pdf. I created a new project with the following code :
shell = new Shell();
shell.setSize(l, h);
Browser browser = new Browser(shell, SWT.NONE);
browser.setBounds(xb, yb, lb, hb);
browser.setUrl("file://" + pdfPath);
and it worked great. But then if I run the same code in my actual application, it opens the pdf into adobe reader and not into the application itself.
Has anybody else noticed that issue before? And if yes how can I solve it?
Thanks in advice, Stefano Franchini
Upvotes: 1
Views: 1127
Reputation: 259
A different IE setting resolved this for me when running Eclipse 2019-03 and OpenJDK 11 (64-bit) on Windows 7:
browser.setURL()
as the absolute path of the PDF file to be shown. Don't forget to call browser.update()
after setting the URL/path so the SWT component is re-rendered.(I know, it's been years on this question but I just ran into it and figured out a new solution which I could not find elsewhere on SO, so wanted to capture this in the hopes of helping someone else who might come across this issue in their work).
Upvotes: 0
Reputation: 8090
I think there is an internet explorer or adobe reader setting which needs to be changed.
This might help:
If you want the browser to open PDF files in a separate Acrobat window, configure the browser to use Acrobat or Adobe Reader as a helper application. Then, when you select a PDF file in Internet Explorer, the browser will open the PDF file in an Acrobat window instead of the browser window.
To configure the browser to use Acrobat or Adobe Reader to open PDF files:
Note: The next time you select a link to a PDF file, the browser may prompt you to open or save the file. If you choose to open the file, the browser opens the file in the helper application that you specified. If you choose to save the file, the browser downloads the file to the hard disk.
Upvotes: 1