Solved

How to Disply a PDF ByteArray in Flex

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Flex organization chart 5 612
AdvancedDataGrid 4 354
DropDownList Skin 5 1,258
Why does my Sprite always have a width and height of ZERO? 2 966
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…
For months I had no idea how to 'discover' the IP address of the other end of a link (without asking someone who knows), and it drove me batty. Think about it. You can't use Cisco Discovery Protocol (CDP) because it's not implemented on the ASAs.…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

13 Experts available now in Live!

Get 1:1 Help Now