The Artima Developer Community
Sponsored Link

PHP Buzz Forum
Easy way to make Word documents with images from PHP

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Alan Knowles

Posts: 390
Nickname: alank
Registered: Sep, 2004

Alan Knowles is Freelance Developer, works on PHP extensions and PEAR.
Easy way to make Word documents with images from PHP Posted: Jan 18, 2011 8:43 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Alan Knowles.
Original Post: Easy way to make Word documents with images from PHP
Feed Title: Smoking toooo much PHP
Feed URL: http://www.akbkhome.com/blog.php/RSS.xml
Feed Description: More than just a blog :)
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Alan Knowles
Latest Posts From Smoking toooo much PHP

Advertisement
Article originally from rooJSolutions blog
 It's yet another "solve this quickly and cheaply" problems....

How to produce nice Word documents with images and all, without ending up doing lots of hard coded PHP calling some obtuse library in a way that would be difficult to maintain.

This one took a bit longer than expected, my first idea was to generate HTML files, then run them through abiword's command line, as that was the hints I got from googling.

abiword --to=doc  myfile.html

Unfortunately, although looking at abiwords source code, it should have  worked, nothing actually came out. After trying a few other magic tools like unoconv I was getting close to admitting defeat.

However, after a nice walk away from the desk and putting the thinking cap on, it came to me.. abw is abiwords xml file format. It's about as simple as HTML. So why not generate a abw file, and convert that into word.

Images in abw files are just base64 at the end of the file, each given a specific name, and reference in the body of the document where you want to use them. Trivial to generate... and even easier if you cheat a little by not using an dom based xml generator for the content (good old Flexy templates). then just run them through abiword as planned.

abiword --to=doc  myfile.abw

Quick, easy and pretty Word documents generated from web pages..

Read: Easy way to make Word documents with images from PHP

Topic: A Different Kind of Conference: the PHP Community Conference Previous Topic   Next Topic Topic: How to Create Your Own Twitter Widget in PHP, Part 3

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use