Bonjour,
Je galère depuis un petit moment pour afficher des pdf téléchargés dans mon application air.
Les PDF sont récupérés pas une URL du type http://hostname/getdocument.aspx?id=10
Dans une ancienne application flex (non AIR), j'utilisais la fonction navigatetourl avec un petit bout de code javascript permettant d'afficher mon PDF dans le butineur
(navigatetourl("(javascript:) window.open('http://...) )
. Sous Air cette solution provoque des erreur Sandbox que je ne sais pas contourner.
j'utilise donc un petit code source récupérer sur internet CPDFPREVIEW. Mais le résultat n'est pas probant. Mais j'ai du oublié un truc!!!
En utilisant le code suivant, j’obtiens un écran vide. Par contre si j'affiche une page HTML, tout fonctionne bien.
Merci d'avance de votre aide
Mon code Flex est le suivant.
Code CPDFPreview.MXML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| <?xml version="1.0" encoding="utf-8"?>
<mx:Window xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="912" height="636"
creationComplete="init();"
>
<mx:Script>
<![CDATA[
import flash.display.NativeWindow
private const DEFAULT_TITLE:String = "PDF Preview";
private function init():void {
this.transparent = false;
this.alpha = 1.0;
this.rotation = 0;
this.nativeWindow.stage.scaleMode = "noScale";
this.htMainView.htmlLoader.navigateInSystemBrowser = true;
}
public function loadURL( anURL:String = "http://your.url.default/", showStatusLocation:Boolean = false ):void {
title = DEFAULT_TITLE;
if ( true == showStatusLocation ) {
status = ' Dateipfad: ' + anURL;
}
htMainView.location = anURL;
this.htMainView.setVisible(true);
}
public function loadFile( anURL:File, showStatusLocation:Boolean = false ):void {
if ( null != anURL ) {
loadURL( "file://" + anURL.nativePath, showStatusLocation );
}
}
]]>
</mx:Script>
<mx:HTML id="htMainView" right="0" left="0" top="0" bottom="0" visible="false" height="100%" width="100%"/>
</mx:Window> |
Dans mon programme principal mon code est le suivant :
1 2 3
| private var aPreview:CPDFPreview = new CPDFPreview();
aPreview.open( true );
aPreview.loadURL("http://localhost:49684//getdocument.aspx?id=14833.pdf&type=pdf", true); |
Partager