? pdf.gif
? pdfview.image.patch
? pdfview_views.info
? pdfview_views.module
? tcpdf
Index: pdfview.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pdfview/pdfview.module,v
retrieving revision 1.37.2.3
diff -u -F^f -r1.37.2.3 pdfview.module
--- pdfview.module	27 Jan 2007 09:10:01 -0000	1.37.2.3
+++ pdfview.module	3 Feb 2007 08:15:41 -0000
@@ -40,17 +40,17 @@ function pdfview_menu($may_cache) {
  * Implementation of hook_link().
  */
 function pdfview_link($type, $node = 0, $main) {
-	$links = array();
-	if ($type == 'node' && $main == 0) {
-  	if (user_access('access content as PDF') && variable_get('pdfview_'.$node->type, 1)) {  	
-  		$links['pdfview_link'] = array(
-  		  'title' => t('Download PDF'),
-  		  'href' => "node/$node->nid/pdf",
-  		  'attributes'=> array('title' => t('Display a PDF version of this page.'))
-  		);
-		}
+  $links = array();
+  if ($type == 'node' && $main == 0) {
+    if (user_access('access content as PDF') && variable_get('pdfview_'.$node->type, 1)) {
+      $links['pdfview_link'] = array(
+        'title' => t('Download PDF'),
+        'href' => "node/$node->nid/pdf",
+        'attributes'=> array('title' => t('Display a PDF version of this page.'))
+      );
+    }
   }
-	return $links;
+  return $links;
 }
 
 /**
@@ -68,8 +68,8 @@ function pdfview_form_alter($form_id, &$
 
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
     $form['workflow']['pdfview'] = array(
-      '#type' => 'radios', 
-      '#title' => t('PDF download'), 
+      '#type' => 'radios',
+      '#title' => t('PDF download'),
       '#default_value' => variable_get('pdfview_'.$form['identity']['type']['#default_value'], 1),
       '#options' => array(t('Disabled'), t('Enabled')),
       );
@@ -97,9 +97,9 @@ function pdfview_node($node) {
   $path = drupal_get_path('module', 'pdfview');
   require_once($path . '/tcpdf/tcpdf.php');
   require_once($path . '/tcpdf/config/tcpdf_config.php');
-  
+
   $pdf = theme('pdfview_pdf');
-   
+
   if ($node->type == 'book') {
     $depth = count(book_location($node)) + 1;
     $pdf = pdfview_book_recurse($pdf, $node, $depth);
@@ -107,7 +107,7 @@ function pdfview_node($node) {
   else {
     $pdf = theme('pdfview_node', $pdf, $node);
   }
-  
+
   return $pdf;
 }
 
@@ -115,20 +115,20 @@ function pdfview_node($node) {
  * Renders a book as a PDF file.
  */
 function pdfview_book_recurse($pdf, &$node, $depth = 10) {
-  if ($node) {            
+  if ($node) {
     $pdf = theme('pdfview_node', $pdf, $node);
 
-    $children = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $node->nid);  
+    $children = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 AND b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $node->nid);
 
     while ($childpage = db_fetch_object($children)) {
       $childnode = node_load($childpage->nid);
       if ($childnode->nid != $node->nid) {
         $pdf = pdfview_book_recurse($pdf, $childnode, $depth + 1);
       }
-    }    
-  }    
+    }
+  }
   return $pdf;
-}	
+}
 
 /**
  * Outputs a PDF file.
@@ -136,7 +136,9 @@ function pdfview_book_recurse($pdf, &$no
 function pdfview_generate_file(&$pdf, $filename) {
   $filename = strtr(strip_tags($filename), " .,?!&#", "_______");
   print $pdf->Output($filename.'.pdf', 'I');
-  die();
+//  die();
+  module_invoke_all('exit');
+  exit;
 }
 
 /**
@@ -146,22 +148,22 @@ function pdfview_generate_file(&$pdf, $f
 function theme_pdfview_pdf() {
   $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
   $pdf->Open();
-  
+
   // set margins
   $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
   $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
   $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
-  
-  // set auto page breaks  
+
+  // set auto page breaks
   $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
   $pdf->AliasNbPages();
-  
+
   // set image scale factor
   $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
-  
+
   $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
   $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
-  
+
   return $pdf;
 }
 
@@ -171,14 +173,14 @@ function theme_pdfview_pdf() {
  */
 function theme_pdfview_node(&$pdf, $node) {
   $pdf->AddPage();
-  
+
   $pdf = theme('pdfview_title', $pdf, $node->title);
-  
+
   $author = strip_tags(theme('username', $node));
-  $pdf = theme('pdfview_author', $pdf, $author);  
+  $pdf = theme('pdfview_author', $pdf, $author);
 
   $pdf = theme('pdfview_published', $pdf, $node->created);
-  
+
   if (node_hook($node, 'view')) {
     node_invoke($node, 'view');
   }
@@ -191,9 +193,9 @@ function theme_pdfview_node(&$pdf, $node
   $content = pdfview_check_images($content);
   $pdf->SetFont(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN);
   $pdf = theme('pdfview_html', $pdf, $content);
-  
+
   return $pdf;
-}	
+}
 
 /**
  * Renders a title
@@ -235,7 +237,7 @@ function theme_pdfview_published(&$pdf, 
  */
 function theme_pdfview_html(&$pdf, $html) {
   foreach (explode("\n", $html) as $one) {
-    $pdf->writeHTML($one);
+    $pdf->writeHTML($one, FALSE);
   }
   return $pdf;
 }
@@ -249,9 +251,10 @@ function pdfview_check_images($string) {
 
 function _pdfview_rewrite_image_url($matches = array()) {
   $path = $matches[0];
-  $path = str_replace($GLOBALS['base_url'].'/', '', $path);
-  if (base_path() == '/' && $path[0] == '/') { 
-    $path = substr($path, 1);
+  if (base_path() == '/') {
+    if ($path[0] == '/') {
+      $path = substr($path, 1);
+    }
   }
   else {
     $path = str_replace(base_path(), '', $path);
