Solved

How to Disply a PDF ByteArray in Flex

Posted on 2010-09-16
5
1,512 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques. This attack comes as a nightmare trifecta for email filtering services; sent from a familiar contact, using authentic tone and verbi…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now