PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jul 19, 2018 9:21 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Aug 08, 2014 6:18 am 

Joined: Fri Aug 08, 2014 6:02 am
Posts: 1
I wrote the code as below and I want output the chart1 in pdf file
I found that the lineseries in the chart1 is correctly printed into PDF file, but the color of the polyline missed.
It seems show the same color for all polylines of all lineseries.
I pastes my testing code below and hope you kindly enough to give an answer to me. Thanks a lot.

In xaml file :
<Window x:Class="DrawPicture.MainWindow"
Title="MainWindow" Height="22cm" Width="30.7cm">
<DVC:Chart Name="chart1" Title="Pic1" Height="200" Width="300">
<DVC:LinearAxis Orientation="Y" Location="Left" >
<Button Click="Button_Click_1">HELLO</Button>

In xaml.cs
public partial class MainWindow : Window
public MainWindow()
chart1.DataContext = new MyClass();
LineSeries series1 = new LineSeries();
series1.ItemsSource = (chart1.DataContext as MyClass).source1;
series1.IndependentValueBinding = new Binding("Key");
series1.DependentValueBinding = new Binding("Value");

private void Button_Click_1(object sender, RoutedEventArgs e)
PdfXpsHelper.SaveViewContentToPdf(@"C:\1.pdf", chart1);

public class MyClass
public MyClass()
var temp = new Dictionary<string, int>();
for (int i = 1; i < 10; i++)
temp.Add(Convert.ToString(0900 + i), i);
source1 = temp;

public Dictionary<string, int> source1

public class PdfXpsHelper
public static void SaveViewContentToPdf(string path, Visual viewbox)
MemoryStream lMemoryStream = new MemoryStream();
Package package = Package.Open(lMemoryStream, FileMode.Create);
XpsDocument doc = new XpsDocument(package);
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);
VisualsToXpsDocument vToXpsD = (VisualsToXpsDocument)writer.CreateVisualsCollator();



var pdfXpsDoc = PdfSharp.Xps.XpsModel.XpsDocument.Open(lMemoryStream);
PdfSharp.Xps.XpsConverter.Convert(pdfXpsDoc, path, 0);

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group