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 <[email protected]> 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 <[email protected]> wrote:
>
> > On Mon, Feb 16, 2009 at 4:05 PM, koko <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to