Hello,
I am having problems with chart creation. When I try to insert chart generated by DynamicPDF into PDF document, following error occur in Draw method:
[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
I'm using a VB.NET CONSOLE PROJECT in visual studio 2012 and I added the reference to the dll framework 2.0.
I do some test and it's the chart that cause problem. The same code works in VB.NET WEB APPLICATION
Here is the code that I tried :
' Create a PDF Document
Dim MyDocument As New Document()
' Create a Page and add it to the MyDocument
Dim MyPage As New Page()
MyDocument.Pages.Add(MyPage)
' Create a MyChart
Dim MyChart As New Chart(0, 0, 400, 230)
' Create a plot area
Dim MyPlotArea As PlotArea = MyChart.PrimaryPlotArea
' Create header titles and add it to the MyChart
Dim MyTitle1 As New Title("Website Visitors")
Dim MyTitle2 As New Title("Year 2007")
MyChart.HeaderTitles.Add(MyTitle1)
MyChart.HeaderTitles.Add(MyTitle2)
' Create a indexed bar series and add values to it
Dim MyBarSeries1 As New IndexedBarSeries("Website A")
MyBarSeries1.Values.Add(New Single() {5, 7, 9, 6})
Dim MyBarSeries2 As New IndexedBarSeries("Website B")
MyBarSeries2.Values.Add(New Single() {4, 2, 5, 8})
Dim MyBarSeries3 As New IndexedBarSeries("Website C")
MyBarSeries3.Values.Add(New Single() {2, 4, 6, 9})
' Add indexed bar series to the plot area
MyPlotArea.Series.Add(MyBarSeries1)
MyPlotArea.Series.Add(MyBarSeries2)
MyPlotArea.Series.Add(MyBarSeries3)
' Create a title and add it to the xaxis
Dim MylTitle As New Title("Visitors (in millions)")
MyBarSeries1.XAxis.Titles.Add(MylTitle)
'Adding AxisLabels to the yAxis
MyBarSeries1.YAxis.Labels.Add(New IndexedYAxisLabel("Q1", 0))
MyBarSeries1.YAxis.Labels.Add(New IndexedYAxisLabel("Q2", 1))
MyBarSeries1.YAxis.Labels.Add(New IndexedYAxisLabel("Q3", 2))
MyBarSeries1.YAxis.Labels.Add(New IndexedYAxisLabel("Q4", 3))
' Add the MyChart to the MyPage
MyPage.Elements.Add(MyChart)
' Save the PDF
MyDocument.Draw("C:/MyDocument.pdf")