Skip to content

Commit

Permalink
batch printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Oaz committed May 3, 2020
1 parent 9498d01 commit 8333441
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions demo/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ public Model(Window window)
{
this.window = window;
window.Styles.Add(themes[0]);
if(Environment.GetCommandLineArgs().Contains("--pdf"))
{
var outputFilename = "batchAllPages.pdf";
Console.WriteLine($"Printing to {outputFilename}");
SaveAllPagesTo(outputFilename);
Environment.Exit(0);
}
}

private readonly Window window;
Expand All @@ -29,15 +36,14 @@ public void SaveCurrentPageAsPDF()
});
}

public void SaveAllPagesAsPDF()
public void SaveAllPagesAsPDF() => Dialog.Save("Save all pages as PDF", "allPages.pdf", SaveAllPagesTo);

private void SaveAllPagesTo(string filename)
{
Dialog.Save("Save all pages as PDF", "allPages.pdf", filename =>
{
var size = CurrentPage(window).Bounds;
var allPages = PagesHost(window).Items.Cast<TabItem>().Select(ti => ti.Content as Control).ToList();
Print.OnPage(maximumPageSize, allPages);
Print.ToFile(filename, allPages);
});
var size = CurrentPage(window).Bounds;
var allPages = PagesHost(window).Items.Cast<TabItem>().Select(ti => ti.Content as Control).ToList();
Print.OnPage(maximumPageSize, allPages);
Print.ToFile(filename, allPages);
}

public void SaveFullWindowAsPDF()
Expand Down

0 comments on commit 8333441

Please sign in to comment.