PHPOffice / PHPPresentation

A pure PHP library for reading and writing presentations documents
https://phpoffice.github.io/PHPPresentation
Other
1.31k stars 523 forks source link

Font::setSize() must be of the type int, float given #708

Open gsonss opened 2 years ago

gsonss commented 2 years ago

Fatal error: Uncaught TypeError: Argument 1 passed to PhpOffice\PhpPresentation\Style\Font::setSize() must be of the type int, float given

gsonss commented 2 years ago

PHP 7.4.19 (cli) Zend Engine v3.4.0

Slairmy commented 2 years ago

same problem with me, Did you solve it ?

Tom-Magill commented 2 years ago

You have tried to set a float as the font size (such as 7.125), but this function requires an integer (such as 7 - see the exact function you're calling below). To fix this, you need to ensure you're only passing an integer value - perhaps using the PHP functions of round(), floor(), ceil() or intval() on the variable?

/**
 * Set Size.
*/
public function setSize(int $pValue = 10): self
{ 
  $this->size = $pValue;

  return $this;
}
Progi1984 commented 3 months ago

@gsonss @Tom-Magill @Slairmy Hi, Could you send me a sample file with error, please, for reproducing the bug ?