Skip to content

AbstractPdf - ZendException font is not set #11743

@jchenevey

Description

@jchenevey

Preconditions

  1. Magento v2.2.0
  2. PHP 7.0.22

Steps to reproduce

  1. Try to write a large multi-line block of text using drawLineBlocks() (my apologies for not providing a better example here - this came up during development of a custom module, which I am unable to include here)

Expected result

  1. PDF should render

Actual result

  1. A new Zend_Pdf_Exception is thrown, stating "Font has not been set"

The issue is caused by lines 1034-1036 in /vendor/magento/module-sales/Model/Order/Pdf/AbstractPdf.php.

foreach ($column['text'] as $part) {
    if ($this->y - $lineSpacing < 15) {
        $page = $this->newPage($pageSettings);
    }
...

This new page is created after the font has been determined (lines 1008-1025) and set for the line to be written. Therefore, at the time line 1057 is reached (below), the font for the new page has not been set.

$page->drawText($part, $feed, $this->y - $top, 'UTF-8');

The solution would be to re-set the page's font after creating the new page.

Metadata

Metadata

Assignees

Labels

Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions