diff --git a/fillpdf.module b/fillpdf.module
index 4eb928be57fc668ab3a92da1f68902632f98be96..f1b59f867873113031c6a5e32c2400c09e2f43aa 100644
--- a/fillpdf.module
+++ b/fillpdf.module
@@ -619,7 +619,9 @@ function fillpdf_save_to_file($pdf_info, $pdf_data, $token_objects, $output_name
  * Set up the data then invoke the Rules event.
  */
 function fillpdf_fillpdf_merge_pre_handle($fillpdf) {
-  rules_invoke_event('fillpdf_merge_pre_handle', $fillpdf);
+  if (module_exists('rules')) {
+    rules_invoke_event('fillpdf_merge_pre_handle', $fillpdf);
+  }
 }
 
 /**