how to use php to include an image in a word file?

为君一笑 提交于 2019-12-03 07:18:56

look here http://www.tkachenko.com/blog/archives/000106.html

<w:pict>
    <v:shapetype id="_x0000_t75" ...>
    ... VML shape template definition ...
    </v:shapetype>
    <w:binData w:name="wordml://02000001.jpg">
    ... Base64 encoded image goes here ...
    </w:binData>
    <v:shape id="_x0000_i1025" type="#_x0000_t75" 
      style="width:212.4pt;height:159pt">
         <v:imagedata src="wordml://02000001.jpg" 
           o:title="Image title"/>
    </v:shape> 
</w:pict>

There is PHPWord project to manipulate MS Word from within PHP.

PHPWord is a library written in PHP that create word documents. No Windows operating system is needed for usage because the result are docx files (Office Open XML) that can be opened by all major office software.

PHPWord can write them http://phpword.codeplex.com/ (note: its still in Beta. I've used PHpExcel by the same guy a lot... never tried the Word version).

Have a look at the phpdocx library for generating real .docx files rather than html files with a .doc extension

PS the extension should strictly be .docx rather than .doc for Open XML Word 2007 files

OpenTBS can create DOCX (and other OpenXML files) dynamic documents in PHP using the technique of templates.

No temporary files needed, no command lines, all in PHP.

It can add or delete pictures. The created document can be produced as a HTML download, a file saved on the server, or as binary contents in PHP.

It can also merge OpenDocument files (ODT, ODS, ODF, ...)

http://www.tinybutstrong.com/opentbs.php

If rich text is ok try PhpRtf.

I would use PHPExcel. It can work with OpenXML too.

Here's the link: http://phpexcel.codeplex.com/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!