Open kilianweisl opened 3 months ago
@kilianweisl Hi have you got a sample file as expected result for analysis ? Thanks
@Progi1984 Sure! Thanks for the fast reply.
Suppose I have the following code:
public function createTable()
{
$pptx = new PhpPresentation();
$slide = $pptx->getActiveSlide();
$shape = $slide->createTableShape(3);
$shape->setWidth(Converter::convertEmuToPx($pptx->getLayout()->getCX()) - 20);
$shape->setOffsetX(10);
$shape->setOffsetY(10);
for($rowCount = 0; $rowCount < 3; $rowCount++) {
$row = $shape->createRow();
for($cellCount = 0; $cellCount < 3; $cellCount++) {
$cell = $row->nextCell();
$cell->createTextRun('Cell ' . $cellCount)
->getFont()
->setSize(20);
}
}
$writer = IOFactory::createWriter($pptx, 'PowerPoint2007');
$writer->save('./table.pptx');
}
The output .pptx file is:
Now the problem is, I don't know how many rows my table has and I need to add a caption below it like so:
How can I get the final height of the table (after adding all rows) in order to place a text object afterwards?
This might also include splitting the table and printing them on multiple slides, as mentioned in https://github.com/PHPOffice/PHPPresentation/issues/72.
@kilianweisl Could you send me a sample docx file with expected result ? I want to analyze the file. Thanks
Do you mean the pptx file? It's just a bunch of rows and a text underneath it.
Oh. I didn't understand it. I think you must all calculate : font size, margin, border size, etc...
While that'd be somehow possible with simple tables, I don't think that it is possible when you e.g. have the following case, where an arbitrary column contains text that forces a line break.
Or is there a way to access the height of a cell/row/RichTextShape after putting text into it?
Hello!
I'd like to add captions to images or tables.
I couldn't find anything in the docs. Either it's possible to get the height of a dynamic shape after filling it (like adding rows to a table) or there is a solution implemented already.
For images, I could also pre-calculate the height when drawing the image with a specific width (considering its aspect-ration), but getting the height via the library would be much more convenient.
Many thanks in advance!