New to Telerik UI for WinForms? Start a free 30-day trial

Exports pivot-grid content to PDF, including page layout, header/footer, and cell-formatting options.

Definition

Namespace:Telerik.WinControls.Export

Assembly:Telerik.WinControls.PivotGrid.dll

Syntax:

C#
public class PivotGridPdfExport

Inheritance: objectPivotGridPdfExport

Constructors

Initializes a PDF exporter for the specified pivot grid control.

C#
public PivotGridPdfExport(RadPivotGrid pivotGrid)
Parameters:pivotGridRadPivotGrid

The control whose grid element supplies the data and layout.

Initializes a PDF exporter for a grid element and copies its current row and column header layouts.

C#
public PivotGridPdfExport(RadPivotGridElement pivotGrid)
Parameters:pivotGridRadPivotGridElement

The grid element whose data will be exported.

Fields

Date when the exporting was started.

C#
public const string DatePrintedString = "[Date Exported]"

Allows to add logo to the header or footer.

C#
public const string LogoString = "[Logo]"

Number of the current page

C#
public const string PageNumberString = "[Page #]"

Time when the printing was started.

C#
public const string TimePrintedString = "[Time Exported]"

Total number of pages

C#
public const string TotalPagesString = "[Total Pages]"

Username associated with the current thread (the current Windows login))

C#
public const string UserNamePrintedString = "[User Name]"

Properties

Gets or sets the color of grid lines.

C#
public Color BorderColor { get; set; }

Gets or sets the background color of cells.

C#
public Color CellBackColor { get; set; }

Gets the layout type of pivot grid column container.

C#
public PivotLayout ColumnsLayoutType { get; set; }

Gets or sets the font of data cells.

C#
public Font DataCellsFont { get; set; }

Gets or sets the background color of descriptor cells.

C#
public Color DescriptorsBackColor { get; set; }

Gets or sets a value indicating whether to export flat data(collapsed rows and columns).

C#
public bool ExportFlatData { get; set; }

Gets or sets a value indicating whether to export only selection.

C#
public bool ExportSelectionOnly { get; set; }

Gets or sets export settings.

C#
public PdfExportSettings ExportSettings { get; set; }

Gets or sets a value indicating whether the visual settings should be exported.

C#
public bool ExportVisualSettings { get; set; }
Property Value:

true if visual settings are exported; otherwise, false.

Gets or sets a value indicating whether the content of page should fit into the page width. Default value is true.

C#
public bool FitToPageWidth { get; set; }

Gets or sets the font of the page footer.

C#
public Font FooterFont { get; set; }

Gets or sets the footer height.

C#
public double FooterHeight { get; set; }

Gets or sets the background color of grandtotal cells.

C#
public Color GrandTotalsBackColor { get; set; }

Gets or sets the font of header cells.

C#
public Font HeaderCellsFont { get; set; }

Gets or sets the font of the page header.

C#
public Font HeaderFont { get; set; }

Gets or sets the header height.

C#
public double HeaderHeight { get; set; }

Gets or sets the background color of header cells.

C#
public Color HeadersBackColor { get; set; }

Gets or sets the text that will be exported near the bottom left corner of the page.

C#
public string LeftFooter { get; set; }

Gets or sets the text that will be exported near the upper left corner of the page.

C#
public string LeftHeader { get; set; }

Gets or sets the header/footer logo.

C#
public Image Logo { get; set; }

Gets or sets the text that will be exported at the bottom center of the page.

C#
public string MiddleFooter { get; set; }

Gets or sets the text that will be exported at the top center of the page.

C#
public string MiddleHeader { get; set; }

Gets or Sets the margins of pages that will be exported in millimeters.

C#
public Padding PageMargins { get; set; }

Gets or sets the page size in millimeters for the exported file.

C#
public SizeF PageSize { get; set; }

[true] if the LeftFooter and RightFooter should be reversed on even pages, [false] otherwise.

C#
public bool ReverseFooterOnEvenPages { get; set; }

[true] if the LeftHeader and RightHeader should be reversed on even pages, [false] otherwise.

C#
public bool ReverseHeaderOnEvenPages { get; set; }

Gets or sets the text that will be exported near the bottom right corner of the page.

C#
public string RightFooter { get; set; }

Gets or sets the text that will be exported near the upper right corner of the page.

C#
public string RightHeader { get; set; }

Gets the layout type of pivot grid row container.

C#
public PivotLayout RowsLayoutType { get; set; }

Gets or sets the document scaling. Default value is 1. For example, scale of 1.2f means 20% size increase.

C#
public double Scale { get; set; }

Gets or sets a value indicating whether header and footer should be exported.

C#
public bool ShowHeaderAndFooter { get; set; }

Gets or sets the background color of subtotal cells.

C#
public Color SubTotalsBackColor { get; set; }

Methods

Converts a value to text and splits it at Windows or Unix line breaks, preserving empty lines.

C#
protected virtual string[] ApplyLineBreaksToText(object value)
Parameters:valueobject

The value to convert; null is treated as an empty string.

Returns:

string[]

The text lines in the value.

Calculates a nonnegative offset that aligns content horizontally and centers it vertically in a header or footer area.

C#
protected virtual SizeF CalculateHeaderFooterContentOffset(double height, SizeF size, StringAlignment alignment)
Parameters:heightdouble

The available height.

sizeSizeF

The measured content size.

alignmentStringAlignment

The horizontal alignment within the printable width.

Returns:

SizeF

The horizontal and vertical offsets for drawing the content.

Cancels an asynchronous export operation.

C#
public void CancelExportAsync()

Converts an image to the byte array format used by the PDF renderer.

C#
protected virtual byte[] ConvertImageToByteArray(Image image)
Parameters:imageImage

The image to convert.

Returns:

byte[]

The encoded image bytes.

Draws a cell's fill, borders, content, and paint event, continuing it on subsequent horizontal pages when necessary.

C#
protected virtual double DrawCell(GridPdfExportCellElement cell, string[] value, double rowHeight, double cellWidth, double columnWidth, bool isNotCellFirstPage)
Parameters:cellGridPdfExportCellElement

The cell appearance and content to draw.

valuestring[]

The text lines to render when the cell contains text rather than an image.

rowHeightdouble

The row height in the PDF layout.

cellWidthdouble

The portion of the cell width drawn on the current page.

columnWidthdouble

The full column width used to align and wrap the cell content.

isNotCellFirstPagebool

true when drawing a continuation of a cell on a later page.

Returns:

double

The remaining cell width that still needs to be drawn on later pages.

Draws cell borders according to its border-box style and reports any width extending beyond the current page.

C#
protected virtual double DrawCellBorders(GridPdfExportCellElement cell, double rowHeight, double width, bool isNotFirst)
Parameters:cellGridPdfExportCellElement

The cell providing border colors and style.

rowHeightdouble

The row height in the PDF layout.

widthdouble

The cell width on the current page.

isNotFirstbool

true when drawing a continuation on a later page.

Returns:

double

The cell width that extends beyond the current page.

Fills the visible portion of a cell with its background color or configured linear gradient.

C#
protected virtual void DrawCellFill(GridPdfExportCellElement cell, double rowHeight, double width)
Parameters:cellGridPdfExportCellElement

The cell providing the background colors.

rowHeightdouble

The row height in the PDF layout.

widthdouble

The cell width on the current page.

Exports the footer part of the page.

C#
protected virtual void DrawFooter()

Draws each border side separately and uses its color, width, and shadow when visual settings are exported.

C#
protected virtual void DrawFourBorders(GridPdfExportCellElement cell, ref PointF tLeft, ref PointF tRight, ref PointF bRight, ref PointF bLeft, bool drawLeftBorder, bool drawRightBorder)
Parameters:cellGridPdfExportCellElement

The cell providing side-specific border styles.

tLeftPointF

The top-left border point.

tRightPointF

The top-right border point.

bRightPointF

The bottom-right border point.

bLeftPointF

The bottom-left border point.

drawLeftBorderbool

Whether to draw the left edge.

drawRightBorderbool

Whether to draw the right edge.

Exports the header part of the page.

C#
protected virtual void DrawHeader()

Draws the left, center, and right header or footer content, swapping the left and right strings on configured even pages.

C#
protected virtual void DrawHeaderFooter(PageHeaderFooter headerFooter)
Parameters:headerFooterPageHeaderFooter

The text, logo placeholders, alignment, and height to draw.

Draws the configured logo when the header or footer text contains the LogoString placeholder.

C#
protected virtual void DrawHeaderFooterImage(string text, double height, StringAlignment alignment)
Parameters:textstring

The header or footer string to inspect for the logo placeholder.

heightdouble

The available height for the logo.

alignmentStringAlignment

The horizontal alignment of the logo.

Draws header or footer text, wrapping and clipping it when it exceeds the available content area.

C#
protected virtual void DrawHeaderFooterText(string text, double height, StringAlignment alignment)
Parameters:textstring

The parsed text to draw.

heightdouble

The available height for the text block.

alignmentStringAlignment

The horizontal alignment within the printable page width.

