Skip to content
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

Finding and replacing a string with another. Template processor #631

Open
mudassar192 opened this issue Oct 8, 2015 · 5 comments
Open

Comments

@mudassar192
Copy link

mudassar192 commented Oct 8, 2015

Hi ,
Currently I am working with PHPWord , and I am trying to replace one string with another.Is there some way that I can do this. I have looked into the TemplateProcessor but am unable to find any solution for this. Can u kindly guide me in this regard.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@ozilion
Copy link
Contributor

ozilion commented Oct 9, 2015

For templates only you can replace by variables. There is no search and replace feature for templates, yet. But maybe you can read content of docx, and make string replace then save you docx as new file.

@mudassar192
Copy link
Author

Yes sure, I tried to follow this approach that u just mentioned. but What i could understand was there was a phpword object --> section --> abstract-container--> addText() function. but I was unable to understand where the text was actually stored.
Basically my question simply put is "How to convert the phpword (containing the read document) into string". or how to extract text from a document object.
P.S : your help is appreciated.

@ngocketit
Copy link

@ozilion Could you please tell how can I define variables in a docx template? I'm using Office for Mac but couldn't find any ways of doing so. Thanks!

@ozilion
Copy link
Contributor

ozilion commented Oct 11, 2016

@ngocketit just put your variables between ${ and } without spacesand in your code, use as

setValue($variable, $value)

@ngocketit
Copy link

@ozilion Thanks a lot! It's as that simple and I got it work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants