RTF Writer: PreserveText - Create#2826
Conversation
|
The description of preserveText in (Samples)[https://github.com/PHPOffice/PHPWord/blob/master/docs/usage/elements/preservetext.md] suggests that preserveText can be used to add Fields. This feels odd since there is already a field element? My current commit adds fields as described. But what is the point of preserveText? preserveText sounds like it's supposed to be used for adding things like whitespace and special characters (like braces and slashes), but text already does that just fine. Instead of "preserving" the text, it currently adds fields. So though I've built this like described, I'm confused what the purpose of the element is? |
I made RTF usable some time ago. @rasamassen has recently done a lot of useful work to cover many missing areas. Since who knows when those changes will be merged, I intend to incorporate much of that work. I will do this with several pushes, each based on one or more of those changes. This one is based on PR PHPOffice#2824 (fixes issue PHPOffice#344), and PR PHPOffice#2826. Widow-orphan control may be affected by this change; based on comments in 2824, I have added a document-level widow-control used only by Rtf, but do not, as yet, use that value to do anything other than read/write an appropriate instruction in the file header.
|
You are correct that PreserveText isn't absolutely required, but it can make things a lot simpler. $footer->addPreserveText('Page {PAGE} of {NUMPAGES}');is much easier than adding a TextRun consisting of Text/Field/Text/Field. |
Description
Create PreserveText
Checklist: