Reputation: 1
I used the apache royal 0.9.7 stable to implement a feature to display pdf from server.
Here is a sample code:
var byteCharacters:String = unescape(encodeURIComponent(pdfData));
var byteNumbers:Array = new Array(byteCharacters.length);
for (var i:int = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray:Uint8Array = new Uint8Array(byteNumbers);
var file:Blob = new Blob([byteArray], {type: 'application/pdf'} as
BlobPropertyBag);
var fileUrl:String = URL.createObjectURL(file);
window.open(fileUrl);
When trying to view the pdf file, I get this error in console:
ReferenceError: BlobPropertyBag is not defined
I saw same issue on https://github.com/apache/royale-compiler/issues/81, then I tried the nightly 0.9.8, but I still have the same issue.
Can anyone help why the dependency is not found ?
Upvotes: 0
Views: 335
Reputation: 507
For what I see in framework code (i.e: org.apache.royale.storage.providers.WebStorageProvider
, the use is:
COMPILE::JS {
var blob:Blob = new Blob([text], new BlobPlainTextOptions());
fileWriter.write(blob);
}
... and in the same file add a helper class ...
COMPILE::JS
class BlobPlainTextOptions implements BlobPropertyBag
{
public function get type():String
{
return "text/plain";
}
public function set type(value:String):void
{
}
}
Upvotes: 0