From d7d5cb5360ee409af92126187cc66b2a5af48a26 Mon Sep 17 00:00:00 2001
From: Aron Novak <aaron@szentimre.hu>
Date: Wed, 2 Mar 2011 17:18:51 +0100
Subject: [PATCH] better API, allows saving file to disk

---
 dompdf.module |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dompdf.module b/dompdf.module
index 5494e9c..3bf2e50 100644
--- a/dompdf.module
+++ b/dompdf.module
@@ -6,7 +6,7 @@
  * @param $html
  *   HTML to use to render the PDF
  * @param $filename
- *   The desired filename for the streamed PDF
+ *   The desired filename for the streamed PDF. If not specified, the generated PDF is returned
  * @param $directives
  *   An optional array of directives to run on the DOMPDF object before streaming it to the browser.
  *   Possible directives are: set_base_path, set_host, set_paper, set_protocol
@@ -22,7 +22,7 @@
  *   );
  * ?>
  */
-function dompdf_stream_pdf($html, $filename, $directives = array()) {
+function dompdf_stream_pdf($html, $filename = '', $directives = array()) {
   require_once drupal_get_path('module', 'dompdf') . '/dompdf/dompdf_config.inc.php';
   $allowed_directives = array(
     'set_base_path', 
@@ -41,8 +41,13 @@ function dompdf_stream_pdf($html, $filename, $directives = array()) {
   }
   
   $dompdf->render();
+  if (empty($filename)) {
+    return $dompdf->output();
+  }
+  else {
   $dompdf->stream($filename);
 }
+}
 
 
 /**
-- 
1.7.4.1

