• Home
  • About
  • Doom II
  • Flog
  • Inspiration

LiveDocx: Pleasant But Lacking

Posted in Computing. on Tuesday, October 13th, 2009 by Derek
Oct 13

On a work project, one client wanted printable documents that weren’t in HTML. So we built RTF template in MS Word, formatted variable placeholders as <<VARIABLE_NAME>>, and in PHP read the whole file to run str_replace on those variable names. This didn’t work well because had to cut and paste RTF codes into separate files (sometimes up to 10) for one document when there were repeating sections. Any change requests to that document also meant breaking it all up again from scratch. Many times we came across the document not formatting correctly in all apps (MS Word, Wordpad, and OpenOffice on Windows or Mac.)

An alternate was found in LiveDocx with phpLiveDocx just recently added to the Zend Framework library. Instead .docx files are created in MS Word with MailMerge fields used for variable placeholders and loop start/end points defined by MS Word bookmarks. The phpLiveDocx code is dead simple too. We could also now export the completed document into .doc or .pdf while the whole service is free since it’s now part of the Zend Framework.

However I came across major limitations in these templates, specifically:

  • No nested loops – I wanted to group employees into their home country and have a separate table for each but the MergeBlock names created by the MS Word bookmark functionality are used as identifiers. I wanted it setup something like:

    1
    2
    3
    4
    5
    6
    
    country_start
    	[country_name]
    	employee_start
    		[employee_name] / [employee_visa_number] / [employee_visa_expiry]
    	employee_end
    country_end

    However the LiveDocx assign() functions ignore any inner loops and variables, so I would have to know beforehand what countries to include and manually created those tables separately (like having one block named “country_canada” and “country_usa”) which isn’t optimal when there are hundreds of countries worldwide.

  • No repeating blocks – Again, since the bookmarks are identifiers, I can’t reuse a block. So I couldn’t pull off even/odd table row background shading to improve readability or have a separate table for each country unless I manually created them separately. I ended up just making one flat table with the database SELECT query alphabetically sorting employees by their country. The redundant repeating country field decreases readability, which is the whole purpose of the printed document.
  • Poor template error feedback – This is probably the issue that ticked me off the most. The first time I built a template, the document generated would either being missing elements (like a table cell) or some elements would be aligned on the document in a nonsensical format. Only through trial-and-error was I able to diagnose and fix the layout issues I was having. The best tip I can give is if there is a problem, add more linebreaks. I found you can’t have two bookmarked blocks start/end on the same line. So for a table row, add two line breaks before adding in another block for LiveDocx to parse. Some of the exception messages thrown by the web service when your MergeMail field assignments aren’t properly called also make zero sense.

That’s really it. I’m impressed by the ease to integrate a web app into this service but its layout limitations leave a lot to be desired.

  • Now Playing: Killing Joke - Pandemonium - 04 - Communion

Leave a Reply

CAPTCHA Image
Refresh Image
*

Derek MacDonald


  • Photo Stream
  • Categories
    • Australia
    • Computing
    • Film & TV
    • Food
    • Gaming
    • General
    • Music
    • Sports
    • Visual Art
  • Search






  • Home
  • About
  • Doom II
  • Flog
  • Inspiration

© Copyright Derek MacDonald. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top