相关疑难解决方法(0)

打印WPF FlowDocument

我正在WPF中构建一个演示应用程序,这对我来说是新的.我目前正在FlowDocument中显示文本,需要打印它.

我正在使用的代码如下所示:

        PrintDialog pd = new PrintDialog();
        fd.PageHeight = pd.PrintableAreaHeight;
        fd.PageWidth = pd.PrintableAreaWidth;
        fd.PagePadding = new Thickness(50);
        fd.ColumnGap = 0;
        fd.ColumnWidth = pd.PrintableAreaWidth;

        IDocumentPaginatorSource dps = fd;
        pd.PrintDocument(dps.DocumentPaginator, "flow doc");
Run Code Online (Sandbox Code Playgroud)

fd是我的FlowDocument,现在我使用默认打印机而不是允许用户指定打印选项.它工作正常,除了在文档打印后,屏幕上显示的FlowDocument已更改为使用我指定的设置进行打印.

我可以通过在打印后手动重置所有内容来解决这个问题,但这是最好的方法吗?我打印之前是否应该复制FlowDocument?或者我应该考虑另一种方法吗?

printing wpf

34
推荐指数
2
解决办法
6万
查看次数

如何使用DocumentPaginator打印时打印预览?

我正在使用我从DocumentPaginator派生的类(见下文)来打印来自WPF应用程序的简单(仅文本)报告.我已经准备好了所有内容都能正确打印,但如何在打印之前进行打印预览?我有一种感觉,我需要使用DocumentViewer,但我无法弄清楚如何.

这是我的Paginator类:

public class RowPaginator : DocumentPaginator
{
    private int rows;
    private Size pageSize;
    private int rowsPerPage;

    public RowPaginator(int rows)
    {
        this.rows = rows;
    }

    public override DocumentPage GetPage(int pageNumber)
    {
        int currentRow = rowsPerPage * pageNumber;
        int rowsToPrint = Math.Min(rowsPerPage, rows - (rowsPerPage * pageNumber - 1));
        var page = new PageElementRenderer(pageNumber + 1, PageCount, currentRow, rowsToPrint)
                       {
                           Width = PageSize.Width,
                           Height = PageSize.Height
                       };
        page.Measure(PageSize);
        page.Arrange(new Rect(new Point(0, 0), PageSize));
        return new DocumentPage(page);
    }

    public override …
Run Code Online (Sandbox Code Playgroud)

.net c# printing wpf

14
推荐指数
2
解决办法
3万
查看次数

WPF:如何在DocumentViewer中删除搜索框?

我的XAML代码是这样的:

<Window
    xmlns                 ='http://schemas.microsoft.com/netfx/2007/xaml/presentation'
    xmlns:x               ='http://schemas.microsoft.com/winfx/2006/xaml'
    Title                 ='Print Preview - More stuff here'
    Height                ='200'
    Width                 ='300'
    WindowStartupLocation ='CenterOwner'>
    <DocumentViewer Name='dv1' ... />
</Window>
Run Code Online (Sandbox Code Playgroud)

如何在XAML或C#中删除搜索框?

wpf documentviewer

12
推荐指数
3
解决办法
1万
查看次数

标签 统计

wpf ×3

printing ×2

.net ×1

c# ×1

documentviewer ×1