2017-10-28 14 views
0

TCPDFを使用していますので、画像の左下隅の座標に従って画像を配置する必要があります。tcpdf左下の座標に従って画像を配置

TCPDFs画像()メソッドは、アンカーポイントとして左上隅を使用していますし、私はこれを変更する可能性を見つけることができません:

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, $alt = false, $altimgs = array()) 

私は何ができるか、画像のYサイズを決定することであり、左下隅の与えられたy座標からイメージのyサイズを差し引く。しかし、イメージを配置する前に、イメージをどのように取得するかもわかりません。

答えて

0

左下隅のy座標が与えられている場合は、まず$ y値とプロパティ$ hiddenをtrueに設定してイメージメソッドを実行します。次に、getImageRBY()メソッドを使用して、隠し画像の下端のy座標を取得します。 getImageRBY()から得た座標から$ yの値を控除して、画像の高さを取得します。

// my bottom left coordinate of the image 
$my_bottom_y_coordinate = 'somevalue'; 

// This is just to calculate the height 
$dummy_y = 'somedummyvalue'; 

// Run the Image function with $hidden set to true, so the image won't be shown. 
$tcpdf->Image($file, $x, $dummy_y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, TRUE, $fitonpage, $alt, $altimgs); 

// get the bottom y-coordinate of the dummy image and deduct it from the 
// $dummy_y variable (which was the upper y coordinate of the dummy image) to retrieve the height 
$height = $tcpdf->getImageRBY() - $dummy_y; 

// 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. 
$y = $my_bottom_y_coordinate - $height; 

// run the Image() method again this time with hidden false so the image is actually placed on the pdf page 
$tcpdf->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, FALSE, $fitonpage, $alt, $altimgs); 

後、画像()メソッドは、画像を配置する必要がy座標あなたの下部から画像の高さを差し引くと、あなたは、$ y値を持っています

関連する問題