title: Convert Wpf Control into pdf
body: <p>I would like to convert my WPF control into pdf, do anyone helps me with some example?</p>
  
  <p>I have a WPF chart and a listview:
  <img src="https://i.stack.imgur.com/6QSfG.png" alt="enter image description here"></p>
  
  <p>above image is the output of my WPF, and I want to convert this page into pdf?</p>
  
  <p>anyone can help me with it?below is my code which can create a pdf but inside the pdf have no content, please help.</p>
  
  <pre><code>public void SaveCurrentViewToXPS()
          {
  
              var dialog = new SaveFileDialog();
  
              dialog.AddExtension = true;
              dialog.DefaultExt = "pdf";
              dialog.Filter = "PDF Document (*.pdf)|*.pdf";
  
              if (dialog.ShowDialog() == false)
                  return;
  
              FixedDocument fixedDoc = new FixedDocument();
              PageContent pageContent = new PageContent();
              FixedPage fixedPage = new FixedPage();
  
              PrintDialog printDlg = new PrintDialog();
              Size pageSize = new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight - 100);
              lw.Width = 2100;
              lw.Height = 2970;
  
              //Create first page of document
              fixedPage.Children.Add(lw);
              //fixedPage.Children.Add(ColumnChart2);
              ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
              fixedDoc.Pages.Add(pageContent);
  
              // write to PDF file
              string tempFilename = "temp.xps";
              File.Delete(tempFilename);
              XpsDocument xpsDoc = new XpsDocument(tempFilename, FileAccess.Write);
              XpsDocumentWriter xWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);
              xWriter.Write(fixedDoc.DocumentPaginator);
              xpsDoc.Close();
  
              PdfSharp.Xps.XpsConverter.Convert(tempFilename);
          }
  </code></pre>
  
  <p>Thanks</p>