PDA

View Full Version : Open pdf file in an Ext window



senacle
29 Jun 2010, 6:25 AM
I would like to open a pdf file in an Ext window.
The 'Stat/data.php' script creates a pdf file. This file can be saved to local disk or sent to the browser.


I found this : http://www.sencha.com/forum/showthread.php?98860-Open-a-new-browser-window&highlight=pdf

And my code :


Ext.Ajax.request({
url: 'Stat/data.php', //used to save pdf file to local disk
params: { statut: statut, date_debut: date_debut, date_fin: date_fin, categorie: categorie },
success: function (response, action) {
obj = Ext.decode(response.responseText);
var chemin_fichier_pdf = obj.message;
new Ext.Window({
height: 600,
width: 700,
bodyCfg: {
tag: 'iframe',
src: chemin_fichier_pdf,
style: 'border: 0 none'
},
modal: true
}).show();
bouton.enable();
},
failure: function(response, action) {
Ext.Msg.show({
title: 'Information',
closable: false,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
bouton.enable();
}
});


All is working fine.


Can i use only the Ext.Window with success and failure without the Ext.Ajax.request ?

I've tried



var src = 'Stat/data.php?statut='+statut+'&date_debut='+date_debut+'&date_fin='+date_fin+'&categorie='+categorie;

new Ext.Window({
height: 600,
width: 700,
bodyCfg: {
tag: 'iframe',
src: src,
style: 'border: 0 none'
},
modal: true
}).show();


But the datas are sent via GET method (i would prefer POST) and i didn't find in the Window API how to have success/failure events.

Animal
29 Jun 2010, 6:28 AM
Then you'll have to use a form DOM submit with the target of the form, the iframe.

See Ext.data.Connection for how to do that. You're experienced enough to do that on your own.

senacle
1 Jul 2010, 12:35 AM
Then you'll have to use a form DOM submit with the target of the form, the iframe.
This is for having POST datas.

I did some other searches in the forum and made some reflexion.
For the second point, i was thinking first that 'Stat/data.php' send a success (and the pdf) or failure.
But the pdf can't be get via ajax (See http://www.sencha.com/forum/showthread.php?80036-SOLVED-Download-data-from-variable-with-a-browser-prompt/page2).

So, i keep the second code above (with GET datas and pdf 'on the fly').

Maybe i will try later with POST and success/failure.



You're experienced enough to do that on your own.
Maybe i'm not so experienced as you were thinking, Animal.

senacle
10 Nov 2010, 5:58 AM
Until last monday, i've tested my code only under firefox.

Now, i did some tests under IE (6, 7 and 8) and i've the following error :

This object doesn't manage this property or method (line 3391) (ext-all-debug.js)

I did some search and i've found that it's the :


tag: 'iframe'

which causes this error.

Animal
10 Nov 2010, 6:12 AM
Try setting http://dev.sencha.com/deploy/dev/docs/?class=Ext.DomHelper&member=useDom to true

senacle
12 Nov 2010, 12:24 AM
I use


Ext.DomHelper.useDom = true;

at the beginning of my code, but the problem is always here...

senacle
15 Nov 2010, 5:32 AM
Sorry for mistake.
The code at the beginning of this thread isn't exactly the one which causes the error under IE.

Take a look at Open pdf file in an Ext window - Bug under IE with iframe (http://www.sencha.com/forum/showthread.php?115794-Open-pdf-file-in-an-Ext-window-Bug-under-IE-with-iframe&p=539101#post539101) for more details