Изображение TCPDF становится черным после наличия ранее скрытого изображения того же источника - PullRequest
0 голосов
/ 09 января 2020

TCPDF Изображение становится черным после наличия ранее скрытого изображения того же источника

Мне нужно скрыть изображение, чтобы получить его размеры, чтобы затем динамически регулировать координаты изображения на основе размера изображения, чтобы оно составляло 10 пикселей от справа от границы страницы

Только когда я меняю скрытое изображение с ложного на истинное, печать набора вторичных изображений становится черной. В PNG прозрачность отсутствует и отображается нормально, если я скрыл ложное на исходное изображение (только у меня 2 изображения на странице)

Изображение черного ящика в PDF, где PNG должно быть

$pdf->SetXY(0, 0);
        // my bottom right coordinate of the image
        $my_right_x_coordinate = 200;
        // This is just to calculate the height
        $dummy_x = 160;
        $h = 15;
        // Run the Image function with $hidden set to true, so the image won't be shown.
        $pdf->Image($image, $dummy_x, 100, 0, $h, '', '', '', false, 300, '', true, false, 0);

        // get the bottom y-coordinate of the dummy image and deduct it from the
        // $dummy_x variable (which was the upper x coordinate of the dummy image) to retrieve the height
        $width = $pdf->getImageRBX() - $dummy_x;

        // deduct the height from the given bottom y coordinate you really want to use. This yields the upper y coordinate you need for the image function.
        $x = $my_right_x_coordinate - $width;
        $y = 100;
        $w = 0;

        // run the Image() method again this time with hidden false so the image is actually placed on the pdf page
        // Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false)

// Print Image with new coordinates
 $pdf->Image($image, $x, 100, 0, $h, '', '', '', false, 300, '', false, false, 0);
...