Skip to content

HiraokaHyperTools/PrintUtilOfWPF

Repository files navigation

PrintUtilOfWPF

Preview/Save XPS from your WPF Visual object

nuget

Sample.cs:

using PrintUtilOfWPF;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;

void testPrint() {
    var pages = new List<DocumentPage>();

    var a4Size = new Size(793, 1122);
    var a4Rect = new Rect(a4Size);

    // prepare your Page object.
    Page page = new Page();

    page.Content = new Label {
        Content = "test page",
        FontSize = 60,
        HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
        VerticalAlignment = System.Windows.VerticalAlignment.Center,
    };

    // These are required ones.
    page.Measure(a4Size);
    page.Arrange(a4Rect);
    page.UpdateLayout();

    pages.Add(new DocumentPage(page, a4Size, a4Rect, a4Rect));

    var printPages = new PrintPages(pages) {
        PageSize = a4Size
    };

    PrintUtil.Preview(printPages.JobTitle, printPages);
}

About

Preview/Save XPS from your WPF Visual object

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published