Pdf is generated but it's empty in email.

WooCommerce
January 08, 2026 15:09:03
Topics: 1
Messages: 1
Hello,
i have a problem.

E2Pdf template generates and attaches to WooCommerce email successfully, but the PDF is **empty** (4142 bytes - blank PDF). When manually generating the same PDF from WooCommerce admin, it works correctly with content.

**Issue**: Custom shortcode `[greeting_card field="html"]` in template Value field is never being processed during email generation, while `[greeting_card field="font_e2pdf"]` in Actions is being called 6 times.

---

## E2Pdf Template Configuration

### Template Details
- **Template ID**: 2
- **Template Name**: "greeting"
- **Extension**: WooCommerce
- **Item**: shop_order
- **Format**: PDF
- **Activated**: Yes

### Template Element Configuration

**Element with Greeting Text:**
- **Type**: HTML element
- **Value**: `[greeting_card field="html"]`
- **HTML Worker**: v2
- **Disable WYSIWYG Editor**: No (checkbox unchecked)

**Actions Configuration:**

**Action 0:**
- **Sort**: 0
- **Action**: Hide Element
- **Apply If**: Any
- **If**: `[greeting_card field="font_e2pdf"]`
- **Condition**: != (not equal)
- **Value**: Bad Script Regular

**Action 1:**
- **Sort**: 1
- **Action**: Show Element
- **Apply If**: Any
- **Else**: - (dropdown)
- **If**: `[greeting_card field="font_e2pdf"]`
- **Condition**: = (equal)
- **Value**: Bad Script Regular

---

## WooCommerce Settings (E2Pdf → Settings → WooCommerce Tab)

### User Order List
- **Template**: --- Select --- (not set)
- **Order Status**: Pending payment ☐, Processing ☐, On hold ☐, Completed ☐, Cancelled ☐, Refunded ☐, Failed ☐, Draft ☐, Any ✓
- **Priority**: 10

### User Order Details
- **Template**: --- Select --- (not set)
- **Order Status**: Pending payment ☐, Processing ☐, On hold ☐, Completed ☐, Cancelled ☐, Refunded ☐, Failed ☐, Draft ☐, Any ✓
- **Hook**: woocommerce_order_details_before_order_table
- **Priority**: 10

### User Cart
- **Template**: --- Select --- (not set)
- **Priority**: 10

### User Checkout
- **Template**: --- Select --- (not set)
- **Hook**: woocommerce_review_order_before_submit
- **Priority**: 10

### Admin Order List
- **Template**: greeting
- **Hook**: woocommerce_admin_order_actions_end
- **Order Status**: Pending payment ☐, Processing ☐, On hold ☐, Completed ✓, Cancelled ☐, Refunded ☐, Failed ☐, Draft ☐, Any ✓
- **Priority**: 10

### Admin Order Details
- **Template**: greeting
- **Order Status**: Pending payment ☐, Processing ☐, On hold ☐, Completed ✓, Cancelled ☐, Refunded ☐, Failed ☐, Draft ☐, Any ✓

---

## Shortcode Used in Template

### Shortcode Name
`[greeting_card]`

This is a custom shortcode registered in our WordPress installation that retrieves greeting card data from WooCommerce order item meta.

### Parameters
- `field="html"` - Should return greeting text content
- `field="font_e2pdf"` - Should return font name for the greeting text

### Data Source
WooCommerce order item meta data with keys:
- **Text keys**: `Grußtext`, `greeting_text`, `_greeting_text`, `text`, `_text`
- **Font keys**: `font_e2pdf`, `_font_e2pdf`, `greeting_font`, `_greeting_font`

### Test with Standard E2Pdf Shortcodes
We have also tried replacing `[greeting_card field="html"]` with standard E2Pdf WooCommerce shortcodes:
```
[e2pdf-wc-product key="get_meta" meta_key="text" order="true"]
```

**Result**: Same issue - element Value is not being processed when generated via email.

---

## WooCommerce Configuration

### HPOS Status
- **Enabled**: Yes
- **Storage**: Custom Order Tables (not WordPress posts)
- Orders are stored in WooCommerce custom tables, NOT wp_posts

### Email Template
- **Email ID**: customer_processing_order
- **Template File**: customer-processing-order.php
- **Location**: /themes/hello-elementor/woocommerce/emails/

### PDF Attachment Method
We are using the E2Pdf shortcode to generate and attach PDF to emails:

```
[e2pdf-attachment id="2" apply="true" filter="true"]
```

This shortcode is processed via WordPress `do_shortcode()` function in the `woocommerce_email_attachments` filter hook.

---

## Test Data

### Test Order
- **Order ID**: 8130
- **Order Status**: Processing
- **Product**: Greeting card product

### Order Item Meta Data
```
Greeting Text: "This is the last test of this. Should be Druckbrief."
Greeting Font: "druckdrief"
```

### Meta Keys Present
- `text` or `Grußtext`: Contains greeting text
- `font_e2pdf`: Contains "druckdrief"

---

## Observed Behavior

### What Works ✓

1. **PDF generation**: PDF file is created successfully and attached to WooCommerce email

2. **Manual PDF generation**: When generating PDF manually from WooCommerce admin order page (using the E2Pdf button next to the order), the PDF contains **correct content** with greeting text

3. **Shortcode in Actions**: The shortcode `[greeting_card field="font_e2pdf"]` in the Actions (If condition) appears to be processed

### What Doesn't Work ✗

1. **PDF content is empty when generated via email**: PDF file is created but contains no content (approximately 4KB - empty PDF structure)

2. **Element Value field not processed**: The element containing `[greeting_card field="html"]` in the Value field appears to not be rendered at all when PDF is generated automatically via email

3. **Different behavior between manual and automatic generation**:
- **Manual** (from WooCommerce admin): PDF contains greeting text ✓
- **Automatic** (via email hook): PDF is empty ✗

---

## Suspected Issue

We suspect that the **Actions** (Hide Element/Show Element) configuration may be preventing the element's Value field from being processed during email generation.

### Actions Logic

The element has Actions configured as:
```
Action 0: IF [greeting_card field="font_e2pdf"] != "Bad Script Regular" THEN Hide Element
Action 1: ELSE Show Element
```

Since the actual font value is "druckdrief" (not "Bad Script Regular"), the condition in Action 0 is true, which hides the element.

### Possible Problem

If Actions are evaluated **before** the Value field is processed, the element gets hidden and its Value `[greeting_card field="html"]` never gets rendered, resulting in an empty PDF.

However, when generating manually from admin, the Actions may work differently or in a different order, allowing the Value to be processed correctly.

---

## Questions for E2Pdf Support

1. **Why different behavior?** Why does manual PDF generation from WooCommerce admin work correctly with content, but automatic generation via email hook produces empty PDF?

2. **Order of operations**: When are Actions evaluated relative to Value field rendering? Are Actions processed before or after the element's Value field?

3. **Actions and Value rendering**: If an element is hidden by Actions, is its Value field still processed, or is it skipped entirely?

4. **Alternative approach**: What is the recommended way to conditionally show/hide elements based on dynamic data without preventing Value from being rendered?

5. **HPOS compatibility**: Is E2Pdf fully compatible with WooCommerce HPOS (Custom Order Tables)? We noticed orders are stored in custom tables, not wp_posts.

6. **Email generation context**: Is there anything special that needs to be configured for PDF generation via WooCommerce email hooks vs manual generation?

---

## Desired Outcome

PDF should contain the greeting text from order meta when automatically generated and attached to WooCommerce "Customer Processing Order" email.

**Expected content**: "This is the last test of this. Should be Druckbrief."
**Current content**: Empty/blank

---

## Screenshots Referenced

We have screenshots showing:
1. E2Pdf template element configuration with Value: `[greeting_card field="html"]`
2. Actions configuration (Hide/Show based on font)
3. E2Pdf WooCommerce settings tab

---

## Expected Support Response

We need guidance on:

1. **Why manual vs automatic generation behaves differently** - same template, same data, different results
2. **How to configure Actions** so they don't prevent element Value from being rendered
3. **Order of operations** - when are Actions evaluated vs when is Value field processed
4. **Best practices** for conditional element rendering in email generation context
5. **HPOS compatibility** - any known issues or special configuration needed

---

## Contact Information

**Site URL**: https://michaelk570.sg-host.com
**WP Admin**: Available upon request
**E2Pdf Template ID**: 2
**Test Order ID**: 8130

---

## Summary for Quick Review

**Working:**
- ✓ PDF generates and attaches to email successfully
- ✓ Manual PDF generation from admin works correctly with content

**Not Working:**
- ✗ Automatic PDF generation via email produces empty PDF (no content)
- ✗ Element with Value `[greeting_card field="html"]` not being rendered during email generation

**Key Question:**
Why does the same E2Pdf template work correctly when generated manually from admin, but produces empty PDF when generated automatically via WooCommerce email hook?

---

Thank you for your support!
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.