private void ChartToPDF()
{
MemoryStream outStream = new MemoryStream();
chart.Save(outStream, new BmpBitmapEncoder());
PdfPage page = pdfDoc.Pages.Add();
PdfBitmap img = new PdfBitmap(outStream);
page.Graphics.DrawImage(img, 0, 0, 500, 250);
outStream.Close();
}
private void SavePDF(string pdfFile)
{
pdfDoc.Save(pdfFile);
System.Diagnostics.Process.Start(pdfFile);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
pdfDoc = new PdfDocument();
ChartToPDF();
SavePDF("chartpdf.pdf");
} |
<syncfusion:SfChart Background="White">
…
</syncfusion:SfChart>
|
<syncfusion:SfChart Width="300" Height="200">
…
</syncfusion:SfChart>
|
private void ChartToPDF()
{
…
page.Graphics.DrawImage(img, 0, 0, 300, 200);
}
|
<syncfusion:SfChart HorizontalAlignment="Left" VerticalAlignment="Top">
…
</syncfusion:SfChart>
|
private void ChartToPDF()
{
page.Graphics.DrawImage(img, (float)(-ChartMargin.Left * 2) - AdjustmentCoefficient, (float)(-ChartMargin.Top * 2) - AdjustmentCoefficient, 300, 200);
}
|
<Grid >
<Grid.DataContext>
<local:ViewModel></local:ViewModel>
</Grid.DataContext>
<Grid.RowDefinitions>
<RowDefinition Height="8*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Button Content="Save" Click="Button_Click" Height="30" Width="70"
Grid.Row="1"
Margin="5"/>
<chart:SfChart x:Name="chart" Background="White" Height="300" Width="600"
HorizontalAlignment="Left"
VerticalAlignment="Top">
..
</chart:SfChart>
</Grid> |