Troubleshooting Rupee Symbol Rendering Issues in Magento PDF Invoices
Are you facing issues where your rupee currency symbol isn’t rendering correctly on invoices generated by Magento? You’re not alone. This is a common problem that can be quite frustrating, especially when dealing with customer documents. Let’s dive into the root causes and step-by-step solutions to fix this issue.
Understanding the Problem: Encoding and Font Issues
The rupee symbol (â¹) often fails to render properly in PDFs due to two primary reasons:
- Character encoding: The PDF generator might not be using the correct character set that includes the rupee symbol.
- Font limitations: Some fonts used by Magento’s built-in PDF generation tools may not support all special characters, including the rupee sign.
Step 1: Check Your Store’s Character Set
Ensure your store is using a character set that supports the rupee symbol. Navigate to System > Configuration > General > General. Under ‘Default Configurations’, look for the ‘Current Configuration Scope’ dropdown and select your website view or default config.
In the left menu, click on ‘General’. Scroll down to find the ‘Locale Options’ section. Make sure the ‘Locale’ field is set to a region that supports rupee currency (like India).
Step 2: Modify Magento’s PDF Configuration
To resolve font issues, we need to modify some core files. This requires technical knowledge of PHP and access to your server via FTP or SSH.
- Navigate to the following file:
app/code/core/Mage/Pdf/Model/Order/Pdf/Invoice.php - Open this file in a text editor.
- Look for the line that says
$this->_setFontRegular($page, 50); - Change it to:
$this->_setFontRegular($page, 'DejaVuSansCondensed', 50);
This changes the font used from the default Magento system font to DejaVu Sans Condensed, which supports more special characters.
- Save and close the file.
- Clear your cache by navigating to
System > Cache Managementand click on “Flush Magento Cache”.
Step 3: Generate a New Invoice
After making these changes, try generating a new invoice for an order with rupee currency. The rupee symbol should now render correctly in the PDF.
Conclusion: Resolving Currency Symbol Display Issues
Remember that modifying core files is not recommended by Magento itself as it can lead to issues during updates. However, for small-scale stores or custom projects, this solution works effectively.
For larger enterprises looking for a long-term fix without modifying core code, consider using third-party PDF generation extensions like https://laravelcompany.com/products/pdf-invoice-generator. These extensions provide more advanced customization options and ensure compatibility with future Magento updates.
Always backup your data before making any changes to the core files. If you’re unsure about any of these steps, consult a professional developer or reach out to the Magento support team for guidance tailored to your specific setup.