Hi Ginger: Thanks a lot for your kind help :) Yeah that's what I really want to do. but there is still a problem, now I am just in development period, how can I write a servlet that can share the session with GWT project ? For now they are using different port and probably different tomcat? Also my textara contains some of the pictures, can I get them in the PDF as well? when I get the content of textarea I just use textarea.gettext();
Thanks a lot for your help! Regards. On 2月17日, 上午9时53分, ginger_ninja <david.s.k...@gmail.com> wrote: > Hi koko, > > Ian is right, I encountered this exact same problem on the project I'm > currently working on. In your case it sounds like you want to send > some data from a textarea over to the server and put some dynamic > content in the PDF, is that right? > > The best solution I've found is to separate what you're doing into two > stages. The first stage I call the preparation stage. The preparation > stage involves preparing the data create the PDF from and storing it > somewhere temporarily, in my case I used the user's session. Once the > data is prepared and stored away you can safely complete the RPC > call. > > The second stage is what I call the generation or retrieval stage. > This involves actually generating and retrieving the PDF using the > data that was previously stored in the session. This stage is > triggered in the onSuccess callback method of the previous RPC call. > Really all that needs to be done inside the onSuccess method is to > open a new window and point the window.location property to the URL of > the servlet you're going to create. Using Ian's technique you can > write a simple servlet like he said, generate the PDF using the stored > data, and set the content type to application/pdf before writing the > byte stream to the servlet's output stream (you can find this inside > the HttpResponse object). This will tell the browser that a PDF is > coming it's way and it will automatically handle it appropriately. > > Dave > > On Feb 17, 11:54 am, koko <ang.ga...@gmail.com> wrote: > > > Thanks Ian, I had tried this way, but what how should I post my data > > in textarea to the server side? I encounter like SOP errors, for my > > tomcat runs on port 8080, while GWT on 8888, I also tried to set in > > the same port 8888, won't work, can you teach me how to configure or > > set in detail, I am doing this for my project, thanks for a lot! > > Regards. > > > On 2月17日, 上午12时34分, Ian Petersen <ispet...@gmail.com> wrote: > > > > On Mon, Feb 16, 2009 at 4:05 PM, koko <ang.ga...@gmail.com> wrote: > > > > I have a problem with converting byte array to pdf file, this will be > > > > processing in the client side. > > > > in my project the PDF file was constructed by the content in the > > > > textarea which user type in, after user press PDF button it will > > > > trigger RPC call and get byte array response from server side, > > > > actually it was a PDF file, I want to shown it to the user and let > > > > them download. > > > > Now after RPC byte array was stored in variable called result, what > > > > should I do next? Can anyone help me please.. > > > > That approach won't work. To serve a PDF to the user, write a servlet > > > that spits out the PDF, annotated with the appropriate Content-Type > > > header. When the user presses the PDF button, either open a new > > > window or display an iframe and, in either case, set the URL for the > > > new window to be the address of your PDF-generating servlet. If you > > > want to prompt the user to save the PDF to disk rather than displaying > > > it the browser, set the Content-Disposition header appropriately. (I > > > forget what value you need there, but you should be able to find it > > > with a good search engine.) > > > > Ian --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---