【问题标题】:wpf documentviewer and simple textwpf 文档查看器和简单文本
【发布时间】:2015-05-23 19:49:10
【问题描述】:

我需要在打印前为用户显示文本并允许打印。 我尝试使用 DocumentViewer,但找不到显示简单文本的示例。只有 Word 或 XPS,但它是过度的解决方案。

有没有办法打印简单的多行文本 throw DocumentViewer

var printText = @"Multiline text to view and print
Line1 Content
Line2 Content
";

和查看

<DocumentViewer>
    <FixedDocument></FixedDocument>
</DocumentViewer>     

如何做到这一点?

【问题讨论】:

标签: c# wpf text documentviewer


【解决方案1】:

FlowDocument?

<FlowDocumentReader xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <FlowDocument>
    <Paragraph>
      <Bold>Some bold text in the paragraph.</Bold>
      Some text that is not bold.
    </Paragraph>
    <List>
      <ListItem>
        <Paragraph>ListItem 1</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 2</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 3</Paragraph>
      </ListItem>
    </List>
  </FlowDocument>
</FlowDocumentReader>

【讨论】:

  • @Json76 然后你可以打勾表示这是一个答案
  • 一个问题 - 它没有在阅读器工具栏(其中缩放按钮和其他按钮)中显示打印按钮作为 DocumentViewer。尝试 set IsPrintEnabled = true 没有帮助。这不是什么大问题,但在布局中我需要为自定义按钮预留位置
猜你喜欢
  • 2011-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多