简体   繁体   中英

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. Only Word or XPS, but it's overgear solutions.

Is there any way to print simple multiline text throw 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 ?

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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