Solved

How to Disply a PDF ByteArray in Flex

Posted on 2010-09-16
5
1,519 Views
Last Modified: 2012-06-22
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?
0
Comment
Question by:MicheleDunham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33700792
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.
0
 

Author Comment

by:MicheleDunham
ID: 33703185

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;
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33705497
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.
0
 

Accepted Solution

by:
MicheleDunham earned 0 total points
ID: 33705550
Yes, that works the same in a .NET aspx page.  However I don't know how to accomplish what you suggest in a web service..  I can use the FileReference class in Flex to allow the user to save the ByteArray as a pdf to disk, but there isn't a way to allow the user to view the pdf in the application or bring up a browser window with the pdf.  In order to do this the client has to download a URL from the server.  At least that is what I think has to happen.  Thanks for your input.
0
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33707840
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).
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question