Here, we import the chart in the frame at two seconds into a Flash movie.
[C#]
Doc doc = new
Doc(); using(SwfImportOperation operation = new SwfImportOperation())
{ operation.Doc = doc; operation.ContentAlign
= ContentAlign.Top; operation.ContentScaleMode =
ContentScaleMode.ShowAll; operation.ProcessingObject
+= delegate(object sender, ProcessingObjectEventArgs e)
{ if(e.Info.SourceType==ProcessingSourceType.MultiFrameImage
&& e.Info.FrameNumber.HasValue) e.Info.FrameNumber
= 1+(long)(e.Info.FrameRate.Value*2); };
const
int chartWidth = 400; const int chartHeight =
300; SwfParameters parameters = new
SwfParameters(); parameters.StageWidth =
chartWidth*20; parameters.StageHeight =
chartHeight*20;
Dictionary<string, object>
flashVars = new Dictionary<string,
object>(); flashVars.Add("chartWidth",
chartWidth); flashVars.Add("chartHeight",
chartHeight); flashVars.Add("dataXML",
"<chart caption='Weekly Sales Summary'
xAxisName='Week'" +" yAxisName='Amount'
numberPrefix='$'>" +"<set
label='Week 1' value='14400' />" +"<set
label='Week 2' value='19600' />" +"<set
label='Week 3' value='24000' />" +"<set
label='Week 4' value='15700'
/>" +"</chart>"); parameters.FlashVars
= flashVars; operation.Parameters =
parameters; operation.Import(Server.MapPath("Column3D.swf"));
} doc.Save(Server.MapPath("chart.pdf")); doc.Clear(); [Visual Basic]
Dim theDoc As Doc = New
Doc() Using theOperation As New
SwfImportOperation theOperation.Doc =
theDoc theOperation.ContentAlign =
ContentAlign.Top theOperation.ContentScaleMode =
ContentScaleMode.ShowAll AddHandler theOperation.ProcessingObject,
AddressOf Processing
Const theChartWidth As
Integer = 400 Const theChartHeight As Integer =
300 Dim theParameters As SwfParameters = New
SwfParameters() theParameters.StageWidth =
theChartWidth * 20 theParameters.StageHeight =
theChartHeight * 20
Dim theFlashVars As Dictionary(Of
String, Object) = New Dictionary(Of String,
Object)() theFlashVars.Add("chartWidth",
theChartWidth) theFlashVars.Add("chartHeight",
theChartHeight) theFlashVars.Add("dataXML", _
"<chart caption='Weekly Sales Summary'
xAxisName='Week'" _ &
" yAxisName='Amount' numberPrefix='$'>" _ & "<set
label='Week 1' value='14400' />" _ & "<set
label='Week 2' value='19600' />" _ & "<set
label='Week 3' value='24000' />" _ & "<set
label='Week 4' value='15700' />" _ &
"</chart>") theParameters.FlashVars
= theFlashVars theOperation.Parameters =
theParameters theOperation.Import(Server.MapPath("Column3D.swf")) End
Using theDoc.Save(Server.MapPath("chart.pdf")) theDoc.Clear()
Private
Shared Sub Processing(sender As Object, e As
ProcessingObjectEventArgs) If
e.Info.SourceType = ProcessingSourceType.MultiFrameImage
_ AndAlso
e.Info.FrameNumber.HasValue Then e.Info.FrameNumber
= 1 + CLng(e.Info.FrameRate.Value * 2) End If End
Sub
|
|
|