Donnez vie à vos documents numériques !
 

Répondre à : Intéractivité entre tableau et graph dans un PDF. – RÉSOLU

abracadabraPDF Forums PDF – Général Intéractivité entre tableau et graph dans un PDF. – RÉSOLU Répondre à : Intéractivité entre tableau et graph dans un PDF. – RÉSOLU

#53930
nabnub
Membre

Salut,

merci pour les infos,

en utilisant simplement les sources que j’ai posté plus haut j’ai réussit a faire ça:        http://cjoint.com/?BKpmS04qVpn  

ça marche en tout cas mais bon la légende n’est pas bonne, et les 5 derniers champs ne sonr pas prit en compte

maintenant j’aimerai bien pouvoir utiliser cette méthode et l’appliquer à mon form

j’ai essayé donc sous adobe flash builder de créer un flex project,

image du dossier et de ses fichiers:

http://s15.postimage.org/yyzi9n3q3/Untitled.jpg

puis j’ai utilisé le code que le gars propose (Acrobat_FlexChartFromTable.mxml)
et j’ai essayé de la modifier

par contre l’autre code (defaultChartData.xml) je ne comprend pas vraiment ce qu’il fait mais je sais qu’on l’utilise comme je l’ai expliqué plus haut,
car en effet dans le code du fichier Acrobat_FlexChartFromTable.mxml
on trouve ceci

Code:
private function loadDefaultXML():void
{
var req:URLRequest = new URLRequest(“defaultChartData.xml”);
var loader:URLLoader = new URLLoader(req);
loader.addEventListener(“complete”, xmlLoaded);
}

donc voici les modifications que j’ai apportés

Code:

layout=”absolute” width=”600″ height=”600″
creationComplete=”init()” applicationComplete=”stage.scaleMode = StageScaleMode.EXACT_FIT;”>


{
//Inject the JavaScript functions we need to interface with the RMA
//You can find the scripts below in the “acroJSFunctions” string object
ExternalInterface.call(“eval”, acroJSFunctions);
//set up callback for upadtes
//the format script in each of the fields uses callAS to send the field name and it’s value to the RMA
//the function for this callback then modifies the XML that drives the chart.
ExternalInterface.addCallback(“changeData”, changeData);
//set up callbacks for commenting
ExternalInterface.addCallback( “multimedia_getState”, getState );
ExternalInterface.addCallback(“multimedia_setState”, setState);
loadDefaultXML();
} private function loadDefaultXML():void
{
var req:URLRequest = new URLRequest(“defaultChartData.xml”);
var loader:URLLoader = new URLLoader(req);
loader.addEventListener(“complete”, xmlLoaded);
} private function xmlLoaded(event:Event):void
{
chartData = new XML(event.target.data);
loadDataFromAcroFields();
}
private function loadDataFromAcroFields():void
{
//get the values from the PDF
//
var c:int;
var r:int;
for (c=0;c<2;c++)
{
for (r=0;r<16;r++)
{     
var result:String = ExternalInterface.call(“getFieldValue”,r, c);
chartData.children()[r].children()[c] = int(result);
}
}
}  private function changeData(name:String, value:String):void
{
//this function gets called when the field value in the PDF file changes
//look in the format script for the field in the PDF.
//the field name is in the form “table.r.c” where r is the row number and c is the column.
//So the first field in the table would be called “table.0.0”
//By splitting the string into an array, I can modify the corresponding element in the XML object that drives the chart.
var fieldNameArray:Array = name.split(“.”);
var row:int = int(fieldNameArray[1]);
var column:int = int(fieldNameArray[2]);
var val:int = int(value);
chartData.children()[row].children()[column] = val
}  private function getState():String
{
//store the chart data XML
return chartData.toString();
} private function setState(stateData:String):Boolean
{
chartData = new XML(stateData);
var c:int;
var r:int;
for (c=0;c<2;c++)
{
for (r=0;r<16;r++)
{     
var fieldVal:String = chartData.children()[r].children()[c].toString();
var result:String = ExternalInterface.call(“setFieldValue”,r, c, fieldVal);
}
} return true;
}
]]>


{
fieldName=”table.”+row+”.”+column;
fieldValue = this.getField(fieldName).value;
return fieldValue;
} function setFieldValue(row, column, value)
{
fieldName=”table.”+row+”.”+column;
this.getField(fieldName).value = value;
} ]]>



  left=”10″ top=”10″ right=”10″ bottom=”10″>









   

donc comme vous pouvez le voir dans l’image plus haut, pleins de fichier sont crées et notament le flash  Acrobat_FlexChartFromTable.swf

voici le fichier, qui lorsqu’on l’ouvre affiche bien le graph que je souhaite:http://cjoint.com/?BKpmZL7Oupc
(je trouve bizzare que le fichier fasse que 84KB, car le swf du gars fait 447KB ??!?)

donc j’ai inséré ce swf  dans le pdf et puis dans ses propriétés =>source => j’ai ajouté le fichier defaultChartData.xml

et donc le message d’erreur suivant apparait: voici le form http://cjoint.com/?BKpmUzHRx7h

Error #2032: Stream Error. URL: file://PDFMedia032480/g/textLayout_2.0.0.232.swf

dois-je plutot m’orienter vers les forums de adobe flex?

merci en tout cas