Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142290 | Jan 25,2019 07:26 AM UTC | Mar 19,2019 05:29 AM UTC | WPF | 6 |
![]() |
Tags: SfChart |
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> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.