View Full Version : Open a PDF file in a dialog window
sarsipius
02-19-2009, 08:57 AM
Hi all,
I am trying to code an app with a list of files in a grid and I want to show a Dialog window with the PDF in it
I don't understand how I can do it.
Could you please help me?
jpnet
02-19-2009, 01:17 PM
Something like this works:
Dialog d = new Dialog();
d.setWidth(500);
d.setHeight(700);
d.setUrl("http://someurl.com/your.pdf");
d.show();
It's important that your server is setting "Content-Disposition" HTTP header to "inline" and not "attachment."
-JP
jpnet
02-19-2009, 02:10 PM
I needed something useful... so I coded this:
public class PdfDialog extends Dialog
{
private PdfDialog self = this;
private String m_url = "";
private String m_title = "";
private final float SCREEN_PERCENT = 0.75f;
public PdfDialog(String httpPdfUrl)
{
m_url = httpPdfUrl;
this.setUrl(m_url);
int pos = m_url.lastIndexOf("/");
if (pos >= 0)//absolute
m_title = m_url.substring(pos + 1);
else //relative
m_title = m_url;
this.setHeading(m_title);
El el = XDOM.getBodyEl();
this.setWidth((int)(el.getWidth() * SCREEN_PERCENT));
this.setHeight((int)(el.getHeight() * SCREEN_PERCENT));
this.okText = "Close";
this.getButtonBar().getButtonById(Dialog.OK).addListener(Events.Select, new SelectionListener<ButtonEvent>(){
public void componentSelected(ButtonEvent ce){
self.close();
}
});
}
}
Hopefully you find it useful too.
-JP
sarsipius
03-03-2009, 04:14 AM
thnaks for your answers
it helps a lot :)
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.