在多个页面上打印流程文档滚动查看器 [英] Print flowdocument scroll viewer on multiple pages

查看:82
本文介绍了在多个页面上打印流程文档滚动查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打印我的 FlowDocument(它被包装到 FlowDocumentScrollViewer 中),因为我有很多文本/文本框/组合框并且页面高度可能会变高!

I'm trying to print my FlowDocument (which is wrapped into a FlowDocumentScrollViewer) because I have a lot of texts/Textbox/combobox and the page height can become high !

我正在使用这个:

PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
{
    Scrollvvv.Document.ColumnWidth = printDialog.PrintableAreaWidth;
    Scrollvvv.Document.ColumnGap = 0;
    printDialog.PrintDocument(((IDocumentPaginatorSource)Scrollvvv.Document).DocumentPaginator, ServicesLangue.RM.GetString("TITRE_MODIFIER_SALON_EXPOSANT"));
}

我的 xaml 看起来像:

My xaml looks like :

<FlowDocumentScrollViewer Name="Scrollvvv" VerticalScrollBarVisibility="Auto">
    <FlowDocument Name="flowDoc" PagePadding="10">
        <Section>
            <BlockUIContainer>
                <Grid Name="grid_principale">
                    <!-- Lot of stuffs here -->
                </Grid>
            </BlockUIContainer>
        </Section>
    </FlowDocument>
</FlowDocumentScrollViewer>

事情是:它将我的所有数据打印在 1 页中,宽度还可以(我可能会添加一些边距,但没关系)但它压缩了我的所有控件以适应一页的高度.

The thing is : It prints all my data in 1 page, the width is ok (i might add some margin but that's ok) but it compresses all my controls to fit in one page in height.

如何解决这个问题?我只想禁用此自动高度并保持原始大小.

How to fix this ? I'd just want to disable this auto Height and keep the original size.

推荐答案

问题是您将所有内容都放在单个 BlockUIContainer 中.DocumentPaginator 无法对 BlockUIContainer 进行分页,即将其拆分为多个页面.如果您的 UI 是静态的,您可以使用多个 BlockUIContainers 来包装您的 UI.即

The problem is that you are putting everything inside single BlockUIContainer. DocumentPaginator has trouble in paginating the BlockUIContainer i.e. splitting it into multiple pages. If your UI is static you can use multiple BlockUIContainers to wrap your UI. i.e.

    <BlockUIContainer>
      <Grid Name="grid_principale">
       <!-- Grid content here -->
      </Grid>
    </BlockUIContainer>
    <BlockUIContainer>
      <Grid Name="grid_principale2">
       <!-- Grid content here -->
      </Grid>
    </BlockUIContainer>

这将生成多个页面.此外,您还必须在打印前设置 FlowDocument.PageHeight.

This will generate multiple pages. Also you will have to set your FlowDocument.PageHeight before printing.

这篇关于在多个页面上打印流程文档滚动查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