# Pdf download via FileReference

**URL:** <https://forum.kirupa.com/t/pdf-download-via-filereference/300641>\
**Category:** flash\
**Created:** [November 25, 2009, 1:07am UTC](https://forum.kirupa.com/t/pdf-download-via-filereference/300641 "2009-11-25T01:07:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wolcotter](https://avatars.discourse-cdn.com/v4/letter/w/6bbea6/32.png) [@wolcotter](https://forum.kirupa.com/u/wolcotter)\
**Post date:** [November 25, 2009, 1:07am UTC](https://forum.kirupa.com/t/pdf-download-via-filereference/300641/1 "2009-11-25T01:07:59Z")

</div>

Attempting for the first time to code a pdf download. Here is the code I’m using:

```auto
pdfBtn.addEventListener(MouseEvent.CLICK, dothis);

function dothis(e:MouseEvent):void {
		
	var fr:FileReference = new FileReference();
	var req:URLRequest = new URLRequest("this.pdf");
	
	try {
		fr.download(req);
		}
		catch (illegalOperation:IllegalOperationError) {
			// code to handle an illegal operation error
		}
		catch (security:SecurityError) {
			// code to handle a security error
	}
}

```

Can anyone tell me what I’m doing wrong here? TIA.
