Class ImageOrPrintOptions
Namespace: Aspose.Cells.Rendering
Assembly: Aspose.Cells.dll (25.2.0)
Allows to specify options when rendering worksheet to images, printing worksheet or rendering chart to image.
public class ImageOrPrintOptions
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
csharp
[C#]
//Set Image Or Print Options
ImageOrPrintOptions options = new ImageOrPrintOptions();
//Set output image format
options.ImageType = ImageType.Png;
//Set Horizontal resolution
options.HorizontalResolution = 300;
//Set Vertical Resolution
options.VerticalResolution = 300;
//Instantiate Workbook
Workbook book = new Workbook("test.xls");
//Save chart as Image using ImageOrPrint Options
book.Worksheets[0].Charts[0].ToImage("chart.png", options);
'Set Image Or Print Options
Dim options As New ImageOrPrintOptions()
'Set output image format
options.ImageType = ImageType.Png
'Set Horizontal resolution
options.HorizontalResolution = 300
'Set Vertical Resolution
options.VerticalResolution = 300
'Instantiate Workbook
Dim book As New Workbook("test.xls")
'Save chart as Image using ImageOrPrint Options
book.Worksheets(0).Charts(0).ToImage("chart.png", options)
Constructors
ImageOrPrintOptions()
public ImageOrPrintOptions()
Properties
AllColumnsInOnePagePerSheet
If AllColumnsInOnePagePerSheet is true , all column content of one sheet will output to only one page in result. The width of paper size of pagesetup will be invalid, and the other settings of pagesetup will still take effect.
public bool AllColumnsInOnePagePerSheet { get; set; }
Property Value
CheckWorkbookDefaultFont
When characters in the Excel are Unicode and not be set with correct font in cell style, They may appear as block in pdf,image. Set this to true to try to use workbook’s default font to show these characters first.
public bool CheckWorkbookDefaultFont { get; set; }
Property Value
Remarks
Default is true.
CustomPrintPageEventHandler
Client can special output to printer when print each page using this EventHandler
public PrintPageEventHandler CustomPrintPageEventHandler { get; set; }
Property Value
CustomQueryPageSettingsEventHandler
Client can control page setting of printer when print each page using this EventHandler
public QueryPageSettingsEventHandler CustomQueryPageSettingsEventHandler { get; set; }
Property Value
DefaultEditLanguage
Gets or sets default edit language.
public DefaultEditLanguage DefaultEditLanguage { get; set; }
Property Value
Remarks
It may display/render different layouts for text paragraph when different edit languages is set. Default is Aspose.Cells.DefaultEditLanguage.Auto.
DefaultFont
When characters in the Excel are Unicode and not be set with correct font in cell style, They may appear as block in pdf,image. Set the DefaultFont such as MingLiu or MS Gothic to show these characters. If this property is not set, Aspose.Cells will use system default font to show these unicode characters.
public string DefaultFont { get; set; }
Property Value
DrawObjectEventHandler
Implements this interface to get DrawObject and Bound when rendering.
public DrawObjectEventHandler DrawObjectEventHandler { get; set; }
Property Value
EmbededImageNameInSvg
Indicate the filename of embedded image in svg. This should be full path with directory like “c:\xpsEmbedded”
public string EmbededImageNameInSvg { get; set; }
Property Value
EmfRenderSetting
Setting for rendering Emf metafile.
public EmfRenderSetting EmfRenderSetting { get; set; }
Property Value
Remarks
EMF metafiles identified as “EMF+ Dual” can contain both EMF+ records and EMF records. Either type of record can be used to render the image, only EMF+ records, or only EMF records. When Aspose.Cells.EmfRenderSetting.EmfPlusPrefer is set, then EMF+ records will be parsed while rendering to image, otherwise only EMF records will be parsed. Default value is Aspose.Cells.EmfRenderSetting.EmfOnly. For the frameworks that depend on .Net System.Drawing.Common, this setting is ignored.
EmfType
Gets or sets an EmfType that specifies the format of the Metafile..
public EmfType EmfType { get; set; }
Property Value
GridlineType
Gets or sets gridline type.
public GridlineType GridlineType { get; set; }
Property Value
Remarks
Default is Dotted type.
HorizontalResolution
Gets or sets the horizontal resolution for generated images, in dots per inch.
public int HorizontalResolution { get; set; }
Property Value
Examples
The following code sets resolution to 192, the width and height of the generated image is twice of the one with resolution left as the default value 96.
csharp
Workbook wb = new Workbook("Book1.xlsx");
ImageOrPrintOptions opts = new ImageOrPrintOptions();
//Set output image type: png.
opts.ImageType = ImageType.Png;
//Set resolution to 192.
opts.HorizontalResolution = 192;
opts.VerticalResolution = 192;
//Render worksheet page to image.
SheetRender sr = new SheetRender(wb.Worksheets[0], opts);
sr.ToImage(0, "Sheet_Page1.png");
Remarks
The default value is 96.
Setting Aspose.Cells.Rendering.ImageOrPrintOptions.HorizontalResolution and Aspose.Cells.Rendering.ImageOrPrintOptions.VerticalResolution effects the width and height of the output image in pixels.
ImageType
Gets or sets the format of the generated images. default value: PNG.
public ImageType ImageType { get; set; }
Property Value
IsFontSubstitutionCharGranularity
Indicates whether to only substitute the font of character when the cell font is not compatibility for it.
public bool IsFontSubstitutionCharGranularity { get; set; }
Property Value
Remarks
Default is false. We will try default font of Workbook and PdfSaveOption/system for cell font first.
IsOptimized
Indicates whether to optimize the output elements.
public bool IsOptimized { get; set; }
Property Value
Remarks
Default value is false. Currently when this property is set to true, the following optimizations will be done:
- optimize the border lines.
- optimize the file size while rendering to Svg image.
OnePagePerSheet
If OnePagePerSheet is true , all content of one sheet will output to only one page in result. The paper size of pagesetup will be invalid, and the other settings of pagesetup will still take effect.
public bool OnePagePerSheet { get; set; }
Property Value
OnlyArea
If this property is true , one Area will be output, and no scale will take effect.
public bool OnlyArea { get; set; }
Property Value
OutputBlankPageWhenNothingToPrint
Indicates whether to output a blank page when there is nothing to print.
public bool OutputBlankPageWhenNothingToPrint { get; set; }
Property Value
Remarks
Default is false.
PageCount
Gets or sets the number of pages to save.
public int PageCount { get; set; }
Property Value
Remarks
Default is System.Int32.MaxValue which means all pages will be rendered.
PageIndex
Gets or sets the 0-based index of the first page to save.
public int PageIndex { get; set; }
Property Value
Remarks
Default is 0.
PageSavingCallback
Control/Indicate progress of page saving process.
public IPageSavingCallback PageSavingCallback { get; set; }
Property Value
PixelFormat
Gets or sets the pixel format for the generated images.
public PixelFormat PixelFormat { get; set; }
Property Value
Remarks
The default value is PixelFormat.Format32bppArgb.
PrintWithStatusDialog
If PrintWithStatusDialog = true , there will be a dialog that shows current print status. else no such dialog will show.
public bool PrintWithStatusDialog { get; set; }
Property Value
PrintingPage
Indicates which pages will not be printed.
public PrintingPageType PrintingPage { get; set; }
Property Value
Quality
Gets or sets a value determining the quality of the generated images
to apply only when saving pages to the Jpeg
format. The default value is 100
public int Quality { get; set; }
Property Value
Remarks
Has effect only when saving to JPEG. The value must be between 0 and 100. The default value is 100.
SVGFitToViewPort
if this property is true, the generated svg will fit to view port.
public bool SVGFitToViewPort { get; set; }
Property Value
SheetSet
Gets or sets the sheets to render. Default is all visible sheets in the workbook: Aspose.Cells.Rendering.SheetSet.Visible.
public SheetSet SheetSet { get; set; }
Property Value
Remarks
The set is ignored when it is used in Aspose.Cells.Rendering.SheetRender
SmoothingMode
Specifies whether smoothing (antialiasing) is applied to lines and curves and the edges of filled areas. The default value is SmoothingMode.None
public SmoothingMode SmoothingMode { get; set; }
Property Value
SvgCssPrefix
Gets and sets the prefix of the css name in svg,the default value is empty string.
public string SvgCssPrefix { get; set; }
Property Value
TextCrossType
Gets or sets displaying text type when the text width is larger than cell width.
public TextCrossType TextCrossType { get; set; }
Property Value
TextRenderingHint
Specifies the quality of text rendering. The default value is TextRenderingHint.SystemDefault
public TextRenderingHint TextRenderingHint { get; set; }
Property Value
TiffBinarizationMethod
Gets or sets method used while converting images to 1 bpp format when Aspose.Cells.Rendering.ImageOrPrintOptions.ImageType is Tiff and Aspose.Cells.Rendering.ImageOrPrintOptions.TiffCompression is equal to Ccitt3 or Ccitt4.
public ImageBinarizationMethod TiffBinarizationMethod { get; set; }
Property Value
Remarks
The default value is FloydSteinbergDithering.
TiffColorDepth
Gets or sets bit depth to apply only when saving pages to the Tiff
format.
public ColorDepth TiffColorDepth { get; set; }
Property Value
Remarks
Has effect only when saving to TIFF. If TiffCompression is set to CCITT3, CCITT4, this will not take effect, the bit depth of the generated tiff image will be always 1.
TiffCompression
Gets or sets the type of compression to apply only when saving pages to the Tiff
format.
public TiffCompression TiffCompression { get; set; }
Property Value
Remarks
Has effect only when saving to TIFF. The default value is Lzw.
Transparent
Indicates if the background of generated image should be transparent.
public bool Transparent { get; set; }
Property Value
Remarks
The default value is false. That means the background of the generated images is white.
VerticalResolution
Gets or sets the vertical resolution for generated images, in dots per inch.
public int VerticalResolution { get; set; }
Property Value
Examples
The following code sets resolution to 192, the width and height of the generated image is twice of the one with resolution left as the default value 96.
csharp
Workbook wb = new Workbook("Book1.xlsx");
ImageOrPrintOptions opts = new ImageOrPrintOptions();
//Set output image type: png.
opts.ImageType = ImageType.Png;
//Set resolution to 192.
opts.HorizontalResolution = 192;
opts.VerticalResolution = 192;
//Render Chart to image.
wb.Worksheets[0].Charts[0].ToImage("Chart.png", opts);
Remarks
The default value is 96.
Setting Aspose.Cells.Rendering.ImageOrPrintOptions.HorizontalResolution and Aspose.Cells.Rendering.ImageOrPrintOptions.VerticalResolution effects the width and height of the output image in pixels.
WarningCallback
Gets or sets warning callback.
public IWarningCallback WarningCallback { get; set; }
Property Value
Methods
SetDesiredSize(int, int)
Sets desired width and height of image.
[Obsolete("Use SetDesiredSize(int, int, bool) by setting param keepAspectRatio to false instead.")]
public void SetDesiredSize(int desiredWidth, int desiredHeight)
Parameters
desiredWidth
int
desired width in pixels
desiredHeight
int
desired height in pixels
Remarks
NOTE: This member is now obsolete. Instead, please use Aspose.Cells.Rendering.ImageOrPrintOptions.SetDesiredSize(System.Int32,System.Int32,System.Boolean) by setting param keepAspectRatio to false. This property will be removed 12 months later since May 2023. Aspose apologizes for any inconvenience you may have experienced.
SetDesiredSize(int, int, bool)
Sets desired width and height of image.
public void SetDesiredSize(int desiredWidth, int desiredHeight, bool keepAspectRatio)
Parameters
desiredWidth
int
desired width in pixels
desiredHeight
int
desired height in pixels
keepAspectRatio
bool
whether to keep aspect ratio of origin image
Remarks
The width and height of the output image in pixels will be only based on the set desired width and height.
The Aspose.Cells.Rendering.ImageOrPrintOptions.HorizontalResolution and Aspose.Cells.Rendering.ImageOrPrintOptions.VerticalResolution will not effect the width and height of the output image in this case.