ExcelToPdfConverter Class
Represents the conversion of Excel document to a PDF document.
Inheritance
Implements
Namespace: Syncfusion.ExcelToPdfConverter
Assembly: Syncfusion.ExcelToPDFConverter.Base.dll
Syntax
public class ExcelToPdfConverter : Object, IDisposable
Remarks
Excel To Pdf Conversion is not supported in WinRT, Windows Phone, Universal, Portable and Silverlight platforms.
Constructors
ExcelToPdfConverter()
Initializes a new instance of the ExcelToPdfConverter class.
Declaration
public ExcelToPdfConverter()
ExcelToPdfConverter(IChart)
Initializes a new instance of the ExcelToPdfConverter class with the specified chart.
Declaration
public ExcelToPdfConverter(IChart chart)
Parameters
Type | Name | Description |
---|---|---|
IChart | chart | The chart. |
ExcelToPdfConverter(IWorkbook)
Initializes a new instance of the ExcelToPdfConverter class with the specified workbook.
Declaration
public ExcelToPdfConverter(IWorkbook workbook)
Parameters
Type | Name | Description |
---|---|---|
IWorkbook | workbook | The workbook. |
ExcelToPdfConverter(IWorksheet)
Initializes a new instance of the ExcelToPdfConverter class with the specified worksheet.
Declaration
public ExcelToPdfConverter(IWorksheet worksheet)
Parameters
Type | Name | Description |
---|---|---|
IWorksheet | worksheet | The worksheet. |
ExcelToPdfConverter(Stream)
Initializes a new instance of the ExcelToPdfConverter class with the specified stream.
Declaration
public ExcelToPdfConverter(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The workbook stream. |
ExcelToPdfConverter(String)
Initializes a new instance of the ExcelToPdfConverter class with the specified file name.
Declaration
public ExcelToPdfConverter(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The file path. |
Properties
ChartToImageConverter
Represents the chart to image converter instance.
Declaration
public IChartToImageConverter ChartToImageConverter { get; set; }
Property Value
Methods
add_CurrentProgressChanged(CurrentProgressChangedEventHandler)
Declaration
public void add_CurrentProgressChanged(CurrentProgressChangedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
CurrentProgressChangedEventHandler | value |
add_SheetAfterDrawn(SheetAfterDrawnEventHandler)
Declaration
public void add_SheetAfterDrawn(SheetAfterDrawnEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SheetAfterDrawnEventHandler | value |
add_SheetBeforeDrawn(SheetBeforeDrawnEventHandler)
Declaration
public void add_SheetBeforeDrawn(SheetBeforeDrawnEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SheetBeforeDrawnEventHandler | value |
Convert()
Converts the document.
Declaration
public PdfDocument Convert()
Returns
Type | Description |
---|---|
PdfDocument | Returns the PDFDocument Object |
Examples
The following code snippet illustrates how to convert the workbook.
using Syncfusion.XlsIO;
using Syncfusion.Pdf;
using Syncfusion.ExcelToPdfConverter;
class Example
{
static void Main()
{
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
PdfDocument doc = converter.Convert();
doc.Save("Output.pdf");
}
}
}
Convert(ExcelToPdfConverterSettings)
Converts the document with the specified converter settings.
Declaration
public PdfDocument Convert(ExcelToPdfConverterSettings converterSettings)
Parameters
Type | Name | Description |
---|---|---|
ExcelToPdfConverterSettings | converterSettings | The converter settings. |
Returns
Type | Description |
---|---|
PdfDocument | Returns the PDFdocument object |
Examples
The following code snippet illustrates how to convert the workbook.
using Syncfusion.XlsIO;
using Syncfusion.ExcelToPdfConverter;
class Example
{
static void Main()
{
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
ExcelToPdfConverterSettings converterSettings = new ExcelToPdfConverterSettings();
converterSettings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;
PdfDocument doc = converter.Convert(converterSettings);
doc.Save("Output.pdf");
}
}
}
CropHFImage(Image, Double, Double, Double, Double, Boolean)
Crops the image with the specified offset.
Declaration
public static Image CropHFImage(Image cropableImage, double leftOffset, double topOffset, double rightOffset, double bottomOffset, bool isTransparent)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Image | cropableImage | Source image to crop. |
System.Double | leftOffset | Left offset to crop from. |
System.Double | topOffset | Top offset to crop from. |
System.Double | rightOffset | Right offset to crop. |
System.Double | bottomOffset | Bottom offset to crop. |
System.Boolean | isTransparent | Indicates whether the destination image is transparent. |
Returns
Type | Description |
---|---|
System.Drawing.Image | Returns the cropped image for the offsets specified. |
Dispose()
Releases both unmanaged and managed resources.
Declaration
public void Dispose()
Dispose(Boolean)
Releases unmanaged and optionally managed resources
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
|
GetBackgroundHeightCoordinates(Single, Single, Single, Single, Dictionary<PointF, SizeF>, PdfPage)
Gets the vertical coordinates of image background.
Declaration
protected Dictionary<PointF, SizeF> GetBackgroundHeightCoordinates(float startX, float startY, float imageWidth, float imageHeight, Dictionary<PointF, SizeF> imageCoordinates, PdfPage pdfPage)
Parameters
Type | Name | Description |
---|---|---|
System.Single | startX | The X coordinate. |
System.Single | startY | The Y coordinate. |
System.Single | imageWidth | Width of the image. |
System.Single | imageHeight | Height of the image. |
System.Collections.Generic.Dictionary<System.Drawing.PointF, System.Drawing.SizeF> | imageCoordinates | The image coordinate. |
PdfPage | pdfPage | The PDF page. |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.Drawing.PointF, System.Drawing.SizeF> | returns the vertical coordinates of image background. |
GetBackgroundWidthCoordinates(Single, Single, Single, Single, Dictionary<PointF, SizeF>, PdfPage)
Gets the horizontal coordinates of image background.
Declaration
protected Dictionary<PointF, SizeF> GetBackgroundWidthCoordinates(float startX, float startY, float imageWidth, float imageHeight, Dictionary<PointF, SizeF> imageCoordinates, PdfPage pdfPage)
Parameters
Type | Name | Description |
---|---|---|
System.Single | startX | The X coordinate. |
System.Single | startY | The Y coordinate. |
System.Single | imageWidth | Width of the image. |
System.Single | imageHeight | Height of the image. |
System.Collections.Generic.Dictionary<System.Drawing.PointF, System.Drawing.SizeF> | imageCoordinates | The image coordinate. |
PdfPage | pdfPage | The PDF page. |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.Drawing.PointF, System.Drawing.SizeF> | Returns the horizontal coordinates of background image. |
GetLayoutOptions(PageSetupBaseImpl)
Gets the LayoutOptions LayoutOptions based on PageSetup.
Declaration
public static LayoutOptions GetLayoutOptions(PageSetupBaseImpl pageSetup)
Parameters
Type | Name | Description |
---|---|---|
PageSetupBaseImpl | pageSetup | Current Page setup. |
Returns
Type | Description |
---|---|
LayoutOptions | Returns the LayoutOptions. |
Print()
Print the Excel document.
Declaration
public void Print()
Examples
The following code snippet illustrates how to print the Excel document.
using Syncfusion.XlsIO;
using Syncfusion.ExcelToPdfConverter;
class Example
{
static void Main()
{
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
converter.Print();
}
}
}
Print(ExcelToPdfConverterSettings)
Print the Excel document with specified Excel to PDF converter settings.
Declaration
public void Print(ExcelToPdfConverterSettings converterSettings)
Parameters
Type | Name | Description |
---|---|---|
ExcelToPdfConverterSettings | converterSettings | The converter settings. This will be ignored if the document is already converted. |
Examples
The following code snippet illustrates how to print the Excel document.
using Syncfusion.XlsIO;
using Syncfusion.ExcelToPdfConverter;
class Example
{
static void Main()
{
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
ExcelToPdfConverterSettings converterSettings = new ExcelToPdfConverterSettings();
converterSettings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;
converter.Print(converterSettings);
}
}
}
Print(PrinterSettings)
Print the Excel document with specified printer settings.
Declaration
public void Print(PrinterSettings printerSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Printing.PrinterSettings | printerSettings | The printer settings. |
Examples
The following code snippet illustrates how to print the Excel document.
using Syncfusion.XlsIO;
using Syncfusion.ExcelToPdfConverter;
using System.Drawing.Printing;
class Example
{
static void Main()
{
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
PrinterSettings printerSettings = new PrinterSettings();
converter.Print(printerSettings);
}
}
}
Print(PrinterSettings, ExcelToPdfConverterSettings)
Print the Excel document with specified printer and Excel to PDF converter settings.
Declaration
public void Print(PrinterSettings printerSettings, ExcelToPdfConverterSettings converterSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Printing.PrinterSettings | printerSettings | The printer settings. |
ExcelToPdfConverterSettings | converterSettings | The converter settings. This will be ignored if the document is already converted. |
Examples
The following code snippet illustrates how to print the Excel document.
using Syncfusion.XlsIO;
using Syncfusion.ExcelToPdfConverter;
using System.Drawing.Printing;
class Example
{
static void Main()
{
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);
PrinterSettings printerSettings = new PrinterSettings();
ExcelToPdfConverterSettings converterSettings = new ExcelToPdfConverterSettings();
converterSettings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;
converter.Print(printerSettings, converterSettings);
}
}
}
remove_CurrentProgressChanged(CurrentProgressChangedEventHandler)
Declaration
public void remove_CurrentProgressChanged(CurrentProgressChangedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
CurrentProgressChangedEventHandler | value |
remove_SheetAfterDrawn(SheetAfterDrawnEventHandler)
Declaration
public void remove_SheetAfterDrawn(SheetAfterDrawnEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SheetAfterDrawnEventHandler | value |
remove_SheetBeforeDrawn(SheetBeforeDrawnEventHandler)
Declaration
public void remove_SheetBeforeDrawn(SheetBeforeDrawnEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
SheetBeforeDrawnEventHandler | value |
Events
CurrentProgressChanged
Occurs when current progress changed.
Declaration
public event CurrentProgressChangedEventHandler CurrentProgressChanged
Event Type
SheetAfterDrawn
Occurs after the sheet is drawn.
Declaration
public event SheetAfterDrawnEventHandler SheetAfterDrawn
Event Type
SheetBeforeDrawn
Occurs before the sheet is drawn.
Declaration
public event SheetBeforeDrawnEventHandler SheetBeforeDrawn