These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Submit to ASPX page (FDFToolkit) and Redirect Problem

kyleshea22
Registered: Dec 18 2009
Posts: 9

Hi Guys,

I have a website that contains a page that serves up PDFs via embedding with an tag. The reason for embedding is to use the hostContainer object to pass data back & fourth between the web page and PDF doc in some instances. This works quite well.

The PDFs ultimately SUBMIT (via javascript) to an aspx web page - a listener if you will. This page uses the FDFToolkit to open the FDF from the stream (FDFOpenFromBuf), perform some other tasks, and ultimately needs to redirect to another ASPX page. I do not have a need to send any FDF back down to the browser - once the user clicks SUBMIT from within the PDF and the document is processed by my listener page - I simply need to redirect to a new, unrelated page.

The problem is that upon redirect (after closing and cleaning up the FDF and other object(s)), the site hangs. I can see the page name of the intended redirect target page in the address (URL) bar - but the page is either never fully loaded or takes SEVERAL minutes. In some instances the page is loaded quickly but hangs on loading any IMAGES withing the page.

I suspect something is going on with needing to clear the response before attempting to redirect? I have tried EVERYTHING, including using certain combinations of response.end(), response.clear(), etc. etc. etc. Nothing seems to work here. Another strange thing is that if I don't load the PDF into an tag embedding it in the page - the redirect works as expected. In other words - if I do the PDF SUBMIT from the URL of http://test.com/PDF.pdf - the redirect on the listener page WORKS. If I do it from http://test.com/container.aspx?path=PDF.pdf (which successfully loads the PDF in the page by path into an tag on the page container.aspx. So this must also have something to do with having the PDF loaded as an on the "container" page.

Does anybody have any thoughts here? I've been stuck on this one for several days - your input is GREATLY appreciated!

Kyle

My Product Information:
Acrobat Pro 9.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Acrobat does act differently depending on how it's loaded, or not loaded, into the browser. It also works differently in different versions. And depending on whether the PDF is displayed in Reader, or the Full Acrobat. And depending on whether the submission URL ends with "#FDF". So there are a lot of variations here, several of which you don't have any control over, like the client side browser, PDF viewer, and settings.

The best way to handle all these issues is to break the submit operation down to the lowest common denominator.

1. Acrobat/Reader Always expects an HTTP Response.
2. The simplest, most broadly well handled response is FDF data.

So, always append the submission URL with "#FDF", and return FDF. This doesn't have to be anything really meaningful, you don't need to send back any data. My favorite thing to do is to send back a script that displays a friendly message such as "Your data submission has been recieved." This will neatly tie up things with Acrobat/Reader regardless of the viewer situation. And then you can redirect the browser to a new page.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kyleshea22
Registered: Dec 18 2009
Posts: 9
Thom, thanks so much for the direction. So - from what I gather - after a submit from a PDF (embedded in an asp.net page) to url appended with #FDF, I should be able to return ANY FDF send back down to browser, then redirect to the final page... I'm trying a few things right now but so far am unsuccessful. What is the format of actually returning a script within FDF? I'm thinking I can just build an FDF string "chunk" in regular text and then send it down to the browser via the response object (.net) - after ensuring the contnet-type is "application/vnd.fdf" of course... But I'm unsure of the proper way to format an FDF block of text and include a javascript to pop a warning message... Does anything need to be specifically to the FDF to tie it into the PDF currently displayed in the browser. Does it complicate matters that I'm technically sending data back down to an ASP.NET PAGE and not the PDF file URL itself? (Remember the address that is shown in the browser duing all of this is actually "http://test.com/Container.aspx" - NOT "http://test.com/Foo.pdf" ...

Thanks again!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
FDF has a script tag, look it up in the PDF reference. Here's an example, it's all plain text. You could put this in a single string.
%FDF-1.21 0 obj<</FDF<</JavaScript <</Before (console.println("Before Import Script");)>>>>>>endobj

trailer << /Root 1 0 R >>%%EOF

For data returned from a submit the FDF is generic. Acrobat is waiting for a response and it will consume anything that comes down the pipe.

Test it out in the stand alone Acrobat first to make sure it all works.


Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kyleshea22
Registered: Dec 18 2009
Posts: 9
Thanks again, Thom. I am using asp.net's response.write() method to send down a simple chunk of FDF (of which the javascript runs fine in standalone Acrobat) - and I get the error/message "A file I/O error has occurred" when the FDF hits the browser. I've tried clearning the response before I write to it, clearing/resetting headers, etc. Nothing seems to work. I'm hopelessly stuck :(
kyleshea22
Registered: Dec 18 2009
Posts: 9
UPDATE: The processing page (submit target) was actually inherited from a master page in the project... When I changed this - I no longer get the "File I/O" error from Acrobat - but still am not able to redirect (i.e. via response.redirect()) because apparently I "can't redirect after http headers have been set..." This I think I may be able to work out, however :)
kyleshea22
Registered: Dec 18 2009
Posts: 9
Seems exceedingly difficult to REDIRECT after having already returned FDF back down to the browser. I do beleive I just need to find the appropriate combination of clearing/setting headers and response content, flushing, ending, etc. and it will work. So far though, every combo I can think of has been unsuccessful.
kyleshea22
Registered: Dec 18 2009
Posts: 9
WORKAROUND: Only a client-side redirect seems to work here. Set a javascript redirect with a delay in the regular page body, fires after the codebehind is done, seems to work fine. This is my solution for now :)
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
That's what I was going to suggest. Actually, I was thinking of adding an "app.launchURL()" call to the "AFTER" code in the FDF. But I'm glad you got it figured out.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

dchaffin
Registered: Jul 7 2010
Posts: 1
@kyleshea22 ... I've been pulling my hair out for the past several days with the exact same issue you were having. Thanks for the idea of the client-side redirect. Doesn't seem like an ideal solution but at least it is more functional.

However, in Firefox I still get an immediate Bad Request (Invalid Header Name) error. IE was working (or rather, not working) exactly as you described above. Chrome, by the way, never had any of these issues and worked flawlessly.

Did you ever figure out a fix to the actual problem or is the JavaScript workaround where you left yours? I'd really like for this to be able to work in Firefox as well.

Thanks.
NK-INC.COM
Registered: Apr 17 2010
Posts: 93
kyleshea22 wrote:
Seems exceedingly difficult to REDIRECT after having already returned FDF back down to the browser. I do beleive I just need to find the appropriate combination of clearing/setting headers and response content, flushing, ending, etc. and it will work. So far though, every combo I can think of has been unsuccessful.
For programming examples check out:
http://www.nk-inc.com/blog/

or

http://www.fdftoolkit.net/examples/