ImageOrPrintOptions.CustomPrintPageEventHandler
ImageOrPrintOptions.CustomPrintPageEventHandler property
Client can special output to printer when print each page using this EventHandler
public PrintPageEventHandler CustomPrintPageEventHandler { get; set; }
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Rendering;
using System;
public class ImageOrPrintOptionsPropertyCustomPrintPageEventHandlerDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add some sample data
worksheet.Cells["A1"].Value = "Sample Data for Printing";
worksheet.Cells["A2"].Value = "This demonstrates printing options";
try
{
// Create ImageOrPrintOptions instance
ImageOrPrintOptions options = new ImageOrPrintOptions();
// Configure printing options
options.PrintWithStatusDialog = true;
options.HorizontalResolution = 300;
options.VerticalResolution = 300;
// Display current printing options
Console.WriteLine($"PrintWithStatusDialog: {options.PrintWithStatusDialog}");
Console.WriteLine($"HorizontalResolution: {options.HorizontalResolution}");
Console.WriteLine($"VerticalResolution: {options.VerticalResolution}");
// Create a SheetRender to demonstrate printing
SheetRender sheetRender = new SheetRender(worksheet, options);
// Render to image to demonstrate printing
sheetRender.ToImage(0, "output.png");
Console.WriteLine("Rendering completed successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
See Also
- class ImageOrPrintOptions
- namespace Aspose.Cells.Rendering
- assembly Aspose.Cells