createParagraphStyle
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addSVG
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- importStylesWordDefault
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDecimalSymbol
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- removeTemplateVariableImage
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
createParagraphStyle
TRIAL / ADVANCED / PREMIUM
Creates a new Word paragraph style.
Description
public createParagraphStyle ( string $name [, array $styleOptions = array() ])
This method allows the generation of custom paragraph styles that may be later used in combination with, for example, the addText method.
Parameters
name
A string with the name of the Word style that you are creating.
styleOptions
This is an array including all the available styling options.
Key | Type | Description |
---|---|---|
backgroundColor | string | Hexadecimal value (FFFF00, CCCCCC, ...). |
bidi | bool | Sets to true for right to left languages like Hebrew or Arabic. |
bold | bool | If true the text will be shown in bold characters. |
border | string | Available values are:
|
borderBottom | string | Overwrites the general border type for the bottom border of the paragraph. |
borderLeft | string | Overwrites the general border type for the left border of the paragraph. |
borderTop | string | Overwrites the general border type for the top border of the paragraph. |
borderRight | string | Overwrites the general border type for the right border of the paragraph. |
borderColor | string | Hexadecimal color value: FF0000, 000000... |
borderBottomColor | string | Overwrites the general border color for the bottom border of the paragraph. |
borderLeftColor | string | Overwrites the general border color for the left border of the paragraph. |
borderTopColor | string | Overwrites the general border color for the top border of the paragraph. |
borderRightColor | string | Overwrites the general border color for the right border of the paragraph. |
borderSpacing | int | Separation between border and text in points. |
borderBottomSpacing | int | Overwrites the general border spacing for the bottom border of the paragraph. |
borderLeftSpacing | int | Overwrites the general border spacing for the left border of the paragraph. |
borderTopSpacing | int | Overwrites the general border spacing for the top border of the paragraph. |
borderRightSpacing | int | Overwrites the general border spacing for the right border of the paragraph. |
borderWidth | int | Border width in eigths of a point. |
borderBottomWidth | int | Overwrites the general border width for the bottom border of the paragraph. |
borderLeftWidth | int | Overwrites the general border width for the left border of the paragraph. |
borderTopWidth | int | Overwrites the general border width for the top border of the paragraph. |
borderRightWidth | int | Overwrites the general border width for the right border of the paragraph. |
caps | bool | If true displays text in capital letters. |
color | string | Hexadecimal color value: 'FF0000', '000000'... |
contextualSpacing | bool | If true ignores spacing above and below the paragraph whenever the neighbouring paragraphs use the same Word style (false by default). |
doubleStrikeThrough | bool | If true displays text in doubleStrikeThrough. |
em | string | Emphasis mark type: 'none', 'dot', 'circle', 'comma', 'underDot'. |
firstLineIndent | int | First line indentation in twentieths of a point (twips). |
font | string | Font family: 'Arial', Calibri'... |
fontSize | int | Text size in half-points: 8, 9, 10... Multiply by 2 to get the same size as using the fontSize property with addText and other methods. |
hanging | int | Paragraph hanging in twentieths of a point (twips). |
headingLevel (outlineLvl option alias) | int | The heading level if you want this paragraph to be a heading. |
hidden | bool | Hide style from user interface. |
indentLeft | int | Left margin in twips (twentieths of a point). |
indentRight | int | Right margin in twips (twentieths of a point). |
italic | bool | If true displays the text in italics. |
keepLines | bool | Keeps (whenever possible) all the current paragraph lines on the same page. |
keepNext | bool | Keeps (whenever possible) in the same page the current paragraph with next paragraph. |
lineSpacing | int | Separation between lines: 240 (single spacing), 480 (double spacing) and so long so forth. |
locked | bool | Style cannot be applied. |
name | string | Forces a name value, otherwise $name is used as styleId and name. |
next | string | Style for next paragraph. |
numberingStyle | string | Numbering style. |
outlineLvl (headingLevel option alias) | int | The heading level if you want this paragraph to be a heading. |
pageBreakBefore | bool | If true forces a page break before the paragraph. |
position | int | Position value. Positive value for raised and negative value for lowered. |
primaryStyle | bool | If true sets the style as primary style to be displayed in the styles interface. |
pStyle | string | Id of the style this paragraph style is based on (it may be retrieved with the parseStyles method). |
rtl | bool | Sets to true for right to left languages like Hebrew or Arabic. |
scaling | int | Scaling value, 100 is the default value. |
semiHidden | bool | Hide style from main user interface. |
smallCaps | bool | If true displays text in small capital letters. |
spacingBottom | int | Bottom padding in twentieths of a point. |
spacingTop | int | Top padding in twentieths of a point. |
strikeThrough | bool | If true displays text in strikethrough. |
suppressLineNumbers | bool | Suppress line numbers. |
tabPositions | array | Each entry is an associative array with the following keys and values:
|
textAlign | string | Text alignment. Possible values are: 'center', 'right', 'both', 'distribute'. |
textDirection | string | Text flow: lrTb, tbRl, btLr, lrTbV, tbRlV, tbLrV. |
underline | string | Underlines text. Possible values are: 'single', 'words', 'double', 'dotted', 'dash' and 'wave'. |
unhideWhenUsed | bool | Remove semi-hidden property when style is used. |
vanish | bool | Uses a vanish style. |
widowControl | bool | Prevents Word from printing the last line of a paragraph by itself at the top of the page (widow) or the first line of a paragraph at the bottom of a page (orphan). |
wordWrap | bool | Allows line breaking at character level (default value is false). |
Code samples
Release notes
- phpdocx 15.5:
- headingLevel option as alias of the outlineLvl option.
- phpdocx 12.5:
- primaryStyle and suppressLineNumbers options.
- phpdocx 12.0:
- hidden, semiHidden, unhideWhenUsed, locked and next options.
- phpdocx 9.5:
- numberingStyle option.
- phpdocx 7.5:
- doubleStrikeThrough, vanish, scaling, position and underlineColor styles.