summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INSTALL.txt21
-rw-r--r--lib/README.txt4
-rw-r--r--print_pdf/print_pdf.admin.inc13
-rw-r--r--print_pdf/print_pdf.install2
-rw-r--r--print_pdf/print_pdf.module3
-rw-r--r--print_pdf/print_pdf.pages.inc13
6 files changed, 45 insertions, 11 deletions
diff --git a/INSTALL.txt b/INSTALL.txt
index f26d0bb..335b35e 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -25,7 +25,7 @@ dompdf support:
1. Download dompdf from http://sourceforge.net/projects/dompdf/
2. Extract the contents of the downloaded package into the print module
- directory (usually sites/all/modules/print)
+ directory (usually sites/all/modules/print/lib)
3. Check if dompdf_config.inc.php fits your installation. In 99% of cases,
no changes are necessary, so just try to use it and only edit anything if
the PDF generation fails.
@@ -42,10 +42,25 @@ TCPDF support:
1. Download TCPDF from http://sourceforge.net/projects/tcpdf/
2. Extract the contents of the downloaded package into the print module
- directory (usually sites/all/modules/print). There is no need to modify
- the config/tcpdf_config.php file, as the module self-configures TCPDF.
+ directory (usually sites/all/modules/print/lib). There is no need to
+ modify the config/tcpdf_config.php file, as the module self-configures
+ TCPDF.
3. Check http://tcpdf.sourceforge.net/ for further information.
+wkhtmltopdf support:
+
+ 1. Download wkhtmltopdf from
+ http://code.google.com/p/wkhtmltopdf/downloads/list. You can choose to
+ download the source and compile it or simply download the static binary,
+ which doesn't require you to complile anything.
+ 2. Place the wkhtmltopdf executable into the print module directory
+ (usually sites/all/modules/print/lib). You can also place a symbolic link
+ to the executable.
+ 3. You will need a running X Server or the virtual (headless) X
+ framebuffer server: Xvfb. Place the Xvfb binary or a symbolic link to it
+ in the print module directory (usually sites/all/modules/print/lib).
+ 4. Check http://code.google.com/p/wkhtmltopdf/ for further information.
+
UPDATE
------
diff --git a/lib/README.txt b/lib/README.txt
new file mode 100644
index 0000000..2ce3f94
--- /dev/null
+++ b/lib/README.txt
@@ -0,0 +1,4 @@
+// $Id$
+
+This directory should be used to place the downloaded external libs used by
+the print module (such as TCPDF, dompdf, etc.).
diff --git a/print_pdf/print_pdf.admin.inc b/print_pdf/print_pdf.admin.inc
index c88fd6e..bb564bf 100644
--- a/print_pdf/print_pdf.admin.inc
+++ b/print_pdf/print_pdf.admin.inc
@@ -181,6 +181,19 @@ function print_pdf_settings() {
'#maxlength' => 3,
'#description' => t('(TCPDF only) Set the font size to be used for normal text. This is the base value for the scaling applied to other text styles.'),
);
+ $form['settings']['print_pdf_wkhtmltopdf_options'] = array(
+ '#type' => 'textfield',
+ '#title' => t('wkhtmltopdf options'),
+ '#default_value' => variable_get('print_pdf_wkhtmltopdf_options', PRINT_PDF_WKHTMLTOPDF_OPTIONS),
+ '#description' => t('(wkhtmltopdf only) Set any additional options to be passed to the wkhtmltopdf executable.'),
+ );
+ $form['settings']['print_pdf_xvfb_options'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Xvfb options'),
+ '#default_value' => variable_get('print_pdf_xvfb_options', PRINT_PDF_XVFB_OPTIONS),
+ '#description' => t('(wkhtmltopdf only) Set any additional options to be passed to the Xvfb executable.'),
+ );
+
if (module_exists('token')) {
$form['settings']['print_pdf_filename'] = array(
'#type' => 'textfield',
diff --git a/print_pdf/print_pdf.install b/print_pdf/print_pdf.install
index 6812630..a38c3ed 100644
--- a/print_pdf/print_pdf.install
+++ b/print_pdf/print_pdf.install
@@ -71,6 +71,8 @@ function print_pdf_uninstall() {
variable_del('print_pdf_link_use_alias');
variable_del('print_pdf_filename');
variable_del('print_pdf_wkhtmltopdf_xdisplay');
+ variable_del('print_pdf_wkhtmltopdf_options');
+ variable_del('print_pdf_xvfb_options');
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_pdf\_display\_%'");
while ($variable = db_fetch_object($settings)) {
variable_del($variable->name);
diff --git a/print_pdf/print_pdf.module b/print_pdf/print_pdf.module
index b018432..54c3754 100644
--- a/print_pdf/print_pdf.module
+++ b/print_pdf/print_pdf.module
@@ -29,6 +29,9 @@ define('PRINT_PDF_PAGE_ORIENTATION_DEFAULT', 'portrait');
define('PRINT_PDF_FONT_FAMILY_DEFAULT', 'dejavusans');
define('PRINT_PDF_FONT_SIZE_DEFAULT', 10);
define('PRINT_PDF_FILENAME_DEFAULT', '[site-name] - [title] - [mod-yyyy]-[mod-mm]-[mod-dd]');
+define('PRINT_PDF_WKHTMLTOPDF_OPTIONS', "--footer-font-size 7 --footer-right '[page]'");
+define('PRINT_PDF_XVFB_OPTIONS', '');
+// define('PRINT_PDF_XVFB_OPTIONS', ' -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/');
/**
* Implementation of hook_menu().
diff --git a/print_pdf/print_pdf.pages.inc b/print_pdf/print_pdf.pages.inc
index 9c3a522..ed5f8ee 100644
--- a/print_pdf/print_pdf.pages.inc
+++ b/print_pdf/print_pdf.pages.inc
@@ -250,12 +250,11 @@ function _print_pdf_wkhtmltopdf($print, $html, $filename) {
$print_pdf_paper_size = drupal_strtolower(variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT));
$print_pdf_page_orientation = variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT);
$print_pdf_content_disposition = variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT);
+ $print_pdf_wkhtmltopdf_options = variable_get('print_pdf_wkhtmltopdf_options', PRINT_PDF_WKHTMLTOPDF_OPTIONS);
+ $print_pdf_xvfb_options = variable_get('print_pdf_xvfb_options', PRINT_PDF_XVFB_OPTIONS);
$xvfb_binary = key(file_scan_directory(drupal_get_path('module', 'print'), '^Xvfb$'));
-
- define('WKHTMLTOPDF_DPI', '96');
- define('WKHTMLTOPDF_OPTIONS', " --footer-font-size 7 --footer-right '[page]'");
-// define('WKHTMLTOPDF_XVFB_OPTIONS', ' -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/');
+ $dpi = 96;
// If available, launch a temporary X server
if (isset($xvfb_binary)) {
@@ -263,16 +262,14 @@ function _print_pdf_wkhtmltopdf($print, $html, $filename) {
variable_set('print_pdf_wkhtmltopdf_xdisplay', ($xdisplay == 4990) ? 10 : $xdisplay + 10);
$xdisplay += mt_rand(0, 9);
- $xcmd = realpath($xvfb_binary) ." :$xdisplay -screen 0 320x200x24 -dpi ". WKHTMLTOPDF_DPI .
- ' -terminate -nolisten tcp -tst'. (defined('WKHTMLTOPDF_XVFB_OPTIONS') ? WKHTMLTOPDF_XVFB_OPTIONS : '');
+ $xcmd = realpath($xvfb_binary) ." :$xdisplay -screen 0 320x200x24 -dpi $dpi -terminate -nolisten tcp -tst $print_pdf_xvfb_options";
$xdescriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
$xprocess = proc_open($xcmd, $xdescriptor, $xpipes, NULL, NULL);
}
$descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
- $cmd = realpath($print_pdf_pdf_tool) ." --page-size $print_pdf_paper_size --orientation $print_pdf_page_orientation".
- ' --dpi '. WKHTMLTOPDF_DPI . (defined('WKHTMLTOPDF_OPTIONS') ? WKHTMLTOPDF_OPTIONS : '') .' - -';
+ $cmd = realpath($print_pdf_pdf_tool) ." --page-size $print_pdf_paper_size --orientation $print_pdf_page_orientation --dpi $dpi $print_pdf_wkhtmltopdf_options - -";
$process = proc_open($cmd, $descriptor, $pipes, NULL, isset($xvfb_binary) ? array('DISPLAY' => ':'. $xdisplay) : NULL);