Solved

How to Disply a PDF ByteArray in Flex

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

20 Experts available now in Live!

Get 1:1 Help Now