Draws the cell image using its alignment and clips it to the current cell or page segment.

C#
protected virtual void DrawImage(GridPdfExportCellElement cell, double rowHeight, double cellWidth, double columnWidth, bool isNotFirst)
Parameters:cellGridPdfExportCellElement

The cell containing the image and its alignment.

rowHeightdouble

The row height in the PDF layout.

cellWidthdouble

The portion of the cell width drawn on the current page.

columnWidthdouble

The full column width used to align the image.

isNotFirstbool

true when drawing a continuation on a later page.

Draws the cell's outer border and, when visual settings are exported, its inner shadow lines.

C#
protected virtual void DrawOuterInnerBorders(GridPdfExportCellElement cell, ref PointF tLeft, ref PointF tRight, ref PointF bRight, ref PointF bLeft, bool drawLeftBorder, bool drawRightBorder)
Parameters:cellGridPdfExportCellElement

The cell providing border colors and widths.

tLeftPointF

The top-left border point.

tRightPointF

The top-right border point.

bRightPointF

The bottom-right border point.

bLeftPointF

The bottom-left border point.

drawLeftBorderbool

Whether to draw the left edge.

drawRightBorderbool

Whether to draw the right edge.

Draws a prepared row, moving to another page when needed and fitting its width when FitToPageWidth is enabled.

C#
protected virtual void DrawRow(PivotGridExportRowElement rowElement)
Parameters:rowElementPivotGridExportRowElement

The row containing the export cells to draw.

Draws a single rectangular border, optionally omitting its left or right edge at a page break.

C#
protected virtual void DrawSingleBorder(GridPdfExportCellElement cell, ref PointF tLeft, ref PointF tRight, ref PointF bRight, ref PointF bLeft, bool drawLeftBorder, bool drawRightBorder)
Parameters:cellGridPdfExportCellElement

The cell providing the border color when visual settings are exported.

tLeftPointF

The top-left border point.

tRightPointF

The top-right border point.

bRightPointF

The bottom-right border point.

bLeftPointF

The bottom-left border point.

drawLeftBorderbool

Whether to draw the left edge.

drawRightBorderbool

Whether to draw the right edge.

Draws the supplied text lines using the cell's alignment and wrapping settings, clipping content to the page segment.

C#
protected virtual void DrawText(GridPdfExportCellElement cell, string[] value, double rowHeight, double cellWidth, double columnWidth, bool isNotFirst)
Parameters:cellGridPdfExportCellElement

The cell whose font, color, and text layout settings are applied.

valuestring[]

The lines of text to render.

rowHeightdouble

The row height in the PDF layout.

cellWidthdouble

The portion of the cell width drawn on the current page.

columnWidthdouble

The full column width used to align and wrap the text.

isNotFirstbool

true when drawing a continuation on a later page.

Creates the export cell for an aggregate heading, using grid visuals or the configured descriptor styling.

C#
protected virtual PivotGridSpreadExportCellElement GetAggregateDescriptorCell(int aggregateIndex)
Parameters:aggregateIndexint

The index of the aggregate description.

Returns:

PivotGridSpreadExportCellElement

The cell model for the aggregate heading.

Creates a column-descriptor heading from the field name or aggregate label.

C#
protected virtual PivotGridSpreadExportCellElement GetColumnDescriptorCell(int descriptorIndex)
Parameters:descriptorIndexint

The index of the column descriptor.

Returns:

PivotGridSpreadExportCellElement

The column-descriptor cell model.

Creates a cell for the column-group header at the specified export row and column.

C#
protected virtual PivotGridSpreadExportCellElement GetColumnHeaderCell(int rowIndex, int columnIndex)
Parameters:rowIndexint

The index of the header row in the export layout.

columnIndexint

The index of the column group in the export data.

Returns:

PivotGridSpreadExportCellElement

The column-header cell model.

Creates a cell from the aggregate value at the specified row and column groups and applies its export styling.

C#
protected virtual PivotGridSpreadExportCellElement GetDataCell(int rowIndex, int columnIndex, PivotRowElement visualRow)
Parameters:rowIndexint

The index of the row group in the export data.

columnIndexint

The index of the column group in the export data.

visualRowPivotRowElement

The attached visual row used to read cell styling when visual settings are exported.

Returns:

PivotGridSpreadExportCellElement

The cell model containing the aggregate value and formatted text.

Maps an export coordinate to its descriptor, header, or data-cell model.

C#
protected virtual PivotGridSpreadExportCellElement GetExportElementForCell(int rowIndex, int columnIndex, PivotRowElement visualRow)
Parameters:rowIndexint

The zero-based row index in the export layout.

