Question

I have tried few things but no success. I want to prompt user on button click event to save PDF file in local computer generated from object array which were created by user at runtime.

Any sort of help is greatly appreciated Thanks

I have revised target flash player 10.0 in the html and somehow found out that the save event call has to be on button click event and I already have that. but still it gives me error and does not even generate swf file.

Here is the code and error.

1061: Call to a possibly undefined method save through a reference with static type flash.net:FileReference. It gives me this error.

var cFile:FileReference = new FileReference();
var gBytes:ByteArray = this._myPDF.save(Method.LOCAL);
cFile.save(gBytes,"test.pdf"); 
Was it helpful?

Solution 2

If you just want to prompt user to save the file in local system, you can try FileReference for that.

like :

file = new FileReference();
file.addEventListener(Event.COMPLETE, completeHandler);
file.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
file.save(mc, "myMovieClip");

here mc is any type of data you can provide, in your case you can provide your dynamically generated PDF file, and "myMovieClip" is name which you wan to give that file.

try this, might be useful for you.

OTHER TIPS

You can try the following, if you want to make download by using specific URL(where file is stored).

var urlRequest:URLRequest = new URLRequest("your_pdf_url");
fileRef = new FileReference();
fileRef.download(urlRequest, "your_file_name.pdf");

I was using CS3 and changing the target player to 10 in HTML but found out that can not be simple. The compiler should have 10.0 as an option so I had to jump to CS6 and it worked as Vipul suggested. target player I had to keep 10.3. I had to change one more thing which is not related to this PDF saving. And that is VideoEvent to Event. I am wondering why adobe had to change that for FP 10 and above. Good to know if anybody want to use. Event.COMPLETE not VideoEvent.COMPLETE once again thanks a lot Vipul I will check the second import statement flash.utils.ByteArray. I must have because I did not get any error

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top