the first digit is cancelled and the currency symbol isn't showing. how can i resolve this issues
Magento – currency symbol not showing in pdf invoice
invoicemagento-1.9pdf
Related Solutions
For this answer: Adding new fonts to Pdf invoice Magento 2?, we can follow
app/code/Vendor/PdfFont/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Sales\Model\Order\Pdf\AbstractPdf">
<plugin name="add_font_to_pdf" type="Vendor\PdfFont\Plugin\AddFontToPdf" sortOrder="10" disabled="false"/>
</type>
</config>
app/code/Vendor/PdfFont/Plugin/AddFontToPdf.php
<?php
namespace RoyalCopenhagen\PdfFont\Plugin;
use Magento\Framework\App\Filesystem\DirectoryList;
class AddFontToPdf
{
/**
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
*/
protected $_rootDirectory;
/**
* AddFontToPdf constructor.
* @param \Magento\Framework\Filesystem $filesystem
*/
public function __construct(
\Magento\Framework\Filesystem $filesystem
)
{
$this->_rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
}
public function beforeDrawLineBlocks($subject, $page, array $draw, array $pageSettings = [])
{
foreach ($draw as $key => $values) {
if(isset($values['lines'])) {
$lines = $values['lines'];
foreach ($lines as $k => $v) {
foreach ($v as $k1 => $v1) {
$v[$k1]['font_file'] = $this->_rootDirectory->getAbsolutePath('lib/internal/Meiryo/Meiryo.ttf');
$lines[$k][$k1] = $v[$k1];
}
}
$draw[$key]['lines'] = $lines;
}
}
// Update the $draw array to add your font
return [$page, $draw, $pageSettings];
}
}
We need to get the font from: $this->_rootDirectory->getAbsolutePath('lib/internal/Meiryo/Meiryo.ttf')
.
However, this way is for drawing item, not for shipping address info. Because the shipping address part used the protected functions to set font style.
vendor/magento/module-sales/Model/Order/Pdf/AbstractPdf.php
protected function _setFontRegular()
protected function _setFontBold()
protected function _setFontItalic()
You need to change how the currency is being displayed in your local.
Goto this file: root/lib/Zend/Locale/Data/en.xml (For English Language)
The above file shows how the currency is being displayed in English. If you want the same format in Arabic then open ar.xml file in the same folder and copy paste whatever is there between the currencyFormat tags from en.xml to ar.xml
Copy the contents of currentFormat tags from English to Arabic. I had the same issue. The currency symbol wouldn't show up in the Arabic locale. The above steps fixed it.
Best Answer
Make sure the Symbol is part of the font you are using.