Hallo zusammen,
ich versuche gerade ein Chart in einem PDF zu erzeugen. Dazu nutze Ich PDFSharp.dll und PDFSharp.Charting.dll. Es kommt zu folgendem Abbruch (Bild 1).
Hätte jemand eine Idee wo mein Problem liegt?
Vielen Dank vorab
ich versuche gerade ein Chart in einem PDF zu erzeugen. Dazu nutze Ich PDFSharp.dll und PDFSharp.Charting.dll. Es kommt zu folgendem Abbruch (Bild 1).
Hätte jemand eine Idee wo mein Problem liegt?
Vielen Dank vorab
VB.NET-Quellcode
- Imports PdfSharp.Charting
- Imports PdfSharp.Drawing
- Imports PdfSharp.Pdf
- Public Class Form1
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- ' Create a new PDF document
- Dim document As PdfDocument = New PdfDocument
- document.Info.Title = "Created with PDFsharp"
- ' Create an empty page
- Dim page As PdfPage = document.AddPage
- ' Get an XGraphics object for drawing
- Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
- #Region "Chart"
- Dim chart_1 As Chart = New Chart(ChartType.Line)
- Dim Series As Series = chart_1.SeriesCollection.AddSeries
- Series.Name = "series 1"
- Series.Add({1, 5, -3, 20, 11})
- Dim Series1 As Series = chart_1.SeriesCollection.AddSeries()
- Series.Name = "Series 2"
- Series.Add({22, 4, 12, 8, 12})
- chart_1.XAxis.MajorTickMark = TickMarkType.Outside
- chart_1.XAxis.Title.Caption = "X-Axis"
- chart_1.YAxis.MajorTickMark = TickMarkType.Outside
- chart_1.YAxis.Title.Caption = "Y-Axis"
- chart_1.YAxis.HasMajorGridlines = True
- chart_1.PlotArea.LineFormat.Color = XColors.DarkGray
- chart_1.PlotArea.LineFormat.Width = 1
- chart_1.PlotArea.LineFormat.Visible = True
- chart_1.Legend.Docking = DockingType.Bottom
- chart_1.Legend.LineFormat.Visible = True
- Dim XSeries As XSeries = chart_1.XValues.AddXSeries()
- XSeries.Add("A", "B", "C", "D", "E", "F")
- #End Region
- Dim chartFrame As New ChartFrame
- chartFrame.Location = New XPoint(100, 100)
- chartFrame.Size = New XSize(500, 500)
- chartFrame.Add(chart_1)
- 'XXXXXXXXXXXXX ABSTURZ XXXXXXXXXXXXX
- chartFrame.Draw(gfx) '
- ' Save the document...
- Dim filename As String = "TestChart.pdf"
- document.Save(filename)
- ' ...and start a viewer.
- Process.Start(filename)
- End Sub
- End Class