View Full Version : Open a PDF file in a dialog window
sarsipius
19 Feb 2009, 6: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
19 Feb 2009, 11:17 AM
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
19 Feb 2009, 12: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
3 Mar 2009, 2:14 AM
thnaks for your answers
it helps a lot :)
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.