Forum


Replies: 3   Views: 3530
How do i change the styling of a heading 1, heading 2, etc?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by AndrewCooper  · 10-06-2016 - 10:06

I've got a Table of Contents.  The table is populated by the different Heading Level styles.  I can use "Heading1PHPDOCX" as the pStyle to get the TOC to populate correctly.  However, I need the styling of the Heading1PHPDOCX to be different.  How do I change the look of that particular style?  I see how to create styles.  How do you edit existing styles?

Andrew

Posted by admin  · 10-06-2016 - 13:03

Hello,

UPDATE: DOCXCustomizer, available in Premium licenses since phpdocx 7.0, allows to change existing styles on-the-fly.

The current version of phpdocx doesn't support changing existing styles, only create, add and import them. You can use a custom DOCX as base template with the styles you need.

The new DOCXPath (http://www.phpdocx.com/documentation/introduction/docxpath) allows to change the body content dynamically, and in the future this same class will be used to support changing other contents such as styles, headers, footers...

Regards.

Posted by AndrewCooper  · 10-06-2016 - 13:48

Okay, I don't mind creating new Styles.  That's fine.  How do I tell the TOC to look at my NewStyle1 as the Level 1 TOC entries?  That's my real issue.  I can't use the existing Heading 1 style because I need it to look different.

Andrew

Posted by admin  · 10-06-2016 - 14:31

Hello,

The addTablesOfContent method allows to set a paragraph style and custom styles, or even import an existing TOC style from a file.

And using the headingLevel property you can a text as content to appear in the TOC. This text can be styled as needed.

Regards.