PivotGridPdfExport
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:
public class PivotGridPdfExport
Inheritance: objectPivotGridPdfExport
Constructors
Initializes a PDF exporter for the specified pivot grid control.
public PivotGridPdfExport(RadPivotGrid pivotGrid)
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.
public PivotGridPdfExport(RadPivotGridElement pivotGrid)
The grid element whose data will be exported.
Fields
Date when the exporting was started.
public const string DatePrintedString = "[Date Exported]"
Allows to add logo to the header or footer.
public const string LogoString = "[Logo]"
Number of the current page
public const string PageNumberString = "[Page #]"
Time when the printing was started.
public const string TimePrintedString = "[Time Exported]"
Total number of pages
public const string TotalPagesString = "[Total Pages]"
Username associated with the current thread (the current Windows login))
public const string UserNamePrintedString = "[User Name]"
Properties
Gets or sets the color of grid lines.
public Color BorderColor { get; set; }
Gets or sets the background color of cells.
public Color CellBackColor { get; set; }
Gets the layout type of pivot grid column container.
public PivotLayout ColumnsLayoutType { get; set; }
Gets or sets the font of data cells.
public Font DataCellsFont { get; set; }
Gets or sets the background color of descriptor cells.
public Color DescriptorsBackColor { get; set; }
Gets or sets a value indicating whether to export flat data(collapsed rows and columns).
public bool ExportFlatData { get; set; }
Gets or sets a value indicating whether to export only selection.
public bool ExportSelectionOnly { get; set; }
Gets or sets export settings.
public PdfExportSettings ExportSettings { get; set; }
Gets or sets a value indicating whether the visual settings should be exported.
public bool ExportVisualSettings { get; set; }
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.
public bool FitToPageWidth { get; set; }
Gets or sets the font of the page footer.
public Font FooterFont { get; set; }
Gets or sets the footer height.
public double FooterHeight { get; set; }
Gets or sets the background color of grandtotal cells.
public Color GrandTotalsBackColor { get; set; }
Gets or sets the font of header cells.
public Font HeaderCellsFont { get; set; }
Gets or sets the font of the page header.
public Font HeaderFont { get; set; }
Gets or sets the header height.
public double HeaderHeight { get; set; }
Gets or sets the background color of header cells.
public Color HeadersBackColor { get; set; }
Gets or sets the text that will be exported near the bottom left corner of the page.
public string LeftFooter { get; set; }
Gets or sets the text that will be exported near the upper left corner of the page.
public string LeftHeader { get; set; }
Gets or sets the text that will be exported at the bottom center of the page.
public string MiddleFooter { get; set; }
Gets or sets the text that will be exported at the top center of the page.
public string MiddleHeader { get; set; }
Gets or Sets the margins of pages that will be exported in millimeters.
public Padding PageMargins { get; set; }
Gets or sets the page size in millimeters for the exported file.
public SizeF PageSize { get; set; }
[true] if the LeftFooter and RightFooter should be reversed on even pages, [false] otherwise.
public bool ReverseFooterOnEvenPages { get; set; }
[true] if the LeftHeader and RightHeader should be reversed on even pages, [false] otherwise.
public bool ReverseHeaderOnEvenPages { get; set; }
Gets or sets the text that will be exported near the bottom right corner of the page.
public string RightFooter { get; set; }
Gets or sets the text that will be exported near the upper right corner of the page.
public string RightHeader { get; set; }
Gets the layout type of pivot grid row container.
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.
public double Scale { get; set; }
Gets or sets a value indicating whether header and footer should be exported.
public bool ShowHeaderAndFooter { get; set; }
Gets or sets the background color of subtotal cells.
public Color SubTotalsBackColor { get; set; }
Methods
Calculates a nonnegative offset that aligns content horizontally and centers it vertically in a header or footer area.
protected virtual SizeF CalculateHeaderFooterContentOffset(double height, SizeF size, StringAlignment alignment)
The available height.
sizeSizeFThe measured content size.
alignmentStringAlignmentThe horizontal alignment within the printable width.
Returns:The horizontal and vertical offsets for drawing the content.
Cancels an asynchronous export operation.
public void CancelExportAsync()
Draws a cell's fill, borders, content, and paint event, continuing it on subsequent horizontal pages when necessary.
protected virtual double DrawCell(GridPdfExportCellElement cell, string[] value, double rowHeight, double cellWidth, double columnWidth, bool isNotCellFirstPage)
The cell appearance and content to draw.
valuestring[]The text lines to render when the cell contains text rather than an image.
rowHeightdoubleThe row height in the PDF layout.
cellWidthdoubleThe portion of the cell width drawn on the current page.
columnWidthdoubleThe full column width used to align and wrap the cell content.
isNotCellFirstPagebooltrue when drawing a continuation of a cell on a later page.
Returns: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.
protected virtual double DrawCellBorders(GridPdfExportCellElement cell, double rowHeight, double width, bool isNotFirst)
The cell providing border colors and style.
rowHeightdoubleThe row height in the PDF layout.
widthdoubleThe cell width on the current page.
isNotFirstbooltrue when drawing a continuation on a later page.
Returns:The cell width that extends beyond the current page.
Fills the visible portion of a cell with its background color or configured linear gradient.
protected virtual void DrawCellFill(GridPdfExportCellElement cell, double rowHeight, double width)
The cell providing the background colors.
rowHeightdoubleThe row height in the PDF layout.
widthdoubleThe cell width on the current page.
Exports the footer part of the page.
protected virtual void DrawFooter()
Draws each border side separately and uses its color, width, and shadow when visual settings are exported.
protected virtual void DrawFourBorders(GridPdfExportCellElement cell, ref PointF tLeft, ref PointF tRight, ref PointF bRight, ref PointF bLeft, bool drawLeftBorder, bool drawRightBorder)
The cell providing side-specific border styles.
tLeftPointFThe top-left border point.
tRightPointFThe top-right border point.
bRightPointFThe bottom-right border point.
bLeftPointFThe bottom-left border point.
drawLeftBorderboolWhether to draw the left edge.
drawRightBorderboolWhether to draw the right edge.
Exports the header part of the page.
protected virtual void DrawHeader()
Draws the left, center, and right header or footer content, swapping the left and right strings on configured even pages.
protected virtual void DrawHeaderFooter(PageHeaderFooter headerFooter)
The text, logo placeholders, alignment, and height to draw.
Draws the configured logo when the header or footer text contains the LogoString placeholder.
protected virtual void DrawHeaderFooterImage(string text, double height, StringAlignment alignment)
The header or footer string to inspect for the logo placeholder.
heightdoubleThe available height for the logo.
alignmentStringAlignmentThe horizontal alignment of the logo.
Draws header or footer text, wrapping and clipping it when it exceeds the available content area.
protected virtual void DrawHeaderFooterText(string text, double height, StringAlignment alignment)
The parsed text to draw.
heightdoubleThe available height for the text block.
alignmentStringAlignmentThe horizontal alignment within the printable page width.
Draws the cell image using its alignment and clips it to the current cell or page segment.
protected virtual void DrawImage(GridPdfExportCellElement cell, double rowHeight, double cellWidth, double columnWidth, bool isNotFirst)
The cell containing the image and its alignment.
rowHeightdoubleThe row height in the PDF layout.
cellWidthdoubleThe portion of the cell width drawn on the current page.
columnWidthdoubleThe full column width used to align the image.
isNotFirstbooltrue when drawing a continuation on a later page.
Draws the cell's outer border and, when visual settings are exported, its inner shadow lines.
protected virtual void DrawOuterInnerBorders(GridPdfExportCellElement cell, ref PointF tLeft, ref PointF tRight, ref PointF bRight, ref PointF bLeft, bool drawLeftBorder, bool drawRightBorder)
The cell providing border colors and widths.
tLeftPointFThe top-left border point.
tRightPointFThe top-right border point.
bRightPointFThe bottom-right border point.
bLeftPointFThe bottom-left border point.
drawLeftBorderboolWhether to draw the left edge.
drawRightBorderboolWhether to draw the right edge.
Draws a prepared row, moving to another page when needed and fitting its width when FitToPageWidth is enabled.
protected virtual void DrawRow(PivotGridExportRowElement rowElement)
The row containing the export cells to draw.
Draws a single rectangular border, optionally omitting its left or right edge at a page break.
protected virtual void DrawSingleBorder(GridPdfExportCellElement cell, ref PointF tLeft, ref PointF tRight, ref PointF bRight, ref PointF bLeft, bool drawLeftBorder, bool drawRightBorder)
The cell providing the border color when visual settings are exported.
tLeftPointFThe top-left border point.
tRightPointFThe top-right border point.
bRightPointFThe bottom-right border point.
bLeftPointFThe bottom-left border point.
drawLeftBorderboolWhether to draw the left edge.
drawRightBorderboolWhether to draw the right edge.
Draws the supplied text lines using the cell's alignment and wrapping settings, clipping content to the page segment.
protected virtual void DrawText(GridPdfExportCellElement cell, string[] value, double rowHeight, double cellWidth, double columnWidth, bool isNotFirst)
The cell whose font, color, and text layout settings are applied.
valuestring[]The lines of text to render.
rowHeightdoubleThe row height in the PDF layout.
cellWidthdoubleThe portion of the cell width drawn on the current page.
columnWidthdoubleThe full column width used to align and wrap the text.
isNotFirstbooltrue when drawing a continuation on a later page.
Creates the export cell for an aggregate heading, using grid visuals or the configured descriptor styling.
protected virtual PivotGridSpreadExportCellElement GetAggregateDescriptorCell(int aggregateIndex)
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.
protected virtual PivotGridSpreadExportCellElement GetColumnDescriptorCell(int descriptorIndex)
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.
protected virtual PivotGridSpreadExportCellElement GetColumnHeaderCell(int rowIndex, int columnIndex)
The index of the header row in the export layout.
columnIndexintThe 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.
protected virtual PivotGridSpreadExportCellElement GetDataCell(int rowIndex, int columnIndex, PivotRowElement visualRow)
The index of the row group in the export data.
columnIndexintThe index of the column group in the export data.
visualRowPivotRowElementThe 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.
protected virtual PivotGridSpreadExportCellElement GetExportElementForCell(int rowIndex, int columnIndex, PivotRowElement visualRow)
The zero-based row index in the export layout.
columnIndexintThe zero-based column index in the export layout.
visualRowPivotRowElementThe 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.
Creates a row-descriptor heading, using individual field names in tabular layout or a single label in compact layout.
protected virtual PivotGridSpreadExportCellElement GetRowDescriptorCell(int descriptorIndex)
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.
protected virtual PivotGridSpreadExportCellElement GetRowHeaderCell(int rowIndex, int columnIndex)
The index of the row group in the export data.
columnIndexintThe 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.
protected virtual void GetStylesFromVisualCell(PivotGridSpreadExportCellElement gridVisualElement, LightVisualElement visualCell)
The export-cell model to style.
visualCellLightVisualElementThe grid visual element whose style is copied.
Finds the row- or column-header visual element at the specified export coordinates.
protected virtual LightVisualElement GetVisualElement(int rowIndex, int columnIndex)
The zero-based row index in the export layout.
columnIndexintThe zero-based column index in the export layout.
Returns: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.
protected virtual bool HasLogoInHeaderFooterString(string s)
The string to inspect.
Returns: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.
public virtual void Initialize()
Raises the event.
protected virtual void OnAsyncExportCompleted(AsyncCompletedEventArgs e)
The AsyncCompletedEventArgs instance containing the event data.
Raises the event.
protected virtual void OnAsyncExportProgressChanged(ProgressChangedEventArgs e)
The ProgressChangedEventArgs instance containing the event data.
Raises the event.
protected virtual void OnCellFormatting(PivotGridPdfExportCellFormattingEventArgs e)
The PivotGridPdfExportCellFormattingEventArgs instance containing the event data.
Raises the event.
protected virtual void OnCellPaint(ExportCellPaintEventArgs e)
The ExportCellPaintEventArgs instance containing the event data.
Raises the event.
protected virtual void OnFooterExported(ExportEventArgs e)
The ExportEventArgs instance containing the event data.
Raises the event.
protected virtual void OnHeaderExported(ExportEventArgs e)
The ExportEventArgs instance containing the event data.
Builds export cells for each prepared row and passes each row to the PDF drawing pipeline.
protected virtual void ProcessRows()
Starts an export operation.
public void RunExport(Stream exportStream, IPdfExportRenderer pdfExportRenderer)
The stream where data will be exported.
pdfExportRendererIPdfExportRenderer.
Starts an export operation.
public void RunExport(string fileName, IPdfExportRenderer pdfExportRenderer)
The file name where data will be exported.
pdfExportRendererIPdfExportRenderer.
Starts an export operation that runs in a background thread.
public void RunExportAsync(Stream exportStream, IPdfExportRenderer exportRenderer)
The stream where data will be exported.
exportRendererIPdfExportRendererInstance of IPdfExportRenderer class.
Starts an export operation that runs in a background thread.
public void RunExportAsync(string fileName, IPdfExportRenderer exportRenderer)
The file name where data will be exported.
exportRendererIPdfExportRendererInstance of IPdfExportRenderer class.
Events
Occurs when an async export operation is completed.
public event AsyncCompletedEventHandler AsyncExportCompleted
Occurs when the progress of an async export operation changes.
public event ProgressChangedEventHandler AsyncExportProgressChanged
Occurs for every cell that is being exported.
public event PivotGridPdfExportCellFormattingEventHandler CellFormatting
Occurs when a cell is drawn.
public event ExportCellPaintEventHandler CellPaint
Occurs when the footer is exported.
public event ExportEventHandler FooterExported
Occurs when the header is exported.
public event ExportEventHandler HeaderExported
Occurs when the export process completes.
public event EventHandler PdfExported