'PDF', ); } /** * Implementation of hook_export_format(); * TODO: translation */ function export_pdf_export_format($data, $title = ''){ $output = ''; $attributes = array(); if ($border = variable_get('export_pdf_border', 0)) { $attributes['border'] = $border; $attributes['bordercolor'] = variable_get('export_pdf_border_color', '#000000'); } $filename = strlen($title) ? table_export_clean($title).'.pdf' : 'table-export.pdf' ; $data = table_export_format_table_simple($data); $full_width = variable_get('export_pdf_full_width', FALSE); // convert to format pdf if ($full_width) { $attributes['width'] = '100%'; } $output .= theme('table_export_table', $data['header'], $data['rows'], $attributes, NULL, FALSE); $orientation = variable_get('export_pdf_orientation', 'p'); $format = variable_get('export_pdf_format', 'a4'); $unit = variable_get('export_pdf_unit', 'mm'); $pdf = new HTML2FPDF($orientation, $unit, $format); $pdf->AddPage(); $pdf->WriteHTML($output); $pdf->Output($filename, 'D'); exit(); } /** * Implementation of hook_export_format_settings(); */ function export_pdf_export_format_settings(){ $form['export_pdf_full_width'] = array( '#type' => 'checkbox', '#title' => t('Full Width'), '#description' => t('When TRUE the PDF table output will fill the entire document.'), '#default_value' => variable_get('export_pdf_full_width', FALSE), ); $form['border']['export_pdf_border'] = array( '#type' => 'textfield', '#title' => t('Border width'), '#description' => t('The width of the border in px. Leave 0 for no border.'), '#default_value' => variable_get('export_pdf_border', 0), ); $form['border']['export_pdf_border_color'] = array( '#type' => 'textfield', '#title' => t('Border color'), '#description' => t('Color is only be used when the border width is set.'), '#default_value' => variable_get('export_pdf_border_color', '#000000'), ); $form['export_pdf_orientation'] = array( '#type' => 'select', '#title' => t('Orientation'), '#default_value' => variable_get('export_pdf_orientation', 'p'), '#options' => array('p' => 'Portrait', 'l' => 'Landscape'), ); $form['export_pdf_format'] = array( '#type' => 'select', '#title' => t('Format'), '#default_value' => variable_get('export_pdf_format', 'a4'), '#options' => array('a3' => 'A3', 'a4' => 'A4', 'a5' => 'A5', 'letter' => 'Letter', 'legal' => 'Legal'), ); $form['export_pdf_unit'] = array( '#type' => 'select', '#title' => t('Unit'), '#default_value' => variable_get('export_pdf_unit', 'mm'), '#options' => array('in' => 'inch', 'mm' => 'mm', 'cm' => 'cm'), ); return $form; }