swt browser diplays pdf in new window - java

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

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-

A different IE setting resolved this for me when running Eclipse 2019-03 and OpenJDK 11 (64-bit) on Windows 7:
Open Internet Explorer
Settings>>Manage add-ons>>Toolbars and Extensions..
Find the menu under Show in the lower-left, change to All add-ons
Find Adobe PDF Reader under the Adobe Inc. section, near the top of the right-hand pane
Change the Status from Disabled to Enabled
Hit Close button
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).

Related

How to attach a chrome window to a desktop application Selenium?

My problem is when I click on a desktop icon, it opens a link in already opened chrome browser in a new tab. How do I attach with the already opened browser and not a new one?
The below code returns a null because there is no window opened through selenium ofcourse, so yeah.
Set<String> windows = webdriver.getWindowHandles();
System.out.println(windows);
Any suggestions would be of great help. Thanks In advance.
There is no way to attach the chrome window that you've opened from the desktop application to your WebDriver instance.
If you want to be able to control a web page with a Selenium - you must pass your URL to a driver like that:
webdriver.get("https://www.your_link.com");
You might think about the way of getting and storing your URL as a variable and passing it into your code.
That would also be helpful if you add a bit more details about the problem. It's a bit unclear at what stage of the test you open the web page with a desktop application. Selenium can't be used to test desktop applications. Code sample of the test from your project would also help.

Adobe acrobat DC and its toolbar in selenium java

I am working on application and using Firefox, in that i have PDF in on of the page. and i have below questions on that,
PDF is not getting opened in web page itself instead it is asking with link 'Tap here to activate plugin' (inside place where pdf will open). Once i click on that it will get open. But through selenium code i am not able to click on that(not able to identify element). i tried to use setPreference but Adobe Acrobat is not getting activated.
IF the PDF opens then i have to mouse over on that and perform action like print, zoom-in and zoom-out on Adobe Acrobat DC toolbar and validate functionality.
Could you please help me to resolve these two issues screen shots are attached.
Thanks

Run IntelliJ JSP code in Chrome rather than display source code

When developing a web page, IntelliJ has browser icons which appear in the top right corner of the editor when you mouse over the area. It used to be for me that if the active file in the editor was a JSP, I could click on my IntelliJ-Chrome icon. This would launch Chrome and what would be displayed would be what the JSP would look like in a browser. I imagine that it was a preview of sorts. This way, I didn't need to run my entire program when all I wanted was to see what my JSP looked like.
I recently reinstalled all my software and lost all my previous settings. Now, when I click on my IntelliJ-Chrome icon, Chrome just displays the JSP source code that is in the editor. How do I get Chrome to run the JSP instead of just display the code?
Everything works fine when I run the entire project through Tomcat.
Additional information 01:
I noticed that when Chrome is displaying these JSP's, the address bar shows the location of the file on my hard drive rather than through localhost. I do of course have a Tomcat Run Configuration set for the project, so I wonder if there is a setting in IntelliJ that is causing the JSP to not get sent through my Tomcat configuration. I have looked this up in the IntelliJ forums and found this post which addresses a similar issue. The answer given is:
You have to configure and mark as default a deployment entry at
"Settings | Deployment
Additional Information 02:
When using these icons, I believe what is launched is not necessarily any run configuration, but the path configuration of the browser. This is located in IntelliJ at Settings -> Tools -> Web Browser.
I can modify the path to go to http:\localhost:8080\, but what this does is launch the OS default browser, not Chrome, at the project welcome page, not the active page in the editor.
You need to have an active Tomcat run/debug configuration. Once you start it and the app is deployed on the server, clicking the browser icon in the editor will open the URL corresponding to the the .jsp file in the browser.
IDE needs to know the deployment context and the server URL for this feature to work which is not possible without Tomcat run configuration.
Clicking the icon for index.jsp in this example will open http://localhost:8080/index.jsp in the browser.
Your Tomcat server is responsible for rendering of the JSP code. Browser just parces HTML (potentially with CSS/JS). JSP is serverside technology. You should run server first, than your favorite icon should work.

None of the buttons(Save, Open, Cancel) attributes in IE developer tool not show up

Requirement is to download the Excel file from IE9 browser. I could able to click the Download button using Web driver in Java by which new window is displayed as shown below:
When I am trying to view the attributes of save button in IE developer tool, tool could not recognize them. Please help where is the problem with this window or how to resolve this issue.

SVG viewer alternative for flash rendering in IE

Hi i have a problem with svg viewer in Internet Explorer, because i use flash, maybe you can suggest me another solution for this browser.
The Chrome Plugin for Internet Explorer is very seamless. We use it in several projects and have been able to display a simple error message to the user indicating that they need to install the plugin.

Categories

Resources