印flowdocument增加了边境表

0

的问题

我建立flowdocument从视图模型,然后它打印pdf。

<UserControl x:Class="WpfApplication5.View.TransferTemplate" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:p="clr-namespace:WpfApplication5.Properties" xmlns:viewmodels="clr-namespace:WpfApplication5.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:WarehouseActionViewModel}" mc:Ignorable="d"
  x:Name="templ">
  <FlowDocument FontFamily="Cambria" FontSize="14" Background="White" x:Name="doc" d:ColumnWidth="1024">

    <Paragraph>
      <Run>Date: </Run>
      <Run Text="{Binding Action.ActionDate, StringFormat=dd-MM-yyyy}" />
    </Paragraph>
    <Paragraph>
      <Run>Note: </Run>
      <Run Text="{Binding Action.Note}" />
    </Paragraph>
    <Paragraph>
      <Run>Sender: </Run>
      <Run Text="{Binding Action.WarehouseFrom}" />
    </Paragraph>
    <Paragraph>
      <Run>Receiver: </Run>
      <Run Text="{Binding Action.WarehouseTo}" />
    </Paragraph>

    <Table x:Name="border" CellSpacing="0" BorderThickness="0" Background="{StaticResource WhiteBg}" BorderBrush="{StaticResource WhiteBg}">
      <Table.Columns>
        <TableColumn Width="0.2*" />
        <TableColumn Width="0.7*" />
        <TableColumn Width="0.1*" />
      </Table.Columns>

      <TableRowGroup>
        <TableRow FontSize="16">
          <TableCell BorderThickness="0,1,0,1" BorderBrush="#CCCCCC" Padding="5">
            <Paragraph>
              <Run Text="{x:Static p:Resources.barcode}" d:Text="Code" />
            </Paragraph>
          </TableCell>
          <TableCell BorderThickness="0,1,0,1" BorderBrush="#CCCCCC" Padding="5">
            <Paragraph>
              <Run Text="{x:Static p:Resources.Name}" d:Text="Name" />
            </Paragraph>
          </TableCell>
          <TableCell BorderThickness="0,1,0,1" BorderBrush="#CCCCCC" Padding="5">
            <Paragraph>
              <Run Text="{x:Static p:Resources.quantity}" d:Text="Quantity" />
            </Paragraph>
          </TableCell>
        </TableRow>
        <TableRow/>
      </TableRowGroup>
    </Table>
  </FlowDocument>
</UserControl>



PrintDialog printDlg = new PrintDialog();
        FlowDocument f = new TransferTemplate(vm).doc;
        f.ColumnWidth = printDlg.PrintableAreaWidth;
        IDocumentPaginatorSource dps = f;
        if ((bool)printDlg.ShowDialog())
        {
            printDlg.PrintDocument(dps.DocumentPaginator, "flow doc");
        }

问题是,当我创建模板和打印它增加了黑边境的表 (边境厚度设定为0) [![进入图像描述这里][1]][1]

但是,当我创建文档,而不xaml模板,具有同样的代码,在c#它不会增加边境 (边境厚度不集)

var table1 = new Table
        {
            CellSpacing = 0,
            Background = Brushes.White
        };
        flowDoc.Blocks.Add(table1);
enter code here

[![进入图像描述这里][2]][2]

我怎样才能解决XAML模板,以禁止边界? [1]: https://i.stack.imgur.com/BlYhX.png [2]: https://i.stack.imgur.com/HoZnF.png

flowdocument pdf printing wpf
2021-11-22 09:40:31
1

最好的答案

1

只是删除 x:Name 从表和它的工作!

Tip:加入 Name 财产的任何Flowdocument框元增加了一个黑的边界的时候打印(我只是测试,打印PDF)。

2021-11-23 09:59:28

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................