Critical Magento 2 Bug: PDF Logo Uploads Break Invoice Printing

Critical Magento 2 Bug: PDF Logo Uploads Break Invoice Printing

At Shopping Mover, we constantly monitor the Magento community for insights that can impact our clients and the broader e-commerce ecosystem. A recent GitHub issue (#41802) has brought to light a critical bug affecting Magento 2.4-develop and earlier versions (from 2.3.4 onwards) that can severely disrupt core business operations: the inability to print invoices, shipments, and credit memos after an incorrect PDF logo upload.

The Unexpected PDF Logo Acceptance

The core of the problem lies in the Magento admin configuration. Under Stores > Configuration > Sales > Sales > Invoice and Packing Slip Design, there's a field labeled "Logo for PDF Print-outs." According to the field's comment and official documentation, this field is intended to accept only image formats such as JPEG, TIFF, and PNG. However, the system currently allows users to upload a .pdf file into this field and save the configuration without any error.

The Consequence: Broken PDF Generation

While the upload itself appears successful, the real issue manifests when a user attempts to print an invoice, shipment, or credit memo for an order. Instead of generating the PDF document, the system returns a generic 500 error. The server's exception.log reveals the underlying technical problem:

Error: Class "Zend_Pdf_Resource_Image_Pdf" not found in lib/internal/Magento/Framework/File/Pdf/ImageResource/ImageFactory.php:164

This error indicates that Magento's PDF generation library attempts to embed the uploaded PDF file as an image, which it cannot do, as a PDF cannot be treated as an image resource in this context. The system expects an actual image format to be provided.

Technical Deep Dive: A Conflict in Logic

The issue's author, SamJUK, provided a crucial insight into the bug's origin. It appears that Magento\Config\Model\Config\Backend\Image\Pdf was updated in a previous Pull Request (#24153) to allow pdf file types. This change was likely intended to support general PDF uploads elsewhere in the system (e.g., for product attachments), but it inadvertently extended to the "Logo for PDF Print-outs" field, where it is inappropriate. A PDF file simply cannot be embedded as an image within another generated PDF document using the current framework logic.

Community Confirmation and Impact

The issue was quickly confirmed by engcom-Bravo, who successfully reproduced the bug on a Magento 2.4-develop instance, validating the steps and the resulting 500 error. This confirmation underscores the severity of the bug, which is categorized as S2 – affecting non-critical data or functionality but forcing users to employ a workaround.

For merchants, this bug means a complete halt to essential document generation, impacting order fulfillment and customer communication. For developers, it highlights a logical inconsistency in file type validation across different configuration fields. Until a fix is officially released by Adobe Commerce, the immediate workaround for any Magento user experiencing this issue is to ensure that only accepted image formats (JPEG, TIFF, PNG) are uploaded as the "Logo for PDF Print-outs." If a PDF was previously uploaded, replacing it with a valid image file should resolve the 500 error.

This incident serves as a reminder of the importance of rigorous testing, especially after core system updates, and the invaluable role of the Magento community in identifying and reporting such critical issues.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools