allan vernon
2007-03-13 07:15:09 UTC
Dear Kevin/Alexander/Willie
I cannot find a way of calculating how many points a text string would take
up using
$pdfPage->drawText('What is the width in points this text would require
using the current font and fontsize?', 72, 720);.
I need this so that I can right margin justify text output to a Pdf file.
The functions seem to be set out in library/Zend/Pdf/Resource/Font.php.
Under abstract class Zend_Pdf_Resource_Font extends Zend_Pdf_Resource there
are
public function getUnitsPerEm()
{
return self::$this->_unitsPerEm;
return $this->_unitsPerEm;
}
and
public function widthsForGlyphs(&$glyphNumbers)
{
$widths = array();
foreach ($glyphNumbers as $key => $glyphNumber) {
if (($glyphNumber < 0) || ($glyphNumber >
$this->_glyphMaxIndex)) {
throw new Zend_Pdf_Exception("Glyph number is out of range:
$glyphNumber",
Zend_Pdf_Exception::GLYPH_OUT_OF_RANGE);
}
$widths[$key] = $this->_glyphWidths[$glyphNumber];
}
print_r($widths);
return $widths;
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws Zend_Pdf_Exception
*/
public function widthForGlyph($glyphNumber)
{
if (($glyphNumber < 0) || ($glyphNumber > $this->_glyphMaxIndex)) {
throw new Zend_Pdf_Exception("Glyph number is out of range:
$glyphNumber",
Zend_Pdf_Exception::GLYPH_OUT_OF_RANGE);
}
return $this->_glyphWidths[$glyphNumber];
}
However, I have no idea how to implement these functions in the user space.
Help would be much appreciated.
Allan Vernon
I cannot find a way of calculating how many points a text string would take
up using
$pdfPage->drawText('What is the width in points this text would require
using the current font and fontsize?', 72, 720);.
I need this so that I can right margin justify text output to a Pdf file.
The functions seem to be set out in library/Zend/Pdf/Resource/Font.php.
Under abstract class Zend_Pdf_Resource_Font extends Zend_Pdf_Resource there
are
public function getUnitsPerEm()
{
return self::$this->_unitsPerEm;
return $this->_unitsPerEm;
}
and
public function widthsForGlyphs(&$glyphNumbers)
{
$widths = array();
foreach ($glyphNumbers as $key => $glyphNumber) {
if (($glyphNumber < 0) || ($glyphNumber >
$this->_glyphMaxIndex)) {
throw new Zend_Pdf_Exception("Glyph number is out of range:
$glyphNumber",
Zend_Pdf_Exception::GLYPH_OUT_OF_RANGE);
}
$widths[$key] = $this->_glyphWidths[$glyphNumber];
}
print_r($widths);
return $widths;
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws Zend_Pdf_Exception
*/
public function widthForGlyph($glyphNumber)
{
if (($glyphNumber < 0) || ($glyphNumber > $this->_glyphMaxIndex)) {
throw new Zend_Pdf_Exception("Glyph number is out of range:
$glyphNumber",
Zend_Pdf_Exception::GLYPH_OUT_OF_RANGE);
}
return $this->_glyphWidths[$glyphNumber];
}
However, I have no idea how to implement these functions in the user space.
Help would be much appreciated.
Allan Vernon
--
View this message in context: http://www.nabble.com/Finding-width-of-a-drawText-Text-in-Zend_Pdf-tf3394291s16154.html#a9449424
Sent from the Zend MFS mailing list archive at Nabble.com.
View this message in context: http://www.nabble.com/Finding-width-of-a-drawText-Text-in-Zend_Pdf-tf3394291s16154.html#a9449424
Sent from the Zend MFS mailing list archive at Nabble.com.