How to ignore empty pages while printing the WPF Diagram (SfDiagram)?
The GetPrintInfo virtual method of PrintingService helps to ignore empty pages while printing of WPF Diagram (SfDiagram). This method will be invoked with the PrintInfo class as an argument when the page is preparing for previewing or printing.
Key properties of PrintInfo:
PrintAction: Defines whether preview and print happen in the diagram.
TotalPageCount: Defines the total pages to be previewed or printed in the diagram.
CurrentPage: Defines which page is currently in preview or print.
Elements: Defines the objects to be previewed or printed in the diagram.
For example, the Elements property of PrintInfo helps to ignore the empty pages in previewing or printing.
Refer to the following code example:
C#
// Derived class from PrintingService public class CustomPrint : PrintingService { // Override GetPrintInfo method protected override void GetPrintInfo(PrintInfo args) { // Check whether the current page is empty or not. if (args.Elements.Count() == 0) { args.Cancel = true; } else { base.GetPrintInfo(args); } } }
Conclusion
I hope you enjoyed learning about how to ignore empty pages while printing the WPF Diagram (SfDiagram).
You can refer to our WPF Diagram feature tour page to learn about its other groundbreaking feature representations. You can also explore our WPF Diagram documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarification, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!