Stefano Franchini
Stefano Franchini

Reputation: 11

swt browser diplays pdf in new window

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

Answers (2)

Hatley
Hatley

Reputation: 259

A different IE setting resolved this for me when running Eclipse 2019-03 and OpenJDK 11 (64-bit) on Windows 7:

  1. Open Internet Explorer
  2. Settings>>Manage add-ons>>Toolbars and Extensions..
  3. Find the menu under Show in the lower-left, change to All add-ons
  4. Find Adobe PDF Reader under the Adobe Inc. section, near the top of the right-hand pane
  5. Change the Status from Disabled to Enabled
  6. Hit Close button
  7. Then try running your SWT Browser instance again with the 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

flavio.donze
flavio.donze

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:

  • Quit Internet Explorer.
  • Start Acrobat or Adobe Reader.
  • Choose "Edit" > "Preferences."
  • Select Internet in the list on the left.
  • Deselect "Display PDF" in Browser, and click "OK."
  • Restart Internet Explorer.

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.

https://helpdesk.egnyte.com/hc/en-us/articles/201637224-How-Do-I-Open-PDF-Files-in-Adobe-and-Not-Internet-Explorer-

Upvotes: 1

Related Questions