I am trying to put the store address to the shipment pdf. I found that Magento has an own function for address insertion, but it doesn't work.
Sales/Model/Order/Shipment.php
public function getPdf($shipments = [])
{
...
$this->insertAddress($page, $shipment->getStore());
Sales/Model/Order/AbstractPdf.php
protected function insertAddress(&$page, $store = null)
{
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
$font = $this->_setFontRegular($page, 10);
$page->setLineWidth(0);
$this->y = $this->y ? $this->y : 815;
$top = 815;
foreach (explode(
"\n",
$this->_scopeConfig->getValue(
'sales/identity/address',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$store
)
) as $value) {
if ($value !== '') {
$value = preg_replace('/<br[^>]*>/i', "\n", $value);
foreach ($this->string->split($value, 45, true, true) as $_value) {
$page->drawText(
trim(strip_tags($_value)),
$this->getAlignRight($_value, 130, 440, $font, 10),
$top,
'UTF-8'
);
$top -= 10;
}
}
}
$this->y = $this->y > $top ? $top : $this->y;
}