Project

General

Profile

Paste
Download (2.41 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / print / print_pdf / lib_handlers / print_pdf_tcpdf / print_pdf_tcpdf.admin.inc @ 76bdcd04

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains the administrative functions of the print_pdf_tcpdf sub-module.
6
 *
7
 * This file is included by the print_pdf_tcpdf module, and includes the
8
 * settings form.
9
 *
10
 * @ingroup print
11
 */
12

    
13
/**
14
 * Form constructor for the TCPDF options settings form.
15
 *
16
 * @ingroup forms
17
 */
18
function print_pdf_tcpdf_settings() {
19
  $form['settings'] = array(
20
    '#type' => 'fieldset',
21
    '#title' => t('TCPDF options'),
22
  );
23

    
24
  $form['settings']['print_pdf_font_family'] = array(
25
    '#type' => 'textfield',
26
    '#title' => t('Font family'),
27
    '#default_value' => variable_get('print_pdf_font_family', PRINT_PDF_TCPDF_FONT_FAMILY_DEFAULT),
28
    '#size' => 60,
29
    '#maxlength' => 250,
30
    '#description' => t('Set the font family to be used. Examples: %examples.', array('%examples' => 'helvetica, times, courier, dejavusans, dejavuserif, freesans, freeserif, freemono')) . '<br />' .
31
      t("CAUTION: TCPDF embeds the complete font in the generated PDF. If you're not using Unicode, then helvetica or times are safe choices that will keep the PDF small. Unicode fonts can increase the size of the PDF to the 1MB region."),
32
  );
33
  $form['settings']['print_pdf_font_size'] = array(
34
    '#type' => 'textfield',
35
    '#title' => t('Font size'),
36
    '#default_value' => variable_get('print_pdf_font_size', PRINT_PDF_TCPDF_FONT_SIZE_DEFAULT),
37
    '#size' => 2,
38
    '#maxlength' => 3,
39
    '#description' => t('Set the font size to be used for normal text. This is the base value for the scaling applied to other text styles.'),
40
  );
41
  $form['settings']['print_pdf_font_subsetting'] = array(
42
    '#type' => 'checkbox',
43
    '#title' => t('Enable font subsetting'),
44
    '#default_value' => variable_get('print_pdf_font_subsetting', PRINT_PDF_TCPDF_FONT_SUBSETTING_DEFAULT),
45
    '#description' => t('Only embed those font characters that are actually used.  This can generates smaller PDF files but may significantly slow down processing.'),
46
  );
47

    
48
  $form['#validate'][] = '_print_pdf_tcpdf_settings_validate';
49

    
50
  return system_settings_form($form);
51
}
52

    
53
/**
54
 * Form validation handler for print_pdf_tcpdf_settings().
55
 *
56
 * @param array $form
57
 *   Form.
58
 * @param array $form_state
59
 *   Form state.
60
 *
61
 * @see print_pdf_tcpdf_settings()
62
 * @ingroup forms
63
 */
64
function _print_pdf_tcpdf_settings_validate($form, &$form_state) {
65
  if ($form_state['values']['print_pdf_font_size'] < 1) {
66
    form_set_error('print_pdf_font_size', t("Font size must be at least 1."));
67
  }
68
}