New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autosize text #71
Comments
@desigennaro Hi, I need more informations. Have you got a sample source code for testing ? Thanks :) Link : http://www.officeopenxml.com/drwSp-text-bodyPr-fit.php (a:normAutoFit) |
Our code is on a development network, but I have included a sample below. We are writing a PPTX file. $shape = $slide->createRichTextShape()
->setHeight(150)
->setWidth(350)
->setAutoFit( 'spAutoFit' );
$textRun = $shape->createTextRun( $text );
$textRun->getFont()->setSize(14); |
Also, when using "normAutoFit" or "RichText::AUTOFIT_NORMAL" I get the following error upon opening the PPTX. "PowerPoint found content in *filename.pptx" that it did not understand. This content has been removed and cannot be recovered." |
@desigennaro Have you tried to use this ? ->setHorizontalOverflow(RichText::OVERFLOW_CLIP)
->setVerticalOverflow(RichText::OVERFLOW_CLIP)
// or / and
->setWrap(RichText::WRAP_SQUARE) |
Yes, but I do not want the text to be cut off. My goal is to have the font size automatically decrease to allow all of the text to fit in the text box. I assumed (and I could be completely wrong) that is what one of the features of autofit is. I also assumed that wrap was to set how the text wraps around a shape it may come in connection with. |
@desigennaro Have you a PPTX file which has that feature ? I want to analyze it. PS : I haven't got Office :( |
@Progi1984 how would you like me to get the file to you? I am unable to upload it here. It is a PPTX file. I suppose you can unzip it and look at the xml....does that help? |
@desigennaro You can send me by mail (my nickname @ GMail Dot Com). |
@Progi1984 sent First slide is with autosizing, second slide is without. Same text. |
@desigennaro Wow... I just try with parameters for normAutoFit but no works. For this : $objWriter->writeElement('a:' . $shape->getAutoFit(), null); by $objWriter->startElement('a:' . $shape->getAutoFit());
if($shape->getAutoFit() == RichText::AUTOFIT_NORMAL){
$objWriter->writeAttribute('fontScale', '47500');
$objWriter->writeAttribute('lnSpcReduction', '20000');
}
$objWriter->endElement(); |
Hi Progi, I would like to create a Shape, (i don't know contents before), so i put a ridiculous height $shape->setHeight(10)->setWidth(915)->setOffsetX(25)->setOffsetY(248)->setAutoFit( RichText::AUTOFIT_NORMAL ); After that i populate my shape with a long long text with createTextRun! $textRun = $shape->createTextRun("Profitez de la bien nommée Costa del Sol en séjournant à Torremolinos à l'hôtel Amaragua. Son emplacement des plus agréables au bord d’une grande plage favorise un séjour en toute quiétude, à quelques pas seulement de l’animation."); On the pptx generated, my shape have 10 height value can we create a shape with a textRun who have dynamic height ? PS: I've tried your patch its seems it's didn't work, sry for my bad english |
@Gyzmoo Yes, I know that my patch doesn't work... It's a WIP so I try fixing that without PowerPoint. For a shape with dynamic height, please create a new issue. Thanks. |
@Progi1984 Thanks for your first shot at it. I will work with what you have posted and keep this thread updated with any forward progress I can make. To get the ball rolling.....in the RichText.php file on line 38 I noticed the following: const AUTOFIT_NORMAL = 'normAutoFit'; in the XML of an unzipped PPTX file an autofit element is: <a:normAutofit fontScale="..." lnSpcReduction="..."/> I assume this is going to be case sensitive ("F" vs "f") |
@desigennaro Good job :) It is the solution. OpenXML is case sensitive. |
…s (fontScale & lineSpacingReduction)
@desigennaro You can now use AutoFit with two options :
$oRichTextShape->setAutoFit(RichText::AUTOFIT_NORMAL, 47.5, 20); |
…s (fontScale & lineSpacingReduction)
When i use the setAutoFit( RichText::AUTOFIT_NORMAL, 50, 20); function, I dont understand why the autoFit option are not OK on the file generated, i've to do an action manually for resize text policy... |
@Gyzmoo You must choose values for each percentage for each richtext shape that you use. Why ? Because it's PowerPoint which makes the calculation to find the good value... And with code, it's the developer which has this job. May be an algorithm could permit to do this, but I have no clue for this solution. |
Hum i understand your solution but all my text on RichTextShape are generics. (i can have 1 words, 1 sentence or many sentences for each export! |
@Progi1984 Thanks for the help. It works great. I am planning to use character count to determine how much I am going to shrink the text since I am using a slide template. |
@desigennaro No problem, it's a pleasure.... Just hard to work without Office 2k7/2k12... PS : I close this issue. |
If the text is too large to fit in the box I would like it to automatically make the font size smaller. I assume that autoFit would be used, but I have been unable to get it working.
The text was updated successfully, but these errors were encountered: