4 Replies Latest reply on Oct 29, 2009 7:20 AM by Patrick Leckey

    Stream XFDF to client (Classic ASP)


      Hi there,

      I need to be able to construct the xfdf in classic ASP and stream it to the client. Right now, I'm getting the following error in Reader when I try to load the ASP page that generates and then streams the xfdf:


      Adobe Reader could not open 'xfdftest.xfdf' because it is either a not supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded.


      I know the xml is fine - when I store it as a physical .xfdf and double click it, it launches the appropriate PDF with the correct data filled in. But anytime I try to create the xml in a script and stream it, I get that error. I'm really hitting a wall here - any ideas?


      I suspect I'm doing something wrong when constructing the XML but  no matter what I try, I cannot get this to work.


      Here's the code I'm using:


          dim strMsg
          strMsg = "<?xml version='1.0' encoding='UTF-8'?><xfdf xmlns='http://ns.adobe.com/xfdf/' xml:space='preserve'><f href='DS.pdf'/><fields><field name='name'><value>FullName</value></field></fields><ids original='FC0D4122940FB4DCF24FDB6C4862108E' modified='376DB033EF002448B7235EE2C5970D9F'/></xfdf>"


          ' Get stream object
          Dim oStream
          Set oStream = Server.CreateObject("ADODB.Stream")

          ' Open Stream
          oStream.Type = 1 'adTypeBinary

          on error resume next
          oStream.WriteText strMsg

          on error goto 0
          if not oStream.EOS then
              Response.BinaryWrite oStream.Read
          end if

          Set oStream = Nothing

          'Response.Write strMsg


        • 1. Re: Stream XFDF to client (Classic ASP)
          DavidMcDivitt Level 1

          Do you still need an answer?


          When I stream reports I send a header that causes a view/save dialog to appear at the client. With PHP I do it as follows:


            header("Content-disposition: attachment; filename="Filename.ext");
            header("Content-type: document/text");

            Send out whatever text, report, etc. Set the filename extension ".ext" to be whatever it should be for the type file.


          ForASP.NET I do the following:


                Response.ContentType = "application/x-pdf"
                Response.AddHeader("content-disposition", "attachment; filename=OnCallReport.pdf")

                In this case "bytes" contains the entire output stream and it happens to be a PDF being sent.


          I'm working on a Classic ASP application right now that will stream out a PDF. I will do similar header statements, then send the whole constructed PDF file verbatim.

          • 2. Re: Stream XFDF to client (Classic ASP)
            anoeno Level 1

            I definitely still need an answer - thanks for your help!


            I don't have a problem streaming a PDF. I run into issues when trying

            to stream the XFDF file. When I double click the XFDF on the server,

            it behaves like I want. It launches acrobat and opens the PDF with the

            data from the XFDF. So, I want to do the same thing through the

            browser. The user will click a link to the XFDF file, which should

            then launch acrobat and open the PDF.


            Right now, it launches Acrobat, but acrobat complains of the error I

            stated before. I'm so close I can taste it!


            Thanks again for your perspective!

            • 3. Re: Stream XFDF to client (Classic ASP)
              DavidMcDivitt Level 1

              When you stream the PDF out, try changing the filename extension to .pdf and see what happens.

              • 4. Re: Stream XFDF to client (Classic ASP)
                Patrick Leckey Level 3

                XFDF is a text format, you should not be streaming it as binary.  You also need to set your charset header to UTF-8.