PDA

View Full Version : Unable to display a pdf in IE when within a popup window


Paul Taylor
Oct 5th, 2005, 10:29 AM
I have a jsp which when you click on a button calls some javascript which uses the window.open method to call a spring controller which then called a subclass of AbstractPdfView to creates a pdf and displays it to screen.

On Firefox browser it works fine but not on IE6, it does not work it brings up an empty window with a 'Cannot Find Server' message. Even though IE fails the controller is correctly called and the PDFDocument built but I think something is wrong with the renderMergedOutputModel() (which is final and hence cant be overridden)

If I change the javascript so that it calls window.location and hence displays the pdf in the main window rather than a popup window it works fine on Firefox and IE, but this is no good to me I need it to open in a new window.

I need to use javascript rather than just usinag a href="url" target="_blank" because I need to determine which report the user has selected for displaying from a list.

relevent parts of jsp

function viewaspdf()
{
var selectedId = getSelectedEntityIdString('listTable');
window.open('http://localhost:9080${pageContext.request.contextPath}/exportreport.do?viewaspdf=' + selectId);
}


<a href="javascript:viewaspdf()" <img src="images/icons/i_pdf.gif"/>PDF</a>

any help appreciated paul

davison
Oct 6th, 2005, 08:51 AM
not being flippant, but it sounds like (yet another) bug in IE. It has had documented issues in the past both with PDF's - wanting to know the content length before downloading it - and JavaScript.

As a test, can you simply try to get a different content type view from your JavaScript call: that at least should determine whether it's an issue with one or the other.

Have you also tried any other browsers (Opera, Mozilla, Safari, Epiphany, Konqueror, et al) to see how they manage it?

Also, try using something like Ethereal or tcpdump to monitor the HTTP stream between client and server and compare with what happens using Firefox.

hth,

Cowboy Bob
Oct 7th, 2005, 07:03 AM
Try making sure the URL has .pdf on the end (often IE ignores mime types and uses file extensions instead - yes, it's a bug).

window.open('http://localhost:9080${pageContext.request.contextPath}/exportreport.do?viewaspdf=' + selectId + '&iefix=fix.pdf');

Bob

soupdragon
Feb 8th, 2007, 04:33 PM
On Firefox browser it works fine but not on IE6, it does not work it brings up an empty window with a 'Cannot Find Server' message. Even though IE fails the controller is correctly called and the PDFDocument built but I think something is wrong with the renderMergedOutputModel() (which is final and hence cant be overridden)


It's not a Spring problem because I'm hitting it with a completely different framework.

Producing a Content-length might be worth a try.