Dear Aspose,
I am using Aspose.Cells for .NET to implement my project
as I am using the print dialog from microsoft for users to choose their desire print settings.
I would like to pass the defined/modified page setup from the worksheet/workbook into the print dialog, then pass the printerSettings back into WorkbookRender to print the document.
In short
Aspose.Cells.PageSetup -> System.Drawing.Printing.PrinterSettings.
Is there a quick way of cloning the settings between the two class?
or should I map the settings manually as below?
Many Thanks,
---------------------- Code ----------------------
private PrinterSettings SetPrinterSettings(PrinterSettings printerSettings, PageSetup pageSetup)
{
// Set LandScape
if (pageSetup.Orientation == PageOrientationType.Landscape)
printerSettings.DefaultPageSettings.Landscape = true;
// Set colour
printerSettings.DefaultPageSettings.Color = pageSetup.BlackAndWhite;
// Set Margin
printerSettings.DefaultPageSettings.Margins.Bottom = (int)pageSetup.BottomMarginInch * 100;
printerSettings.DefaultPageSettings.Margins.Top = (int)pageSetup.TopMarginInch * 100;
printerSettings.DefaultPageSettings.Margins.Left = (int)pageSetup.LeftMarginInch * 100;
printerSettings.DefaultPageSettings.Margins.Right = (int)pageSetup.RightMarginInch * 100;
// Set PaperSize
string paperName = Enum.GetName(typeof(PaperKind), (int)pageSetup.PaperSize);
printerSettings.DefaultPageSettings.PaperSize = this.GetPaperSizeWithName(paperName);
return printerSettings;
}
private System.Drawing.Printing.PaperSize GetPaperSizeWithName(string paperName)
{
// Set default paper size
PrinterSettings settings = new PrinterSettings();
foreach (System.Drawing.Printing.PaperSize pSize in settings.PaperSizes)
{
if (pSize.PaperName == paperName)
return pSize;
}
return settings.DefaultPageSettings.PaperSize;
}
---------------------- Code ----------------------