New to Telerik UI for ASP.NET MVC? Start a free 30-day trial

The fluent API for configuring the grid PDF export.

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Syntax:

C#
public class PDFSettingsBuilder

Inheritance: objectPDFSettingsBuilder

Inherited Members object.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

Constructors

C#
public PDFSettingsBuilder(PDFSettings pdf)
Parameters:pdfPDFSettings

Methods

Exports all pages. Applicable only for the Grid. Ajax binding or server binding with ServerOperation(false) is required.

C#
public PDFSettingsBuilder AllPages()
Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.AllPages())
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Sets the author of the PDF document.

C#
public PDFSettingsBuilder Author(string author)
Parameters:authorstring

The author of the PDF document.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Author("John Doe"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Specifies if the Print dialog should be opened immediately after loading the document.

C#
public PDFSettingsBuilder AutoPrint(bool value)
Parameters:valuebool

The value that configures the autoprint.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.AutoPrint(false))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Does not create clickable hyperlinks in the exported PDF file.

C#
public PDFSettingsBuilder AvoidLinks()
Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.AvoidLinks())
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

A flag indicating whether to produce clickable hyperlinks in the exported PDF file.

C#
public PDFSettingsBuilder AvoidLinks(bool avoidLinks)
Parameters:avoidLinksbool

A flag indicating whether to produce actual hyperlinks in the exported PDF file.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.AvoidLinks(true))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

A CSS selector for the links to ignore. All matching links will not be clickable in the exported PDF file.

C#
public PDFSettingsBuilder AvoidLinks(string avoidLinks)
Parameters:avoidLinksstring

A CSS class parameter. All matching links will not be clickable in the exported PDF file.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.AvoidLinks("avoidLinkClass"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Sets the creator of the PDF document.

C#
public PDFSettingsBuilder Creator(string creator)
Parameters:creatorstring

The creator of the PDF document.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Creator("John Doe"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Sets the date of the PDF document.

C#
public PDFSettingsBuilder Date(DateTime date)
Parameters:dateDateTime

The date when the PDF document is created.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Date(DateTime.Now))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Sets the file name of the PDF file.

C#
public PDFSettingsBuilder FileName(string fileName)
Parameters:fileNamestring

Specifies the file name of the exported PDF file.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.FileName("Products.pdf"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Sets the author of the PDF document.

C#
public PDFSettingsBuilder ForcePageBreak(string selector)
Parameters:selectorstring

The selector which will force the pages to break in the PDF document.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.ForcePageBreak(".k-master-row:nth-child(11n)"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Forces the use of server-side proxy even if the browser supports local saving.

C#
public PDFSettingsBuilder ForceProxy(bool forceProxy)
Parameters:forceProxybool

true if the server proxy should be used always; false for automatic detection

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.ForceProxy(true))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Specifies the quality of the images within the exported file, from 0 to 1.

C#
public PDFSettingsBuilder JpegQuality(double value)
Parameters:valuedouble

The value that configures the jpegquality.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.JpegQuality(0.85))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

If set to true all PNG images contained in the exported file will be kept in PNG format.

C#
public PDFSettingsBuilder KeepPNG(bool value)
Parameters:valuebool

The value that configures the keeppng.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.KeepPNG(true))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Sets the keywords of the PDF document.

C#
public PDFSettingsBuilder Keywords(string keywords)
Parameters:keywordsstring

Specifies the keywords of the exported PDF file.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Keywords("northwind products"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Turns the page in landscape orientation.

C#
public PDFSettingsBuilder Landscape()
Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Landscape())
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Specifies the margins in "pt" units.

C#
public PDFSettingsBuilder Margin(double top, double right, double bottom, double left)
Parameters:topdouble

Specifies the top margin in "pt" units.

rightdouble

Specifies the right margin in "pt" units.

bottomdouble

Specifies the bottom margin in "pt" units.

leftdouble

Specifies the left margin in "pt" units.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Margin(10, 10, 10, 10))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Specifies the margins in units ("in", "mm", "pt", "cm")

C#
public PDFSettingsBuilder Margin(string top, string right, string bottom, string left)
Parameters:topstring

Specifies the top margin.

rightstring

Specifies the right margin.

bottomstring

Specifies the bottom margin.

leftstring

Specifies the left margin.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Margin("10in", "10mm", "10pt", "10cm"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Specifies custom paper size in "pt" units.

C#
public PDFSettingsBuilder PaperSize(double width, double height)
Parameters:widthdouble

Specifies the width size of the PDF in "pt" units.

heightdouble

Specifies the height size of the PDF in "pt" units.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.PaperSize(20, 20))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Specifies custom paper size in custom units ("in", "mm", "pt", "cm")

C#
public PDFSettingsBuilder PaperSize(string width, string height)
Parameters:widthstring

Specifies the width size of the PDF.

heightstring

Specifies the height size of the PDF.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.PaperSize("15pt", "20cm"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Specifies a predefiend paper size e.g. "A3", "A4" or "auto" (default).

C#
public PDFSettingsBuilder PaperSize(string paperSize)
Parameters:paperSizestring

Specifies the paper size.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.PaperSize("A3"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Set the a name or keyword indicating where to display the document returned from the proxy. The default is "_self".

C#
public PDFSettingsBuilder ProxyTarget(string target)
Parameters:targetstring

The proxy target

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.ProxyTarget("_blank"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Set the url of the server side proxy. The proxy is responsible for returning the PDF to the end user. Used in browsers that don't support saving files from JavaScript.

C#
public PDFSettingsBuilder ProxyURL(string url)
Parameters:urlstring

The URL of the server side proxy which will stream the file to the end user.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.ProxyURL("/save"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Set this to true to repeat the grid headers on each page.

C#
public PDFSettingsBuilder RepeatHeaders()
Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.RepeatHeaders())
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Set this to true to repeat the grid headers on each page.

C#
public PDFSettingsBuilder RepeatHeaders(bool value)
Parameters:valuebool

The value for RepeatHeaders

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.RepeatHeaders(true))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

A scale factor. In many cases, text size on screen will be too big for print, so you can use this option to scale down the output in PDF.

C#
public PDFSettingsBuilder Scale(double scale)
Parameters:scaledouble

The value for the scale factor.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Scale(1))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)

Sets the subject of the PDF document.

C#
public PDFSettingsBuilder Subject(string subject)
Parameters:subjectstring

The subject value of the PDF file.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid<OrderViewModel>()
.Name("grid")
.ToolBar(t => t.Pdf())
.Pdf(pdf => pdf.Subject("Products"))
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(false);
columns.Bound(p => p.Freight);
})
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)
C#
public PDFSettingsBuilder Template(string value)
Parameters:valuestringReturns:

PDFSettingsBuilder

A piece of HTML to be included in each page. Can be used to display headers and footers. See the documentation in drawDOM.

C#
public PDFSettingsBuilder Template<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

A Template component that configures the template.

Returns:

PDFSettingsBuilder

C#
public PDFSettingsBuilder TemplateHandler(string value)
Parameters:valuestringReturns:

PDFSettingsBuilder

A piece of HTML to be included in each page. Can be used to display headers and footers. See the documentation in drawDOM.

C#
public PDFSettingsBuilder TemplateId(string templateId)
Parameters:templateIdstring

The ID of the template element for Template

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid&lt;OrderViewModel&gt;()
.Name("grid")
.ToolBar(t =&gt; t.Pdf())
.Pdf(pdf =&gt; pdf.TemplateId("page-template").AllPages().PaperSize("A3"))
.Columns(columns =&gt;
{
columns.Bound(p =&gt; p.OrderID).Filterable(false);
columns.Bound(p =&gt; p.Freight);
})
.Scrollable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.PageSize(20)
.Read(read =&gt; read.Action("Orders_Read", "Grid"))
)
)

A piece of HTML to be included in each page. Can be used to display headers and footers. See the documentation in drawDOM.

C#
public PDFSettingsBuilder TemplateView(MvcHtmlString templateView)
Parameters:templateViewMvcHtmlString

The view that contains Template

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid&lt;OrderViewModel&gt;()
.Name("grid")
.ToolBar(t =&gt; t.Pdf())
.Pdf(pdf =&gt; pdf.TemplateView(Html.Partial("page-template")).AllPages().PaperSize("A3"))
.Columns(columns =&gt;
{
columns.Bound(p =&gt; p.OrderID).Filterable(false);
columns.Bound(p =&gt; p.Freight);
})
.Scrollable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.PageSize(20)
.Read(read =&gt; read.Action("Orders_Read", "Grid"))
)
)

Sets the title of the PDF document.

C#
public PDFSettingsBuilder Title(string title)
Parameters:titlestring

The title of the PDF file.

Returns:

PDFSettingsBuilder

Example:
C#
@(Html.Kendo().Grid&lt;OrderViewModel&gt;()
.Name("grid")
.ToolBar(t =&gt; t.Pdf())
.Pdf(pdf =&gt; pdf.Title("Orders"))
.Columns(columns =&gt;
{
columns.Bound(p =&gt; p.OrderID).Filterable(false);
columns.Bound(p =&gt; p.Freight);
})
.Scrollable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.PageSize(20)
.Read(read =&gt; read.Action("Orders_Read", "Grid"))
)
)