简体   繁体   English

wpf documentviewer和简单文本

[英]wpf documentviewer and simple text

I need to dispay text for user before printing and allow to print it. 我需要在打印之前为用户支付文字并允许打印。 I try to use DocumentViewer, but can't find example to display simple Text. 我尝试使用DocumentViewer,但是找不到显示简单Text的示例。 Only Word or XPS, but it's overgear solutions. 仅Word或XPS,但它是多余的解决方案。

Is there any way to print simple multiline text throw DocumentViewer 有什么方法可以打印简单的多行文本抛出DocumentViewer

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

and View 和查看

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

How to make this work ? 如何使这项工作?

A FlowDocument ? 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM