-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
feature request π¬A request for new changes to improve functionalityA request for new changes to improve functionalityhelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitieshelpers βquestion βIssues or PR require more informationIssues or PR require more information
Description
I'm using PrintHelper extension of windows-community-toolkit and printing some data. The problem is when data is large it overlaps the page and i can't find a way to dynamically add a new page and shift data to next page. Is there a way ?
public PrintHelper PrintHelper;
public void StartPrint(Panel container, List<CompanyDetail> PrintSampleItems)
{
try
{
PrintHelper = new PrintHelper(container);
PrintHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;
PrintHelper.OnPrintFailed += PrintHelper_OnPrintFailed;
PrintHelper.OnPreviewPagesCreated += PrintHelperOnOnPreviewPagesCreated;
var pageNumber = 0;
var data = PrintSampleItems;
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() {Height = GridLength.Auto});
grid.RowDefinitions.Add(new RowDefinition() {Height = new GridLength(1, GridUnitType.Star)});
grid.RowDefinitions.Add(new RowDefinition() {Height = GridLength.Auto});
// Static header
var header = new TextBlock
{
Text = "Departments Print",
Margin = new Thickness(0, 0, 0, 20),
HorizontalAlignment = HorizontalAlignment.Center,
FontSize = 18,
FontWeight = FontWeights.Bold
};
Grid.SetRow(header, 0);
grid.Children.Add(header);
var dataGrid = new CompanyDetailReportTemplateControl
{
HorizontalAlignment = HorizontalAlignment.Center
};
dataGrid.SetValues(PrintSampleItems);
Grid.SetRow(dataGrid, 1);
grid.Children.Add(dataGrid);
// Footer with page number
pageNumber++;
var footer = new TextBlock
{
Text = $"Page [ {pageNumber} ]", Margin = new Thickness(0, 20, 0, 0),
HorizontalAlignment = HorizontalAlignment.Right
};
Grid.SetRow(footer, 2);
grid.Children.Add(footer);
PrintHelper.AddFrameworkElementToPrint(grid);
}
catch
{
}
}
The result looks like this. As can be seen if data is large it is not printed because next page is not added automatically. I can do that be manually looping data and defining exactly how many rows to print on one page and how many on next but that's not what i want cuz if some cell data is large then my logic won't work.
Metadata
Metadata
Assignees
Labels
feature request π¬A request for new changes to improve functionalityA request for new changes to improve functionalityhelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitieshelpers βquestion βIssues or PR require more informationIssues or PR require more information
