Re: Needed Urgent Help:How to display PDF conent of page in GWT Panel or frame or HTML in HtmlPanel + source code

1,305 views
Skip to first unread message

Philippe Lhoste

unread,
Nov 15, 2012, 5:02:43 AM11/15/12
to Google-We...@googlegroups.com
On 14/11/2012 13:52, singh ajay wrote:
> I am generating PDF file using JRXML using Java JASPEREXPORTMANAGER.
> but i don't know how to view pdf in gwt UI.
> any frame or special container require.

Most of the time, the PDF file is downloaded, unless the user installed and activated some
plugin to show it in the browser, but then it uses the full page.

There is at least one (to my knowledge) tentative to make a JavaScript PDF reader, but I
am not sure if it is complete.

Now, I question the point of your request: either you want to deliver a PDF content,
generally to be saved on the user's computer, so you don't need to display it, or you want
to deliver some visual content to be displayed in a browser, and then you can use HTML or
canvas. I am not sure why you want to display PDF as part of a Web page.

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

Christof Kaller

unread,
Nov 15, 2012, 6:30:56 AM11/15/12
to google-we...@googlegroups.com
Hi,

Philipe is wright. The user needs to install a plug-in. An alternative indeed is using a javascript rendering engine- don't remember the name of it, but know that there is one.

Another way is to use google docs for it, then u can actually view it in an iframe as well.


try:

<iframe src="http://docs.google.com/viewer?url=http%3A%2Fwww.maneofsite.com%2FnameOfPDF.pdf&embedded=true" width="600" height="780" style="border: none;"></iframe>

Christof

2012/11/15 Philippe Lhoste <Phi...@gmx.net>


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--

Christof Kaller
 
An de Krütpasch 15
47661 Issum
 
T: +49(0)2835-440 724 / M: +49(0)177-23 44 54 8
E:
Christo...@googlemail.com
 
Der Inhalt dieser E-Mail ist vertraulich und ausschließlich für den bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein sollten, so beachten Sie bitte, daß jede Form der
Kenntnisnahme, Veröffentlichung, Vervielfältigung oder Weitergabe des Inhalts dieser E-Mail unzulässig ist. Wir bitten Sie, sich in diesem Fall mit dem Absender der E-Mail in Verbindung zu setzen.

Glenn Picher

unread,
Jul 18, 2013, 4:23:50 PM7/18/13
to google-we...@googlegroups.com, christo...@googlemail.com
This is a nice idea. Unfortunately the PDF drew blank in Firefox, and drew instead of the PDF file a security warning in IE 10. Worked in Chrome and Safari though. (All on Windows.) It also draws with a grey border and some viewing controls you might or might not want. Thanks for the suggestion.

Petro Blagodir

unread,
Mar 9, 2015, 6:38:54 PM3/9/15
to google-we...@googlegroups.com
Hello Ajay!

you need to do following things.

1. Create servlet (on server side) which will convert pdf to image
2. in gwt show image instead pdf

Please take a look at screen shot in the attachment, there is pdf viewer developed on gwt.

            if ("application/force-download".equals(fileType) ||"application/pdf".equals(fileType) ){
        response.setContentType("image/png");        
        try{        
            RandomAccessFile raf = new RandomAccessFile(file, "r");            
            FileChannel channel = raf.getChannel();
            ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());            
            PDFFile pdffile = new PDFFile(buf);
            if (pdffile.getNumPages() < pageNumber){
            pageNumber = pdffile.getNumPages();
            }
             PDFPage page = pdffile.getPage(pageNumber);
                BufferedImage img=null;            
                int w = (int) page.getBBox().getWidth();
                int h = (int) page.getBBox().getHeight();
                Rectangle rect = new Rectangle(0, 0, w, h);
                int rotation = page.getRotation();
                Rectangle rect1 = rect;
                if (rotation == 180) {
                rect1 = new Rectangle(0, 0, rect.height, rect.width);
                }                        
                img = (BufferedImage) page.getImage( (int)(w+w*coef), (int)(h+h*coef),rect1,null,true,true);                      
                ImageIO.write(createResizedCopy(img, (int)(w+w*coef), (int)(h+h*coef),fileName,rotate,isSmall,coef), imageOutput, response.getOutputStream());
           
            
            
            


Here is code example 


On Wednesday, November 14, 2012 at 2:52:33 PM UTC+2, singh ajay wrote:
Hi Folk,
can any one help me out with my problem,
I am generating PDF file using JRXML using Java JASPEREXPORTMANAGER.
but i don't know how to view pdf in gwt UI.
any frame or special container require. 
 
Do let me know.
 
Ragards,
Ajay Singh, Mumbai, India 
pdf_to_image.png
Reply all
Reply to author
Forward
0 new messages