print_pdf_tcpdf.admin.inc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @file
  4. * Contains the administrative functions of the print_pdf_tcpdf sub-module.
  5. *
  6. * This file is included by the print_pdf_tcpdf module, and includes the
  7. * settings form.
  8. *
  9. * @ingroup print
  10. */
  11. /**
  12. * Form constructor for the TCPDF options settings form.
  13. *
  14. * @ingroup forms
  15. */
  16. function print_pdf_tcpdf_settings() {
  17. $form['settings'] = array(
  18. '#type' => 'fieldset',
  19. '#title' => t('TCPDF options'),
  20. );
  21. $form['settings']['print_pdf_font_family'] = array(
  22. '#type' => 'textfield',
  23. '#title' => t('Font family'),
  24. '#default_value' => variable_get('print_pdf_font_family', PRINT_PDF_TCPDF_FONT_FAMILY_DEFAULT),
  25. '#size' => 60,
  26. '#maxlength' => 250,
  27. '#description' => t('Set the font family to be used. Examples: %examples.', array('%examples' => 'helvetica, times, courier, dejavusans, dejavuserif, freesans, freeserif, freemono')) . '<br />' .
  28. 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."),
  29. );
  30. $form['settings']['print_pdf_font_size'] = array(
  31. '#type' => 'textfield',
  32. '#title' => t('Font size'),
  33. '#default_value' => variable_get('print_pdf_font_size', PRINT_PDF_TCPDF_FONT_SIZE_DEFAULT),
  34. '#size' => 2,
  35. '#maxlength' => 3,
  36. '#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.'),
  37. );
  38. $form['settings']['print_pdf_font_subsetting'] = array(
  39. '#type' => 'checkbox',
  40. '#title' => t('Enable font subsetting'),
  41. '#default_value' => variable_get('print_pdf_font_subsetting', PRINT_PDF_TCPDF_FONT_SUBSETTING_DEFAULT),
  42. '#description' => t('Only embed those font characters that are actually used. This can generates smaller PDF files but may significantly slow down processing.'),
  43. );
  44. $form['#validate'][] = '_print_pdf_tcpdf_settings_validate';
  45. return system_settings_form($form);
  46. }
  47. /**
  48. * Form validation handler for print_pdf_tcpdf_settings().
  49. *
  50. * @param array $form
  51. * Form.
  52. * @param array $form_state
  53. * Form state.
  54. *
  55. * @see print_pdf_tcpdf_settings()
  56. * @ingroup forms
  57. */
  58. function _print_pdf_tcpdf_settings_validate($form, &$form_state) {
  59. if ($form_state['values']['print_pdf_font_size'] < 1) {
  60. form_set_error('print_pdf_font_size', t("Font size must be at least 1."));
  61. }
  62. }