PDA

View Full Version : PDF file downloads instead of showing in window



leowyatt
11 Feb 2011, 4:54 AM
Hi,

I'm trying to display a PDF in a new window and currently all my browser does is download the file. Here is the code I'm using;



this.window = new Ext.ux.MediaWindow({
id : 'PDFViewerWin',
title : 'title',
bodyCfg: {
tag: 'iframe',
src: '/path/to/file.pdf',
style: 'border: 0 none'
},
width : 600,
height : 400,
bodyStyle : 'position:relative; padding:0px;'
});



Am I going about this the wrong way? Is this not possible?

Condor
11 Feb 2011, 5:09 AM
It's better to use an <object> or <embed> tag here instead of an <iframe> (also see the ux.Media user extension).

You could also fix this by changing your server to set the Content-disposition response header to 'inline' instead of 'attachment'.

leowyatt
11 Feb 2011, 5:17 AM
Cheers for the reply Condor

When you say change the tag do you mean, tag: 'object' or tag : 'embed' ?

I don't think I can change the Content-disposition I'm afraid.

If I use embed I get an m is null on this.assert(m.height,height); which I'm assuming m is the PDF.

Condor
11 Feb 2011, 5:29 AM
Try:

{
tag: 'object',
type: 'application/pdf',
data: '/path/to/file.pdf'
}

leowyatt
11 Feb 2011, 5:40 AM
Well I'm getting a window now but it is no bigger than the title bar so it is a start :)

The file isn't downloading anymore

leowyatt
11 Feb 2011, 5:46 AM
Right if I change from 'object' to 'embed' I get the window loads, is the correct size but the content is blank. I have checked taskmgr and I can see adobe running.


EDIT: If I use;



window.open('path/to/file.pdf');


The PDF opens in a new tab

anmol
7 Oct 2012, 11:30 PM
Hi All,
I am tring same thing using ExtJs 4.0
i want to open a PDF in tab, following code works fine in FireFox and chrome.
It embeds PDF but it in IE it opens the 'download window'.

following is the code:
/****************************************************************************/
dashBoardTab.add({
title: 'Admin Help',
padding: '5',
id: 'adminHelp',
closable: true,
html: '<iframe src="../../../../Content/Help/FitChallengeOverview.pdf" width="100%" height="800px" frameborder="0" ></iframe>'

}).show();

/****************************************************************************/