diff --git a/modules/pdf/commerce_invoice_pdf.module b/modules/pdf/commerce_invoice_pdf.module
index 6493cad..fd48964 100644
--- a/modules/pdf/commerce_invoice_pdf.module
+++ b/modules/pdf/commerce_invoice_pdf.module
@@ -379,13 +379,7 @@ function commerce_invoice_pdf_download_invoices_submit($form, $form_state) {
 function commerce_invoice_pdf_download_invoices($invoice, $context) {
   global $user;
   $destination = $context['destination'];
-  // Switch to the default theme, in order to render the invoice properly if the
-  // admin theme was other than the default one.
-  global $theme;
-  $theme = NULL;
-  $custom_theme = &drupal_static('menu_get_custom_theme');
-  $custom_theme = variable_get('theme_default', 'bartik');
-  drupal_theme_initialize();
+  _commerce_invoice_pdf_ensure_default_theme();
   // Get the invoice file.
   if ($file = commerce_invoice_pdf_create($invoice)) {
     $zip = new ZipArchive();
@@ -419,3 +413,57 @@ function commerce_invoice_pdf_download_invoices($invoice, $context) {
     _views_bulk_operations_log(t('An archive has been created and can be downloaded from: !url', array('!url' => $url)));
   }
 }
+
+/**
+ * Switch to the default theme, in order to render the invoice properly if the
+ * admin theme was other than the default one.
+ */
+function _commerce_invoice_pdf_ensure_default_theme() {
+  global $theme;
+  $theme = NULL;
+  $custom_theme = &drupal_static('menu_get_custom_theme');
+  $custom_theme = variable_get('theme_default', 'bartik');
+  drupal_theme_initialize();
+}
+
+/**
+ * Implements hook_advanced_queue_info().
+ */
+function commerce_invoice_pdf_advanced_queue_info() {
+  $items['commerce_invoice_pdf_create_queue'] = array(
+    'label' => t('Create PDF invoices queue'),
+    'worker callback' => 'commerce_invoice_pdf_create_worker',
+    'retry after' => 30,
+    'max attempts' => 5,
+    // PDF creation is relatively slow process with a low priority
+    'weight' => -100,
+  );
+
+  return $items;
+}
+
+function commerce_invoice_pdf_create_worker($item, $end_time = FALSE) {
+  $data = $item->data;
+
+  /** @var Invoice $invoice */
+  if ($invoice = entity_load_single('commerce_invoice', $data['invoice_id'])) {
+    _commerce_invoice_pdf_ensure_default_theme();
+
+    // Make sure that any entity_access() down the line returns TRUE.
+    global $user;
+    if($user->uid !== $invoice->uid) {
+      $user = user_load($invoice->uid);
+    }
+    if (commerce_invoice_pdf_create($invoice, TRUE, $data['recreate'])) {
+      return array(
+        'status' => ADVANCEDQUEUE_STATUS_SUCCESS,
+        'result' => 'Processed ' . $item->item_id,
+      );
+    }
+  }
+
+  return array(
+    'status' => ADVANCEDQUEUE_STATUS_FAILURE,
+    'result' => 'Error processing queue item ' . $item->item_id,
+  );
+}
\ No newline at end of file
diff --git a/modules/pdf/commerce_invoice_pdf.rules.inc b/modules/pdf/commerce_invoice_pdf.rules.inc
new file mode 100644
index 0000000..0f8fb52
--- /dev/null
+++ b/modules/pdf/commerce_invoice_pdf.rules.inc
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * @file
+ * Rules integration for the Commerce Invoice PDF module.
+ */
+use Drupal\commerce_invoice\Entity\Invoice;
+
+/**
+ * Implements hook_rules_action_info().
+ */
+function commerce_invoice_pdf_rules_action_info() {
+  $actions = array();
+
+  $actions['commerce_invoice_pdf_create'] = array(
+    'base' => 'commerce_invoice_pdf_action_create',
+    'label' => t('Create a PDF'),
+    'parameter' => [
+      'invoice' => [
+        'type' => 'commerce_invoice',
+        'label' => t('Invoice'),
+      ],
+      'recreate' => [
+        'type' => 'boolean',
+        'label' => t('Recreate existing'),
+        'description' => t('Recreate (replace) the file if it already exists.'),
+        'default value' => 1,
+      ],
+    ],
+    'group' => t('Commerce Invoice'),
+  );
+
+  if (module_exists('advancedqueue')) {
+    $actions['commerce_invoice_pdf_create']['parameter']['queue'] = [
+      'type' => 'boolean',
+      'label' => t('Use Advanced Queue'),
+      'description' => t('Do not create PDF immediately. Instead, add the task to Advanced Queue.'),
+      'default value' => 1,
+      'optional' => TRUE,
+    ];
+  }
+
+  return $actions;
+}
+
+
+/**
+ * Rules action: Create a PDF file for a given invoice entity.
+ *
+ * @param Invoice $invoice
+ *   The invoice entity
+ * @param boolean $recreate
+ *   Whether to recreate (replace) the file if it already exists.
+ * @param boolean $queue
+ *   Whether to add the PDF creation into a queue or not.
+ */
+function commerce_invoice_pdf_action_create(Invoice $invoice, $recreate, $queue = FALSE) {
+  if (!$queue) {
+    _commerce_invoice_pdf_ensure_default_theme();
+    commerce_invoice_pdf_create($invoice, TRUE, $recreate);
+  }
+  else {
+    $queue = DrupalQueue::get('commerce_invoice_pdf_create_queue');
+    $task = array(
+      'invoice_id' => $invoice->invoice_id,
+      'recreate' => $recreate,
+    );
+    $queue->createItem($task);
+  }
+}
\ No newline at end of file
