Link to home
Start Free TrialLog in
Avatar of MicheleDunham
MicheleDunham

asked on

How to Disply a PDF ByteArray in Flex

I have a .NET web service that I am calling from a Flex application.  The web service returns a PDF as a ByteArray that I would like to display in a new browser window.  I believe I need to use a combination of the URLRequest and URLStream classes to accomplish this task.  Is there a good example on how to do this?
Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

The problem is that Flex is not able to display PDFs. Even if both are Adobe Products, you cannot display a PDF in Flex. The best solution would be to have an aspx page serialize the ByteArray with a MIME Type for PDF and have that content displayed in an IFrame.
Avatar of MicheleDunham
MicheleDunham

ASKER


I'm not sure how to hook in the aspx page with the web service?  This is the code the web service executes to generate the ByteArray.  Since the export bytearray is already in a PDF format would it be possible then to use the AlivePDF library to save or display the document?

 // Export the Report to a PDF Byte Array
           
            MemoryStream oStream;
            oStream = (MemoryStream)drillDownCrystalReport.ExportToStream
                (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Byte[] reportPDFByteArray = oStream.ToArray();

            //  Return the PDF Byte Array to the Calling Program

            return reportPDFByteArray;
Well unfortunately I am a Java Guy and not very familiar with the details of aspx pages. In the Java world we have a Response object and you can get a reference to it's output stream which sends everything you write in that stream to the client.
ASKER CERTIFIED SOLUTION
Avatar of MicheleDunham
MicheleDunham

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sending this to the client via WebService will not work. Not if you want to display the PDF in the client. If you want to do this you have to send back the PDF the old-fashioned way using a simple aspx-page (in your case).