简体   繁体   中英

WPF RichTextBox font spacing inconsistency

I found the WPF RichTextBox that renders FlowDocument is not WYSIWYG.

Screenshot below shows the Editor (left) has reduced spacing compared to its rendered PDF output (right).

实时出价与PDF

The xaml for this document.

<ns0:FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:ns0="http://schemas.microsoft.com/xps/2005/06"
                  Background="#FFFFFFFF" ColumnWidth="816" PageWidth="816" PageHeight="1056"
                  AllowDrop="True" NumberSubstitution.CultureSource="User">
  <ns0:FlowDocument.Blocks>
    <ns0:Paragraph>
      <ns0:Paragraph.Inlines>
        <ns0:Run Text="72" FontFamily="Arial" FontSize="72" />
      </ns0:Paragraph.Inlines>
    </ns0:Paragraph>
    <ns0:Paragraph>
      <ns0:Paragraph.Inlines>
        <ns0:Run Text="48" FontFamily="Arial" FontSize="48" />
      </ns0:Paragraph.Inlines>
    </ns0:Paragraph>
    <ns0:Paragraph>
      <ns0:Paragraph.Inlines>
        <ns0:Run Text="20" FontFamily="Arial" FontSize="20" />
      </ns0:Paragraph.Inlines>
    </ns0:Paragraph>
    <ns0:Paragraph>
      <ns0:Paragraph.Inlines>
        <ns0:Run Text="12" FontFamily="Arial" FontSize="12" />
      </ns0:Paragraph.Inlines>
    </ns0:Paragraph>
    <ns0:Paragraph>
      <ns0:Paragraph.Inlines>
        <ns0:Run Text="08" FontFamily="Arial" FontSize="8" />
      </ns0:Paragraph.Inlines>
    </ns0:Paragraph>
  </ns0:FlowDocument.Blocks>
</ns0:FlowDocument>

Do you have a workaround to address this issue ?

If you want page fidelity then FlowDocument is the wrong tool.
A FlowDocuement is just that - Flow - it knows no page specification.
For page fidelity use FixedDocument .

On screen PDF next to a Microsoft Word will also not necessarily have the same spacing.
Those two images also don't a have the same text height.
Reader has a zoom.
Why would you even expect those two images to be the same?

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