Class GridPDFConverter
Implements the functionalities for exporting the grid to PDF document.
Inheritance
Inherited Members
Namespace: Syncfusion.GridHelperClasses
Assembly: Syncfusion.GridHelperClasses.Windows.dll
Syntax
public class GridPDFConverter
Remarks
It has support for Header, Footer and Margins. It uses Grid's printing library to generate Metafile images and generates PDF file
Constructors
GridPDFConverter()
Initializes a new instance of the GridPDFConverter class.
Declaration
public GridPDFConverter()
GridPDFConverter(Boolean, Boolean)
Initializes a new instance of the GridPDFConverter class.
Declaration
public GridPDFConverter(bool showHeader, bool showFooter)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | showHeader | True if Header should be shown; Default is false. |
System.Boolean | showFooter | True if Footer should be shown; Default is false. |
Properties
ExportRange
Gets or sets the range of records to be exported.
Declaration
public int ExportRange { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
Determines the export range of records when ExportToPdfWithMerge is used Note: the method ExportToPdfWithMerge is used to handle "out of memory exception" which happens when the record count exceeds 60k records hence this value determines the no of records that can be exported in each single PDF file. This value can't be set more than 60k.
FooterHeight
Gets or sets the height of the Footer.
Declaration
public int FooterHeight { get; set; }
Property Value
Type |
---|
System.Int32 |
HeaderHeight
Gets or sets the height of the Header.
Declaration
public int HeaderHeight { get; set; }
Property Value
Type |
---|
System.Int32 |
Margins
Gets or sets the Margins for the PDF document.
Declaration
public PdfMargins Margins { get; set; }
Property Value
Type |
---|
PdfMargins |
PdfMergeMode
Gets or sets the MergeAt for the PDF Document
Declaration
public GridPDFConverter.MergeMode PdfMergeMode { get; set; }
Property Value
Type |
---|
GridPDFConverter.MergeMode |
ShowFooter
Gets or sets a value indicating whether a Footer should be shown. True if Header should be shown; Default is false
Declaration
public bool ShowFooter { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
GridPDFConverter lets the user to draw the required Footer. Handle the DrawPDFFooter event. Height is set with FooterHeight
ShowHeader
Gets or sets a value indicating whether a Header should be shown. True if Header should be shown; Default is false
Declaration
public bool ShowHeader { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
GridPDFConverter lets the user to draw the required Header. Handle the DrawPDFHeader event. Height is set with HeaderHeight
Methods
ConvertMetafilesToPdf(List<Metafile>, PdfSection)
Converts the provided Metafiles to the PDF section.
Declaration
protected void ConvertMetafilesToPdf(List<Metafile> metaFiles, PdfSection section)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.Drawing.Imaging.Metafile> | metaFiles | list containing Grid images |
PdfSection | section | PDF section to insert |
DrawGridToMetafiles(GridControlBase, Size)
Converts the grid to meta files.
Declaration
protected List<Metafile> DrawGridToMetafiles(GridControlBase grid, Size imgSize)
Parameters
Type | Name | Description |
---|---|---|
GridControlBase | grid | The GridControl to be exported. |
System.Drawing.Size | imgSize | Size of the image to create. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.Drawing.Imaging.Metafile> | List of Metafile type. |
DrawHeaderFooter(PdfDocument, Boolean, Boolean)
Draws the Header and Footer.
Declaration
protected void DrawHeaderFooter(PdfDocument pdfDocument, bool top, bool bottom)
Parameters
Type | Name | Description |
---|---|---|
PdfDocument | pdfDocument | The PdfDocument. |
System.Boolean | top | Indicates whether header should be drawn. |
System.Boolean | bottom | Indicates whether footer should be drawn. |
ExportToPdf(PdfDocument, GridControlBase)
Exports the Grid contents to a PDF Document.
Declaration
public void ExportToPdf(PdfDocument pdfDocument, GridControlBase grid)
Parameters
Type | Name | Description |
---|---|---|
PdfDocument | pdfDocument | Destination PDF Document |
GridControlBase | grid | Source Grid to Export |
ExportToPdf(PdfDocument, GridControlBase, GridRangeInfo)
Exports the contents of the cells in a range to PDF file.
Declaration
public void ExportToPdf(PdfDocument pdfDocument, GridControlBase grid, GridRangeInfo exportRange)
Parameters
Type | Name | Description |
---|---|---|
PdfDocument | pdfDocument | Destination PDF Document. |
GridControlBase | grid | Source Grid to Export. |
GridRangeInfo | exportRange | The range to be exported. |
Remarks
If exportRange is GridRangeInfo.Empty, the entire grid is exported.
ExportToPdf(String, GridControlBase)
Exports the Grid contents to PDF file.
Declaration
public void ExportToPdf(string filename, GridControlBase grid)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | File name to write the generated PDF. |
GridControlBase | grid | Grid instance to export. |
ExportToPdf(String, GridControlBase, GridRangeInfo)
Exports the contents of the cells in a range to PDF file.
Declaration
public void ExportToPdf(string filename, GridControlBase grid, GridRangeInfo exportRange)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | File name to write the generated PDF. |
GridControlBase | grid | The GridControl to be exported. |
GridRangeInfo | exportRange | The range to be exported. |
Remarks
If exportRange is GridRangeInfo.Empty, the entire grid is exported.
ExportToPdfWithMerge(ref PdfDocument, GridControlBase)
Exports grid with huge data in to two or more PDF documents internally and Merges them into single document(pdfDocument). This method can be used to handle "out of memory exception" that happens when huge amount of data (more than 60k records) is exported to PDF.
Declaration
public void ExportToPdfWithMerge(ref PdfDocument pdfDocument, GridControlBase grid)
Parameters
Type | Name | Description |
---|---|---|
PdfDocument | pdfDocument | The PDF document to merge the grid content. |
GridControlBase | grid | The grid control to be merged with PDF document. |
ExportToPdfWithMerge(String, GridControlBase)
Exports grid with huge data in to two or more PDF documents internally and Merges them into single document(filename). This method can be used to handle out of memory exception that happens when huge amount of data (more than 60k records) is exported to PDF.
Declaration
public void ExportToPdfWithMerge(string filename, GridControlBase grid)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | File name of the PDF document file. |
GridControlBase | grid | The GridControl to be merged with PDF document. |
OnDrawPDFFooter(PDFHeaderFooterEventArgs)
Raises the DrawPDFFooter event.
Declaration
protected virtual void OnDrawPDFFooter(PDFHeaderFooterEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PDFHeaderFooterEventArgs | e | A PDFHeaderFooterEventArgs that contains the event data. |
OnDrawPDFHeader(PDFHeaderFooterEventArgs)
Raises the DrawPDFHeader and DrawPDFHeader event.
Declaration
protected virtual void OnDrawPDFHeader(PDFHeaderFooterEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PDFHeaderFooterEventArgs | e | The PDFHeaderFooterEventArgs that contains the event data. |
OnPDFExported(PDFExportedEventArgs)
Raises the Exported event.
Declaration
protected virtual void OnPDFExported(PDFExportedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PDFExportedEventArgs | e | An PDFExportingEventArgs that contains the event data. |
OnPDFExporting(PDFExportingEventArgs)
Raises PDFExporting event.
Declaration
protected virtual void OnPDFExporting(PDFExportingEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PDFExportingEventArgs | e | The PDFExportingEventArgs that contains the event data. |
PointToPixelConverter(SizeF)
Point to pixel converter.
Declaration
protected Size PointToPixelConverter(SizeF size)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.SizeF | size | The size of point to pixel converter. |
Returns
Type | Description |
---|---|
System.Drawing.Size | The point to pixel converter. |
Events
DrawPDFFooter
Lets the user draw a Footer for the PDF Document
Declaration
public event GridPDFConverter.DrawPDFHeaderFooterEventHandler DrawPDFFooter
Event Type
Type |
---|
GridPDFConverter.DrawPDFHeaderFooterEventHandler |
DrawPDFHeader
Lets the user draw a header for the PDF Document
Declaration
public event GridPDFConverter.DrawPDFHeaderFooterEventHandler DrawPDFHeader
Event Type
Type |
---|
GridPDFConverter.DrawPDFHeaderFooterEventHandler |
Exported
Occurs after exporting to PDF.
Declaration
public event GridPDFConverter.PDFExportedEventHandler Exported
Event Type
Type |
---|
GridPDFConverter.PDFExportedEventHandler |
Exporting
Occurs while exporting to PDF.
Declaration
public event GridPDFConverter.PDFExportingEventHandler Exporting
Event Type
Type |
---|
GridPDFConverter.PDFExportingEventHandler |