Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
CodeQuality\Class_\CompleteDynamicPropertiesRector::class
])
->withSkip([
# see https://github.com/Shardj/zf1-future/pull/453
CodeQuality\Class_\CompleteDynamicPropertiesRector::class => [
__DIR__ . '/library/Zend/Pdf/Element.php',
],
Php53\FuncCall\DirNameFileConstantToDirConstantRector::class,
Php53\Ternary\TernaryToElvisRector::class,
Php54\Array_\LongArrayToShortArrayRector::class,
Expand Down
3 changes: 1 addition & 2 deletions library/Zend/Pdf/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*
* @property mixed $value
* @property mixed $value see https://github.com/Shardj/zf1-future/pull/453
*/
abstract class Zend_Pdf_Element
{
public $value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it worked setting to protected $value; to generate a PDF with a PNG image. Otherwise the PDF just stays blank without an image. I guess the protected value can't get accessed directly, thus the magical getter kicks in to retrieve value from the stream object.

include 'vendor/autoload.php';
$filename = '/var/www/testfile.png';

# @see https://github.com/Shardj/zf1-future/pull/453#issuecomment-2416109612
# "public $value" in Zend_Pdf_Element causes image not to render in PDF. 
# Switching to "protected $value" worked for me. 
$image  = Zend_Pdf_Image::imageWithPath($filename); 


$pdf = new Zend_Pdf();
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$page->drawImage($image, 50, 500, 400, 800);
$pdf->pages[] = $page;

header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="output.pdf"');
echo $pdf->render();

PS: But if specific rector rule is still needed, just leave the code like you suggested. Openmage with "release-1.24.1" is not working for me at the moment. So I'm happy if this Pull Request is merged soon. :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For OM feel free to start discussing about alternatives.

dompdf, ..., twig ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my use case I'm using a third party module for invoice creation.

public const TYPE_BOOL = 1;
public const TYPE_NUMERIC = 2;
public const TYPE_STRING = 3;
Expand Down
Loading