pdf

Since: Buttons 1.0.0

Create and save a PDF file that contains the data from the table. Please note - this property requires the Buttons extension for DataTables.

Description

This button type serves as a proxy that will automatically detect if the pdfHtml5 or pdfFlash buttons can be used based on the browser's capabilities and the libraries available on the page.

This is provided as an option since the HTML5 button type requires a reasonably modern browser which may not always be available to the end user.

The order of selection, in priority order is:

If the requirements of both buttons are not satisfied, no button will be presented to the end user. For the requirements of each button type, please refer to its own documentation.

The options available to the HTML5 and Flash buttons are common between them to ensure that no additional logic is required by the developer based on which button type is selected - e.g. if you set the message option, it will be used by the HTML5 and Flash button types. The sole exception to this is the customize option which can be used for HTML5 buttons only. It will be ignored by the Flash PDF generator.

Options

This button can have the following options set in its configuration object to customise its actions and display:

Examples

DataTables initialisation: Use the pdf button type to automatically select between the Flash and HTML button options.:

$('#myTable').DataTable( {
	buttons: [
		'pdf'
	]
} );

DataTables initialisation: Use the exportOptions to save only the data shown on the current DataTable page:

$('#myTable').DataTable( {
	buttons: [
		{
			extend: 'pdf',
			text: 'Save current page',
			exportOptions: {
				modifier: {
					page: 'current'
				}
			}
		}
	]
} );