使用 BlockUIContainer 进行流文档分页

发布于 2024-12-09 19:47:12 字数 1574 浏览 0 评论 0原文

有谁知道如何在 FlowDocument 中的多个页面上分解大型 BlockUIControl ?现在它被切断而不是分页。我正在使用自定义 DocumentPaginator

 DocumentPaginator dp = ((IDocumentPaginatorSource)doc).DocumentPaginator;
                    FittedDocumentPaginator fdp = new FittedDocumentPaginator(dp, 0.85, 0.85);
                    p.PrintDocument(fdp, "Baker Data");


public class FittedDocumentPaginator : DocumentPaginator
{
    public DocumentPaginator Base { get; private set; }
    public double xScale { get; private set; }
    public double yScale { get; private set; }
    private readonly ScaleTransform _sTransform;

    public FittedDocumentPaginator(DocumentPaginator baseDp, double xScale, double yScale)
    {
        if (baseDp == null)
            throw new ArgumentNullException("baseDp");

        Base = baseDp;
        this.xScale = xScale;
        this.yScale = yScale;
        _sTransform = new ScaleTransform(xScale, yScale);
    }

    public override DocumentPage GetPage(int pageNumber)
    {
        var page = Base.GetPage(pageNumber);
        ((ContainerVisual)page.Visual).Transform = _sTransform;

        return page;
    }

    public override bool IsPageCountValid
    {
        get { return Base.IsPageCountValid; }
    }

    public override int PageCount
    {
        get { return Base.PageCount; }
    }

    public override Size PageSize
    {
        get { return Base.PageSize; }
        set { Base.PageSize = value; }
    }

    public override IDocumentPaginatorSource Source
    {
        get { return Base.Source; }
    }
}

如有任何帮助,我们将不胜感激。

Does anyone know how to break a large BlockUIControl over several pages in a FlowDocument? Right now it is getting cut off rather than paginating it. I am using a custom DocumentPaginator

 DocumentPaginator dp = ((IDocumentPaginatorSource)doc).DocumentPaginator;
                    FittedDocumentPaginator fdp = new FittedDocumentPaginator(dp, 0.85, 0.85);
                    p.PrintDocument(fdp, "Baker Data");


public class FittedDocumentPaginator : DocumentPaginator
{
    public DocumentPaginator Base { get; private set; }
    public double xScale { get; private set; }
    public double yScale { get; private set; }
    private readonly ScaleTransform _sTransform;

    public FittedDocumentPaginator(DocumentPaginator baseDp, double xScale, double yScale)
    {
        if (baseDp == null)
            throw new ArgumentNullException("baseDp");

        Base = baseDp;
        this.xScale = xScale;
        this.yScale = yScale;
        _sTransform = new ScaleTransform(xScale, yScale);
    }

    public override DocumentPage GetPage(int pageNumber)
    {
        var page = Base.GetPage(pageNumber);
        ((ContainerVisual)page.Visual).Transform = _sTransform;

        return page;
    }

    public override bool IsPageCountValid
    {
        get { return Base.IsPageCountValid; }
    }

    public override int PageCount
    {
        get { return Base.PageCount; }
    }

    public override Size PageSize
    {
        get { return Base.PageSize; }
        set { Base.PageSize = value; }
    }

    public override IDocumentPaginatorSource Source
    {
        get { return Base.Source; }
    }
}

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望喜 2024-12-16 19:47:12

尝试使用 FlowDocumentReader 控件

Try using FlowDocumentReader control

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文