ImageVerifierCode 换一换
格式:DOCX , 页数:21 ,大小:35.94KB ,
资源ID:3487752      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3487752.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(PHPWordDocs062.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

PHPWordDocs062.docx

1、PHPWordDocs062PHPWord Beta 0.6.2Developers GuideTable of contentsWhat the hell are twips?Youll often find the unit twips in this documentation. Twips are the base length unit in Open Office. Twip means TWentieth of an Inch Point. So 1 twip = 1/1440 inch. Set default FontBy default every text appears

2、 in Arial font with font size of 10 point. You can alter the default font by using the following two functions:$PHPWord-setDefaultFontName(Tahoma);$PHPWord-setDefaultFontSize(12);Set document propertiesYou can set the following document properties:NameTypeCreatorStringCompanyStringTitleStringDescrip

3、tionStringCategoryStringLast modified byStringCreatedDatetimeModifiedDatetimeSubjectStringKeywordsStringTo set these properties use the following code:$properties = $PHPWord-getProperties();$properties-setCreator(My name); $properties-setCompany(My factory);$properties-setTitle(My title);$properties

4、-setDescription(My description); $properties-setCategory(My category);$properties-setLastModifiedBy(My name);$properties-setCreated( mktime(0, 0, 0, 3, 12, 2010) );$properties-setModified( mktime(0, 0, 0, 3, 14, 2010) );$properties-setSubject(My subject); $properties-setKeywords(my, key, word);Secti

5、onsAdd a sectionEvery visible element in word is placed inside of a section. To create a default section use the following code:$section = $PHPWord-createSection();The code above creates a default section (portrait oriented) with default margins.Style sectionsThere are two ways to style your section

6、s:Style with given array:$sectionStyle = array(orientation = null, marginLeft = 900, marginRight = 900, marginTop = 900, marginBottom = 900);$section = $PHPWord-createSection(sectionStyle);Style after creating the section:$section = $PHPWord-createSection();$sectionStyle = $section-getSettings();$se

7、ctionStyle-setLandscape();$sectionStyle-setPortrait();$sectionStyle-setMarginLeft(900);$sectionStyle-setMarginRight(900);$sectionStyle-setMarginTop(900);$sectionStyle-setMarginBottom(900);Available style propertiesProperties are all case sensitive !NameDescriptionOrientationPage orientation. Possibl

8、e values are:null (means portrait orientation)landscapemarginTopPage margin top in twips.marginLeftPage margin left in twips.marginRightPage margin right in twips.marginBottomPage margin bottom in twips.borderTopSizeBorder top size in twips.borderTopColorBorder top color in HEX.borderLeftSizeBorder

9、left size in twips.borderLeftColorBorder left color in HEX.borderRightSizeBorder right size in twips.borderRightColorBorder right color in HEX.borderBottomSizeBorder bottom size in twips.borderBottomColorBorder bottom color in HEX.The following two properties are automatically set by the use of the

10、orientation property. You can alter them but thats not recommended!NameDescriptionpageSizeWPage width in twips.pageSizeHPage height in twips.Text ElementsAdd text elementsTo add text elements to your word document use the function addText.$section-addText( $text, $fontStyle, $paragraphStyle );addTex

11、t()ParametersTypeDescription$textStringText that appears in the document.$fontStyleString / ArrayFont style of the text.$paragraphStyleString / ArrayParagraph style of the text.Add textrun elementsA textrun element can contain text or link elements. All elements are placed inside one paragraph with

12、the optionally given paragraph style. To add a textrun use the function createTextrun.createTextRun()ParametersTypeDescription$paragraphStyleString / ArrayParagraph style of the text.After creating the textrun you can add text or link elements with individual styles.$textrun = $section-createTextRun

13、();$textrun-addText(I am bold, array(bold=true); $textrun-addText(I am italic, array(italic=true);$textrun-addText(I am colored, array(color=AACC00);Of course you can use the pre defined paragraph or font styles. See chapter “Style text elements” for more information.Style text elementsThere are 2 o

14、ptions to style the inserted text elements:Inline Style:$fontStyle = array(color=006699, size=18, bold=true);$section-addText(helloWorld, $fontStyle);$text = $section-addText(helloWorld);$style = $text-getStyle();$style-setColor(006699);$style-setSize(18);$style-setBold();Or you can style your text

15、by using a style definition. After defining a style you have to set the second parameter to the name of your style. Use the function addFontStyle:$PHPWord-addFontStyle( $styleName, $fontStyle);addFontStyle()ParametersTypeDescription$styleNameStringName of the font style.$fontStyleArrayFont style.Exa

16、mple:$fontStyle = array(color=006699, size=18, bold=true);$PHPWord-addFontStyle(myOwnStyle, $fontStyle);$text = $section-addText(helloWorld, myOwnStyle);To add a paragraph style definition, use the function addParagraphStyle:addParagraphStyle()ParametersTypeDescription$styleNameStringName of the par

17、agraph style.$paragraphStyleArrayParagraph style.Available style propertiesProperties are all case sensitive !Font StyleNameDescriptionsizeFont size in points.nameFont familyboldBolditalicItalicsuperScriptSuperScriptsubScriptSubScriptunderlineUse the defined constants: PHPWord_Style_Font:UNDERLINE_.

18、ColorFont colorfgColorForeground color. You can only use the predefined constants:PHPWord_Style_Font:FGCOLOR_.Paragraph StyleNameDescriptionalignHorizontal alignment. Possible are:leftrightcenterboth / justify spaceBeforeTop margin of the text in twips.spaceAfterBottom margin of the text in twipsspa

19、cingMargin between the text lines in twips.Add text breaksTo add a text break use the function addTextBreak:$section-addTextBreak();If you need more than one text break you can set a multiple text break like this:$section-addTextBreak(15);The code above inserts 15 text breaks.Add page breaksTo add a

20、 manual page break you can use the function addPageBreak:$section-addPageBreak();List elementsAdd list elementsTo add a list item use the function addListItem:$section-addListItem( $text, $depth, $styleText, $styleList, $styleParagraph );addListItem()ParametersTypeDescription$textStringText that app

21、ears in the document.$depthIntegerDe$styleTextString / ArrayFont style of the current list element. See the chapter Style text elements for more information.$styleListArrayList style of the current element.$styleParagraphString / ArrayParagraph style of the current list element. See the chapter Styl

22、e text elements for more information.Style list elementsExample of styling list elements:$listStyle = array(listType = PHPWord_Style_ListItem:TYPE_NUMBER);$section-addListItem(Listitem 1, 0, null, $listStyle);Available list style propertiesProperties are all case sensitive !NameDescriptionlistTypeLi

23、st point style.Use the constants in PHPWord_Style_ListItem:TYPE_.HyperlinksAdd HyperlinksYou can add Hyperlinks to the document by using the function addLink:$section-addLink( $linkSrc, $linkName, $styleFont, $styleParagraph);addListItem()ParametersTypeDescription$linkSrcStringThe URL of the Link.$l

24、inkNameStringPlaceholder of the URL that appears in the document.$styleFontString / ArrayStyle of the Link. See the chapter Style text elements for more information.$styleParagraphString / ArrayParagraph style of the link. See the chapter Style text elements for more information.Style HyperlinksTher

25、e are two ways to style a hyperlink.Inline Style:$linkStyle = array(color=0000FF, underline=PHPWord_Style_Font:UNDERLINE_SINGLE);$section-addLink(http:/www.google.de, null, $linkStyle);Or you can style the hyperlink by using a style definition. After defining a style you have to set the third parame

26、ter to the name of your style.$linkStyle = array(color=0000FF, underline=PHPWord_Style_Font:UNDERLINE_SINGLE);$PHPWord-addLinkStyle(myHyperlinkStyle, $linkStyle);$section-addLink(http:/www.google.de, null, myHyperlinkStyle);addLinkStyle()ParametersTypeDescription$styleNameStringThe name of the Link

27、style.$stylesArrayLink style. All font style properties are possible. See the chapter Style text elements for more information.ImagesAdd imagesTo add an image use the function addImage:$section-addImage( $src, $style );addImage()ParametersTypeDescription$srcStringPath to the image on the web server.

28、 The path can be a relative or a absolute path.$styleArrayImage style.Style imagesTo style an image you can only use an array:$imageStyle = array(width=350, height=350, align=center);$section-addImage(EARTH.jpg, $imageStyle);Available style propertiesProperties are all case sensitive !NameDescriptio

29、nwidthImage width in pixelheightImage height in pixelalignImage alignment in the document. Possible are:leftrightcenterIf no width and height is given, PHPWord tries to detect the width / height properties by using the native PHP function getimagesize.PHPWord supports the image types gif, jpeg, png, bmp, tiff.Add memory imagesYou can also add images that have been created by GD. To add an GD image use the function addMemoryImage:$section-addMemoryImage( $link, $style );addMemoryImage()ParametersTypeDescription$linkStringThe first parameter indicates the source to the PHP File. I

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1