columnIndexint

The zero-based column index in the export layout.

visualRowPivotRowElement

The visual row used to obtain cell styling when visual settings are exported.

Returns:

PivotGridSpreadExportCellElement

The cell model for the position, or null when no cell is exported there.

Calculates the page count from the initialized export layout and current page settings. When FitToPageWidth is enabled, horizontal pages are fitted into one page width.

C#
public int GetNumberOfPages()
Returns:

int

The number of pages required by the current layout.

Creates a row-descriptor heading, using individual field names in tabular layout or a single label in compact layout.

C#
protected virtual PivotGridSpreadExportCellElement GetRowDescriptorCell(int descriptorIndex)
Parameters:descriptorIndexint

The index of the row descriptor.

Returns:

PivotGridSpreadExportCellElement

The row-descriptor cell model.

Creates a cell for the row-group header at the specified data row and header column.

C#
protected virtual PivotGridSpreadExportCellElement GetRowHeaderCell(int rowIndex, int columnIndex)
Parameters:rowIndexint

The index of the row group in the export data.

columnIndexint

The index of the row-header column.

Returns:

PivotGridSpreadExportCellElement

The row-header cell model.

Copies font, colors, border, and text-wrapping settings from a grid visual element when visual settings are enabled.

C#
protected virtual void GetStylesFromVisualCell(PivotGridSpreadExportCellElement gridVisualElement, LightVisualElement visualCell)
Parameters:gridVisualElementPivotGridSpreadExportCellElement

The export-cell model to style.

visualCellLightVisualElement

The grid visual element whose style is copied.

Finds the row- or column-header visual element at the specified export coordinates.

C#
protected virtual LightVisualElement GetVisualElement(int rowIndex, int columnIndex)
Parameters:rowIndexint

The zero-based row index in the export layout.

columnIndexint

The zero-based column index in the export layout.

Returns:

LightVisualElement

The matching header visual element, or null when the position has no corresponding header element.

Determines whether the specified header or footer string contains the logo placeholder.

C#
protected virtual bool HasLogoInHeaderFooterString(string s)
Parameters:sstring

The string to inspect.

Returns:

bool

true when the string contains LogoString; otherwise, false.

Rebuilds the internal row, column, descriptor, and size data used by the next export. Collapsed groups are expanded when ExportFlatData is enabled, and groups outside the selection are omitted when ExportSelectionOnly is enabled.

C#
public virtual void Initialize()

Raises the event.

C#
protected virtual void OnAsyncExportCompleted(AsyncCompletedEventArgs e)
Parameters:eAsyncCompletedEventArgs

The AsyncCompletedEventArgs instance containing the event data.

Raises the event.

C#
protected virtual void OnAsyncExportProgressChanged(ProgressChangedEventArgs e)
Parameters:eProgressChangedEventArgs

The ProgressChangedEventArgs instance containing the event data.

Raises the event.

C#
protected virtual void OnCellFormatting(PivotGridPdfExportCellFormattingEventArgs e)
Parameters:ePivotGridPdfExportCellFormattingEventArgs

The PivotGridPdfExportCellFormattingEventArgs instance containing the event data.

Raises the event.

C#
protected virtual void OnCellPaint(ExportCellPaintEventArgs e)
Parameters:eExportCellPaintEventArgs

The ExportCellPaintEventArgs instance containing the event data.

Raises the event.

C#
protected virtual void OnFooterExported(ExportEventArgs e)
Parameters:eExportEventArgs

The ExportEventArgs instance containing the event data.

Raises the event.

C#
protected virtual void OnHeaderExported(ExportEventArgs e)
Parameters:eExportEventArgs

The ExportEventArgs instance containing the event data.

Raises the event.

C#
protected virtual void OnPdfExported(EventArgs e)
Parameters:eEventArgs

The EventArgs instance containing the event data.

Parses a given string for special words.

C#
protected virtual string ParseHeaderFooterString(string s)
Parameters:sstring

The string.

Returns:

string

The parsed string.

Builds export cells for each prepared row and passes each row to the PDF drawing pipeline.

C#
protected virtual void ProcessRows()

Starts an export operation.

C#
public void RunExport(Stream exportStream, IPdfExportRenderer pdfExportRenderer)
Parameters:exportStreamStream

The stream where data will be exported.

pdfExportRendererIPdfExportRenderer

.

Starts an export operation.

C#
public void RunExport(string fileName, IPdfExportRenderer pdfExportRenderer)
Parameters:fileNamestring

The file name where data will be exported.

pdfExportRendererIPdfExportRenderer

.

Starts an export operation that runs in a background thread.

C#
public void RunExportAsync(Stream exportStream, IPdfExportRenderer exportRenderer)
Parameters:exportStreamStream

The stream where data will be exported.

exportRendererIPdfExportRenderer

Instance of IPdfExportRenderer class.

Starts an export operation that runs in a background thread.

C#
public void RunExportAsync(string fileName, IPdfExportRenderer exportRenderer)
Parameters:fileNamestring

The file name where data will be exported.

exportRendererIPdfExportRenderer

Instance of IPdfExportRenderer class.

Events

Occurs when an async export operation is completed.

C#
public event AsyncCompletedEventHandler AsyncExportCompleted

Occurs when the progress of an async export operation changes.

C#
public event ProgressChangedEventHandler AsyncExportProgressChanged

Occurs for every cell that is being exported.

C#
public event PivotGridPdfExportCellFormattingEventHandler CellFormatting

Occurs when a cell is drawn.

C#
public event ExportCellPaintEventHandler CellPaint

Occurs when the footer is exported.

C#
public event ExportEventHandler FooterExported

Occurs when the header is exported.

C#
public event ExportEventHandler HeaderExported

Occurs when the export process completes.

C#
public event EventHandler PdfExported
In this article
DefinitionConstructorsPivotGridPdfExport(RadPivotGrid)PivotGridPdfExport(RadPivotGridElement)FieldsDatePrintedStringLogoStringPageNumberStringTimePrintedStringTotalPagesStringUserNamePrintedStringPropertiesBorderColorCellBackColorColumnsLayoutTypeDataCellsFontDescriptorsBackColorExportFlatDataExportSelectionOnlyExportSettingsExportVisualSettingsFitToPageWidthFooterFontFooterHeightGrandTotalsBackColorHeaderCellsFontHeaderFontHeaderHeightHeadersBackColorLeftFooterLeftHeaderMiddleFooterMiddleHeaderPageMarginsPageSizeReverseFooterOnEvenPagesReverseHeaderOnEvenPagesRightFooterRightHeaderRowsLayoutTypeScaleShowHeaderAndFooterSubTotalsBackColorMethodsApplyLineBreaksToText(object)CalculateHeaderFooterContentOffset(double, SizeF, StringAlignment)CancelExportAsync()ConvertImageToByteArray(Image)DrawCell(GridPdfExportCellElement, string[], double, double, double, bool)DrawCellBorders(GridPdfExportCellElement, double, double, bool)DrawCellFill(GridPdfExportCellElement, double, double)DrawFooter()DrawFourBorders(GridPdfExportCellElement, ref PointF, ref PointF, ref PointF, ref PointF, bool, bool)DrawHeader()DrawHeaderFooter(PageHeaderFooter)DrawHeaderFooterImage(string, double, StringAlignment)DrawHeaderFooterText(string, double, StringAlignment)DrawImage(GridPdfExportCellElement, double, double, double, bool)DrawOuterInnerBorders(GridPdfExportCellElement, ref PointF, ref PointF, ref PointF, ref PointF, bool, bool)DrawRow(PivotGridExportRowElement)DrawSingleBorder(GridPdfExportCellElement, ref PointF, ref PointF, ref PointF, ref PointF, bool, bool)DrawText(GridPdfExportCellElement, string[], double, double, double, bool)GetAggregateDescriptorCell(int)GetColumnDescriptorCell(int)GetColumnHeaderCell(int, int)GetDataCell(int, int, PivotRowElement)GetExportElementForCell(int, int, PivotRowElement)GetNumberOfPages()GetRowDescriptorCell(int)GetRowHeaderCell(int, int)GetStylesFromVisualCell(PivotGridSpreadExportCellElement, LightVisualElement)GetVisualElement(int, int)HasLogoInHeaderFooterString(string)Initialize()OnAsyncExportCompleted(AsyncCompletedEventArgs)OnAsyncExportProgressChanged(ProgressChangedEventArgs)OnCellFormatting(PivotGridPdfExportCellFormattingEventArgs)OnCellPaint(ExportCellPaintEventArgs)OnFooterExported(ExportEventArgs)OnHeaderExported(ExportEventArgs)OnPdfExported(EventArgs)ParseHeaderFooterString(string)ProcessRows()RunExport(Stream, IPdfExportRenderer)RunExport(string, IPdfExportRenderer)RunExportAsync(Stream, IPdfExportRenderer)RunExportAsync(string, IPdfExportRenderer)EventsAsyncExportCompletedAsyncExportProgressChangedCellFormattingCellPaintFooterExportedHeaderExportedPdfExported
Not finding the help you need?
Contact Support