WPF文档查看器导出为PDF

时间:2012-09-06 05:36:07

标签: wpf visual-studio-2010 c#-4.0 wpf-controls documentviewer

您好我正在使用WPF文档查看器来查看文档 有没有办法将文档保存为PDF?

<DocumentViewer Name="documentViewer" />

我正在使用WPFReports生成报告。

2 个答案:

答案 0 :(得分:0)

据我所知,不,你不能。但是,您可以将DocumentViewer渲染为XPS,然后将其渲染为PDF。

答案 1 :(得分:0)

<Label>
  <Hyperlink Click="lnkSelectDocument_Click">
    <Label Content="{Binding ShortFielName}">
    </Label>
  </Hyperlink> 
</Label>


private void lnkSelectDocument_Click(object sender, RoutedEventArgs e) {
  try {
    System.Diagnostics.Process process = new System.Diagnostics.Process();
    string path = "d:\\test.doc";
    Uri pdf = new Uri(path, UriKind.RelativeOrAbsolute);
    process.StartInfo.FileName = pdf.LocalPath;
    process.Start();
    process.WaitForExit();
  } catch (Exception error) {
    MessageBox.Show("Could not open the file.", "Error", MessageBoxButton.OK,
      MessageBoxImage.Warning);
  }
}