<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>GS Design</title>
	
	<link>http://www.gsdesign.ro/blog</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Sun, 15 Apr 2012 15:43:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/gsdesign/bzmE" /><feedburner:info uri="gsdesign/bzme" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>jQuery UI bootstrap tabs remember last selected tab</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/OuJblZ4w5Tw/</link>
		<comments>http://www.gsdesign.ro/blog/jquery-ui-bootstrap-tabs-remember-last-selected-tab/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 15:43:53 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Front-End Developing]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=474</guid>
		<description><![CDATA[I have started working with Bootstrap UI from Twitter and i love it. I had some trouble though with the tabs component that did not remember the last tab selected on refresh. You can easily edit the component to allow for this feature: - comment the line bellow from the TAB DATA-API // e.preventDefault() - [...]]]></description>
			<content:encoded><![CDATA[<p>I have started working with Bootstrap UI from Twitter and i love it. I had some trouble though with the tabs component that did not remember the last tab selected on refresh.</p>
<p>You can easily edit the component to allow for this feature:</p>
<p><strong>- comment the line bellow from the TAB DATA-API</strong><br />
<code class="prettyprint"><br />
// e.preventDefault()<br />
</code></p>
<p><strong>- add the following code below the TAB DATA-API</strong><br />
<code class="prettyprint"><br />
$('ul.nav-tabs li a[data-toggle="tab"]').each(function(){<br />
    if ($(this).attr("href") == window.location.hash) {<br />
        $(this).tab('show')<br />
    }<br />
});</p>
<p><strong>- add an anchor to all your tabs links</strong><br />
</code></p>

<p><a href="http://feedads.g.doubleclick.net/~a/xmflWF__xCl3ezh8JBpm3HnBcJY/0/da"><img src="http://feedads.g.doubleclick.net/~a/xmflWF__xCl3ezh8JBpm3HnBcJY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/xmflWF__xCl3ezh8JBpm3HnBcJY/1/da"><img src="http://feedads.g.doubleclick.net/~a/xmflWF__xCl3ezh8JBpm3HnBcJY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/OuJblZ4w5Tw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/jquery-ui-bootstrap-tabs-remember-last-selected-tab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/jquery-ui-bootstrap-tabs-remember-last-selected-tab/</feedburner:origLink></item>
		<item>
		<title>Easy deploy your applications from SVN with Springloops</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/ib7FVPaoNLk/</link>
		<comments>http://www.gsdesign.ro/blog/easy-deploy-your-applications-from-svn-with-springloops/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 15:02:13 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[project management]]></category>
		<category><![CDATA[Web Aplications]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[springloops]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[version-control]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=465</guid>
		<description><![CDATA[When you are an one man band, coding any project doesn&#8217;t raise to much logistical problems. You can&#8217;t work with ought Version Control and deployment may be as easy as overwriting all files by FTP. When you start to at least another developer on the project, then things get tricky. You would need some Version Control and [...]]]></description>
			<content:encoded><![CDATA[<p>When you are an one man band, coding any project doesn&#8217;t raise to much logistical problems. You can&#8217;t work with ought Version Control and deployment may be as easy as overwriting all files by FTP. When you start to at least another developer on the project, then things get tricky.</p>
<p>You would need some Version Control and of course you will need some deployment strategy. This is <a href="http://www.springloops.com/v2?r=12980191561783250" target="_blank">Springloops</a> comes in. Not only does it give you an version control repository (Git or Subversion) for your project but it also provides an automatic process of deploying your app, either by FTP, SFTP, FTP over SSH and even to Amazon S3.<span id="more-465"></span></p>
<p>If version control and one click automatic deployments were not enough to convince you, <a href="http://www.springloops.com/v2?r=12980191561783250" target="_blank">Springloops</a> also has project management features: milestones, tickets and even time tracking.</p>
<p>Another cool thing is they have a <strong>free plan</strong> witch gives you access to all the features for only one active project. So you have a project starting up give it a try i promise you wont be disappointed.</p>
<p><a href="http://www.springloops.com/v2?r=12980191561783250"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2012/03/springloops.png" alt="" title="springloops" width="500" class="aligncenter size-full wp-image-468" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/oWbZ6T-8zlpM07qbOnCUhn1xMyI/0/da"><img src="http://feedads.g.doubleclick.net/~a/oWbZ6T-8zlpM07qbOnCUhn1xMyI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oWbZ6T-8zlpM07qbOnCUhn1xMyI/1/da"><img src="http://feedads.g.doubleclick.net/~a/oWbZ6T-8zlpM07qbOnCUhn1xMyI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/ib7FVPaoNLk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/easy-deploy-your-applications-from-svn-with-springloops/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/easy-deploy-your-applications-from-svn-with-springloops/</feedburner:origLink></item>
		<item>
		<title>Database design example for a configurable product eshop</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/DG2xcAH_EOM/</link>
		<comments>http://www.gsdesign.ro/blog/database-design-example-for-a-configurable-product-eshop/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 22:28:20 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[database design]]></category>
		<category><![CDATA[eshop]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=449</guid>
		<description><![CDATA[I was building an e-shop and one of the requiremens was to have configurable products. The configurable parts will need to have different prices and stocks from the main product.  Also the shop must be able to move products from one category to another. So i started thinking of a database structure that will enable [...]]]></description>
			<content:encoded><![CDATA[<p>I was building an e-shop and one of the requiremens was to have configurable products.<br />
The configurable parts will need to have different prices and stocks from the main product.  Also the shop must be able to move products from one category to another.</p>
<p>So i started thinking of a database structure that will enable me to accomplish this. As i started to research i also posted a question on <a href="http://stackoverflow.com/q/2645958/65503">stackoverflow</a> to see what others had in mind.</p>
<p><span id="more-449"></span></p>
<h3>The design</h3>
<p>After a bit of thought i came up with this design.<br />
<a href="http://www.gsdesign.ro/blog/wp-content/uploads/2010/12/screenshot_001.jpeg"><img class="aligncenter size-full wp-image-450" title="screenshot_001" src="http://www.gsdesign.ro/blog/wp-content/uploads/2010/12/screenshot_001.jpeg" alt="" width="389" height="420" /></a></p>
<h3>Design Details</h3>
<p><strong>Products have an id_configuration</strong><br />
A configurable products actually is a collection of products witch have the same id_configuration (witch is auto-generated).</p>
<p><strong>Features linked to products</strong><br />
Rather then categories, which seems more naturally to me. This enables me to easily move products between categories.</p>
<p><strong>Product features values is stored in the link table</strong><br />
I decided to store the feature value for a product in the link table. This helps with more simple queries and also it means that you don&#8217;t have to insert all the options in the feature options table (think of features that have different values for all products)</p>
<p><strong>Name and Label for features</strong><br />
The name is used internally in the admin section and Label is used in the site front-end. This is useful for features with same name. Ex: Size for clothes, size for hardisks etc.</p>
<p><strong> Filterable flag on features </strong><br />
A Yes/No flag that shows witch filters are filtrable.</p>
<h3>Examples of use</h3>
<p><strong>Selecting products</strong><br />
The most important thing is how do we select products, and how do we only show one product for the configurable ones. For this we use GROUP BY.<br />
<code class="prettyprint"><br />
SELECT * FROM `products`<br />
GROUP BY CASE `products`.`configurable` WHEN 'yes' THEN `products`.`id_configuration` ELSE `products`.`id` END<br />
</code></p>
<p><strong>Filtering products</strong><br />
The bellow example shows the query for a single filter/feature (with id 38) and 2 values selected:<br />
<code class="prettyprint"><br />
SELECT * FROM `products`<br />
WHERE `id` IN (SELECT id_product FROM `product-features` WHERE `id_feature` = 38 AND `value` IN ('Test value', 'New Value') GROUP BY id_product HAVING COUNT(*) >= 1)<br />
GROUP BY CASE `products`.`configurable` WHEN 'yes' THEN `products`.`id_configuration` ELSE `products`.`id` END<br />
</code></p>
<p><strong>Get active filters</strong><br />
After you have a list of filter products you will want to print out a list of filters that are applicable to this list, since not all are available to the current selected products.<br />
<code class="prettyprint"><br />
SELECT `id_feature` FROM `product-features`<br />
WHERE `id_product` IN (SELECT `id` FROM `products` WHERE ___YOUR_CONDITIONS____) GROUP BY `id_feature`<br />
</code><br />
<em>Notice that i left out the GROUP BY from the product subselect.</em></p>
<p><strong>Associate count of products for a filter</strong><br />
Its very useful to show the count of products for a certain value of a filter. The bellow query is how you can select that count for one filter.<br />
<code class="prettyprint"><br />
SELECT *, COUNT(*) AS `count` FROM (<br />
    SELECT *<br />
    FROM `product-features`<br />
    WHERE<br />
        `id_product` IN (SELECT `id` FROM `products` WHERE ___YOUR_CONDITIONS____) AND<br />
        `id_feature` = 36<br />
) AS `tbl` GROUP BY `value`<br />
</code><br />
<em>Notice that i left out the GROUP BY from the product subselect.</em></p>
<h3>Conclusions</h3>
<p>I think this database model works best for what i wanted and it has all the flexibility i needed:<br />
- it allows for any 2 products to group as configurable<br />
- you can add promotions and separate images for each variation<br />
- have separate stocks on each variation (witch make more sense to me)<br />
- get sales report cumulate or separate on each variation.</p>
<p>Hope you like this approach and i await you comments on it.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/77hWi-n82awddzxqYC2ECB-vflI/0/da"><img src="http://feedads.g.doubleclick.net/~a/77hWi-n82awddzxqYC2ECB-vflI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/77hWi-n82awddzxqYC2ECB-vflI/1/da"><img src="http://feedads.g.doubleclick.net/~a/77hWi-n82awddzxqYC2ECB-vflI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/DG2xcAH_EOM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/database-design-example-for-a-configurable-product-eshop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/database-design-example-for-a-configurable-product-eshop/</feedburner:origLink></item>
		<item>
		<title>Error: svn attempt to write a readonly database, commit failed</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/eXrXToZBw0s/</link>
		<comments>http://www.gsdesign.ro/blog/error-svn-attempt-to-write-a-readonly-database-commit-failed/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 14:07:20 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[php advanced]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=446</guid>
		<description><![CDATA[After upgrading our server subversion to 1.6.2 on a new repo i run into this error when commiting: svn attempt to write a readonly database commit failed Although if i looked at the repo the commited files were there. After hunting Google a bit, I found the problem to be with the &#8220;/svn/repopath/db/rep-cache.db&#8221; file that [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading our server subversion to 1.6.2 on a new repo i run into this error when commiting:</p>
<blockquote><p>
svn attempt to write a readonly database<br />
<strong>commit failed</strong>
</p></blockquote>
<p>Although if i looked at the repo the commited files were there.</p>
<p>After hunting Google a bit, I found the problem to be with the <strong>&#8220;/svn/repopath/db/rep-cache.db&#8221;</strong> file that did not have write permissions for the user subversion uses.<br />
After fixing permissions, committing went perfectly with no errors. </p>
<p>Hope it helps.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/R_4m6B3d8zDJxsuGGXdjfnkpbNg/0/da"><img src="http://feedads.g.doubleclick.net/~a/R_4m6B3d8zDJxsuGGXdjfnkpbNg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/R_4m6B3d8zDJxsuGGXdjfnkpbNg/1/da"><img src="http://feedads.g.doubleclick.net/~a/R_4m6B3d8zDJxsuGGXdjfnkpbNg/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/eXrXToZBw0s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/error-svn-attempt-to-write-a-readonly-database-commit-failed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/error-svn-attempt-to-write-a-readonly-database-commit-failed/</feedburner:origLink></item>
		<item>
		<title>Access Dropbox.com behind corporate / company firewall</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/hrw-XSpcD_M/</link>
		<comments>http://www.gsdesign.ro/blog/access-dropbox-com-behind-corporate-company-firewall/#comments</comments>
		<pubDate>Wed, 19 May 2010 08:05:52 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[hosts]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=435</guid>
		<description><![CDATA[If you find yourself one morning with your dropbox client not connecting to the server, and you trace the problem to the company/ISP ( or country if your in China :-p ) firewall then you can put the kind words for them to the side a little and try the following. Most of the firewalls [...]]]></description>
			<content:encoded><![CDATA[<p>If you find yourself  one morning with your dropbox client not connecting to the server, and you trace the problem to the company/ISP ( or country if your in China :-p ) firewall then you can put the kind words for them to the side a little and try the following.<br />
Most of the firewalls block the main IP for dropbox.com 174.36.30.70 but the alternate IP is open <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So add this to your hosts:<br />
<code>174.36.30.71 www.dropbox.com</code></p>
<p>Hope it works for you.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/ile7tXj6uvYqHP5TohNJijsO8Rk/0/da"><img src="http://feedads.g.doubleclick.net/~a/ile7tXj6uvYqHP5TohNJijsO8Rk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ile7tXj6uvYqHP5TohNJijsO8Rk/1/da"><img src="http://feedads.g.doubleclick.net/~a/ile7tXj6uvYqHP5TohNJijsO8Rk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/hrw-XSpcD_M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/access-dropbox-com-behind-corporate-company-firewall/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/access-dropbox-com-behind-corporate-company-firewall/</feedburner:origLink></item>
		<item>
		<title>php adwords api library</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/1iR8B2HFjrQ/</link>
		<comments>http://www.gsdesign.ro/blog/php-adwords-api-library/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 17:45:13 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[php classes]]></category>
		<category><![CDATA[adword]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=425</guid>
		<description><![CDATA[Recently i posted on google code a library we developed to interact with Adwords Api from php. Php Adwords API Library was developed by Hyperactive team for an internal project, since we didn&#8217;t like options available and felt we could do something that would be easier to work with, at least for us. We made [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i posted on google code a library we developed to interact with Adwords Api from php.<br />
<strong>Php Adwords API Library</strong> was developed by <a href="http://www.hyperactive.ro/">Hyperactive team</a> for an internal project, since we didn&#8217;t like <a href="http://code.google.com/intl/ro-RO/apis/adwords/docs/clients.html">options available</a> and felt we could do something that would be easier to work with, at least for us. We made it public so that others looking for a php library to interact with adwords api would have more options to chose from ( plus free testing for us :-p ).</p>
<p>The project can be found here:<br />
<a href="http://code.google.com/p/php-adwords-api/">http://code.google.com/p/php-adwords-api/</a></p>
<p>It is still a work in progress and does not yet support all the services and functions of the API, but we hope to add more services as soon as possible. And if you need a certain service or function please dont hesitate to add a ticket on google code and request it.</p>
<p>You will find examples of usage in the folder examples of the library.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/a_C8nNQiYeKcVOZw1tU_urP8I1c/0/da"><img src="http://feedads.g.doubleclick.net/~a/a_C8nNQiYeKcVOZw1tU_urP8I1c/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/a_C8nNQiYeKcVOZw1tU_urP8I1c/1/da"><img src="http://feedads.g.doubleclick.net/~a/a_C8nNQiYeKcVOZw1tU_urP8I1c/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/1iR8B2HFjrQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/php-adwords-api-library/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/php-adwords-api-library/</feedburner:origLink></item>
		<item>
		<title>PDF Generation with Zend Framework</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/WOsivpZv404/</link>
		<comments>http://www.gsdesign.ro/blog/pdf-generation-with-zend-framework/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 18:54:46 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[generation]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=402</guid>
		<description><![CDATA[Guest Post by: Jonathan Maron has been working in the web application conceptualization and development space since 1996. His current position is with an international company, specialized in the production of word processing components. Being an advocate of the FOSS movement, Jonathan promotes the use of Open Source software and rejects the notion of reinventing [...]]]></description>
			<content:encoded><![CDATA[<div style="background-color:#F8F8EE;padding:4px;"><img src="http://a1.twimg.com/profile_images/94865980/39d66a8cf.7605677.jpg" alt="Jonathan Maron" align="left" height="120" style="margin-right:5px;" /><em>Guest Post by:</em><br />
<strong>Jonathan Maron</strong> has been working in the web application conceptualization and development space since 1996. His current position is with an international company, specialized in the production of word processing components. Being an advocate of the FOSS movement, Jonathan promotes the use of Open Source software and rejects the notion of reinventing the wheel, preferring to develop with established frameworks.</div>
<p>Generating print-ready well-formatted PDF documents with PHP is not an easy task. Traditionally, there are two main approaches to PDF generation with PHP. Given sufficient time and patience, both partially get the job done, but still leave a lot to be desired:</p>
<p><strong>HTML-to-PDF</strong>: This approach is widely used in mainstream applications. Here an HTML document is programmatically created and converted to a PDF, using one of the many open source libraries <sup><a href="#foot-01">1</a></sup>. Since HTML, however, is not a page-oriented format (as is PDF), it is impossible to perform a 1-to-1 mapping between HTML and PDF. Typical word processing file format features, such as header and footers, orphans and widows or even page numbers can simply not be represented in HTML.<br />
<span id="more-402"></span></p>
<h2>Table of contents</h2>
<ul>
<li><a href="#A-completely-new-approach">A completely new approach</a></li>
<li><a href="#Introducing-LiveDocx">Introducing LiveDocx</a></li>
<li><a href="#Templates-and-documents">Templates and documents</a></li>
<li><a href="#Using-LiveDocx">Using LiveDocx</a>
<ul>
<li><a href="#Creating-a-template-in-Microsoft--Word-2007">Creating a template in Microsoft® Word 2007</a></li>
<li><a href="#Assigning-scalar-data-types-in-LiveDocx">Assigning scalar data types in LiveDocx</a></li>
<li><a href="#Assigning-compound-data-types-in-LiveDocx">Assigning compound data types in LiveDocx</a></li>
<li><a href="#Generating-image-files-with-LiveDocx">Generating image files with LiveDocx</a></li>
</ul>
</li>
<li><a href="#Deploying-LiveDocx-in-your-own-applications">Deploying LiveDocx in your own applications</a></li>
<li><a href="#Learn-more">Learn more</a>
<ul>
<li><a href="#LiveDocx-in-PHP-5">LiveDocx in PHP 5</a></li>
<li><a href="#LiveDocx-SOAP-service">LiveDocx SOAP service</a></li>
</ul>
</li>
<li><a href="#Footnotes">Footnotes</a></li>
</ul>
<p><strong>Programmatic</strong>: This approach offers total control of the resulting PDF. However, it requires that the x and y coordinates of every line of text, every geometrical shape and graphic be set from program code <sup><a href="#foot-02">2</a></sup>. Not only is this an extremely time-consuming solution, but is also very brittle: Every time a graphical designer changes the layout of a document, a programmer must re-work his or her program code.</p>
<p><a name="A-completely-new-approach"></a></p>
<h2>A completely new approach</h2>
<p>In this article, the author presents an entirely new, third approach. It relies on templates being created in a WYSIWYG environment, such as Microsoft® Word or Open Office, and then being populated with data in PHP. The resulting document can be saved not only to PDF, but also DOCX, DOC and RTF.</p>
<p>Before we delve into a technical discussion on the inner workings of this new approach, let us first take a look at a practical example. The following PHP 5 code illustrates PDF generation, in which the merge fields <em>software</em>, <em>licensee</em> and <em>company</em> in the template <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-template.docx">template.docx</a> <small>[46.7 KB]</small> are populated with scalar data in PHP. The resulting document <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-document.pdf">document.pdf</a> <small>[104.7 KB]</small> is created and written to disk.</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showCodeTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Service_LiveDocx_MailMerge<span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'username'</span> =&gt; <span style="color:#FF0000;">'yourUsername'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'password'</span> =&gt; <span style="color:#FF0000;">'yourPassword'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">setLocalTemplate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'template.docx'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'software'</span>, <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'licensee'</span>, <span style="color:#FF0000;">'Henry Smith'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'company'</span>,&nbsp; <span style="color:#FF0000;">'Megasoft Co-operation'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">createDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$document</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">retrieveDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">file_put_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'document.pdf'</span>, <span style="color:#0000FF;">$document</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/unset"><span style="color:#000066;">unset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$phpLiveDocx</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The code demonstrated in this article will be shipped with the <a href="http://is.gd/3Qo5v">Zend Framework 1.10</a> when it becomes available. Although at the time of writing, there is no official release date, 1.10 is expected to release in Q4 2009. In the meantime, you can check the components out of the <a href="http://is.gd/3RHxJ">Standard Incubator</a> SVN repository.</p>
<p><a name="Introducing-LiveDocx"></a></p>
<h2>Introducing LiveDocx</h2>
<p><a href="http://is.gd/3QmRf">LiveDocx</a> is a <a href="http://is.gd/3Qn3m">SOAP</a>-based document generation service, based on the market-leading, word processing component <a href="http://is.gd/3QmUe">TX Text Control .NET</a>. LiveDocx allows word processing templates to be populated in any programming language that supports SOAP. The resulting document can be saved to any supported format. This article, however, concentrates on using LiveDocx in PHP 5.</p>
<p>The components of the Zend Framework implementation of LiveDocx are located at <em>/Zend/Service/LiveDocx/</em> in the standard Zend Framework distribution file. It is possible to use LiveDocx directly with the PHP 5 <a href="http://is.gd/3QmK5">SoapClient</a>, without the Zend Framework, and with the third party library <a href="http://is.gd/3QmMu">NuSOAP</a>. The NuSOAP approach even allows LiveDocx to be used in PHP 4. This article, however, concentrates on the official Zend Framework components in PHP 5.</p>
<p><a name="Templates-and-documents"></a></p>
<h2>Templates and documents</h2>
<p>Throughout this article, we refer to the terms <em>templates</em> and <em>documents</em>. It is important to understand the difference between the two.</p>
<p><strong>Templates</strong>: The term <em>template</em> is used to refer to the input file, containing formatting and text fields. Templates can be in any one of the following file formats:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Office_Open_XML">DOCX</a> - Office Open XML Format</li>
<li><a href="http://en.wikipedia.org/wiki/DOC_%28computing%29">DOC</a> - Microsoft® Word DOC Format</li>
<li><a href="http://en.wikipedia.org/wiki/Rich_Text_Format">RTF</a> - Rich Text Format</li>
<li><a href="http://www.textcontrol.com/">TXD</a> - TX Text Control® Format</li>
</ul>
<p>Templates can be stored either <em>locally</em> on the client machine (the one from which the SOAP request is initiated) or <em>remotely</em> on the backend server. The decision on which one you should use depends upon the kind of application you are developing.</p>
<p>If you store the templates locally, you have to transfer the template together with the data that should be populated on every request. In the case that the template remains the same on every request, this approach is very inefficient. It would be better to upload the template to the backend server once and then reference it on all subsequent requests. This way, only the data that should be populated is transfered from the client to the backend server. Most applications, using LiveDocx fall into this category.</p>
<p>On the other hand, if you have a template that is constantly changing, or an application in which you enable end-users to upload templates, you may consider storing templates locally and transfer them every request. This approach, is obviously slower, as every request contains the template itself, in addition to the data to populate it.</p>
<p><strong>Documents</strong>: The term <em>document</em> is used to refer to the generated output file that contains the template file, populated with data - i.e. the finished document. Documents can be saved in any one of the following file formats:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Office_Open_XML">DOCX</a> - Office Open XML Format</li>
<li><a href="http://en.wikipedia.org/wiki/DOC_%28computing%29">DOC</a> - Microsoft® Word DOC Format</li>
<li><a href="http://en.wikipedia.org/wiki/Xhtml">HTML</a> - XHTML 1.0 Transitional Format</li>
<li><a href="http://en.wikipedia.org/wiki/Rich_Text_Format">RTF</a> - Rich Text Format</li>
<li><a href="http://en.wikipedia.org/wiki/Portable_Document_Format">PDF</a> - Acrobat® Portable Document Format</li>
<li><a href="http://www.textcontrol.com/">TXD</a> - TX Text Control Format</li>
<li><a href="http://en.wikipedia.org/wiki/Text_file">TXT</a> - ANSI Plain Text</li>
</ul>
<p>In addition to the above word processing file formats, documents can also be saved to the following image file formats:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/BMP_file_format">BMP</a> - Bitmap Image Format</li>
<li><a href="http://en.wikipedia.org/wiki/GIF">GIF</a> - Graphics Interchange Format</li>
<li><a href="http://en.wikipedia.org/wiki/Jpg">JPG</a> - Joint Photographic Experts Group Format</li>
<li><a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics">PNG</a> - Portable Network Graphics Format</li>
<li><a href="http://en.wikipedia.org/wiki/Tagged_Image_File_Format">TIFF</a> - Tagged Image File Format</li>
<li><a href="http://en.wikipedia.org/wiki/Windows_Metafile">WMF</a> - Windows Meta File Format</li>
</ul>
<p><a name="Using-LiveDocx"></a></p>
<h2>Using LiveDocx</h2>
<p>In this section, we are going to look at the entire process of creating a document using LiveDocx from scratch.</p>
<p><a name="Creating-a-template-in-Microsoft--Word-2007"></a></p>
<h3>Creating a template in Microsoft® Word 2007</h3>
<p>The first step in any LiveDocx project is the creation of a template. To do this, you can use either Open Office or Microsoft® Word. For the purpose of this article, we are going to use Microsoft® Word 2007. For instructions on using Open Office, please take a look at the <a href="http://is.gd/3Sps0">LiveDocx Blog</a>.</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-dialog_zoom.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-dialog_zoom-300x197.png" alt="msword-dialog_zoom" title="msword-dialog_zoom" width="300" height="197" class="alignright size-medium wp-image-406" /></a></p>
<p>Start off by creating a new file in Microsoft® Word 2007 and save the template file as <em>template.docx</em>.</p>
<p>You can then start to compose the template, inserting text, graphics and merge fields with the <em>Field</em> dialog box, shown to the right.</p>
<p>After a while, you will have a template, which contains images, text and a number of merge fields. The merge fields are represented by <em>{ MERGEFIELD name }</em> and will be populated with scalar data in the next step. The follow screenshot of the template in Microsoft® Word 2007 illustrates how your template may look:</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-template_zoom.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-template_zoom-300x225.png" alt="msword-basic-template_zoom" title="msword-basic-template_zoom" width="300" height="225" class="aligncenter size-medium wp-image-407" /></a></p>
<p>Save the template <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-template.docx">template.docx</a> <small>[46 KB]</small> when you are done.</p>
<p><a name="Assigning-scalar-data-types-in-LiveDocx"></a></p>
<h3>Assigning scalar data types in LiveDocx</h3>
<p>Now that we have the template file, the next step is to populate it with data. In the following example, we are going to assign scalar data types - in this case strings - to the template.</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showCodeTxt('php-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Service_LiveDocx_MailMerge<span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'username'</span> =&gt; <span style="color:#FF0000;">'yourUsername'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'password'</span> =&gt; <span style="color:#FF0000;">'yourPassword'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">setLocalTemplate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'template.docx'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'software'</span>, <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'licensee'</span>, <span style="color:#FF0000;">'Henry Smith'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'company'</span>,&nbsp; <span style="color:#FF0000;">'Megasoft Co-operation'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'date'</span>,&nbsp; &nbsp; &nbsp;<span style="color:#FF0000;">'October 10, 2009'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'time'</span>,&nbsp; &nbsp; &nbsp;<span style="color:#FF0000;">'14:12:01'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'city'</span>,&nbsp; &nbsp; &nbsp;<span style="color:#FF0000;">'Frankfurt'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'country'</span>,&nbsp; <span style="color:#FF0000;">'Germany'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">createDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$document</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">retrieveDocument</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'pdf'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">file_put_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'document.pdf'</span>, <span style="color:#0000FF;">$document</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/unset"><span style="color:#000066;">unset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$phpLiveDocx</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>For many applications, in particular those in which PDF files are used of archiving purposes, you may wish to set the meta data of the PDF file. You can do this, by specifying an associative array with the meta data that should be embedded into the PDF file. The <em>setDocumentProperties()</em> method must be called before <em>createDocument()</em>:</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showCodeTxt('php-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$documentProperties</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'title'</span>&nbsp; &nbsp; =&gt; <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'author'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'Megasoft Co-operation'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'subject'</span>&nbsp; =&gt; <span style="color:#FF0000;">'Magic Graphical Compression Suite v1.9'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'keywords'</span> =&gt; <span style="color:#FF0000;">'Graphics, Magical, Compress, Suite, License'</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">setDocumentProperties</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$documentProperties</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The resulting document <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/license-agreement-document.pdf">document.pdf</a> <small>[104 KB]</small> is written to disk and can now be opened in your favorite PDF reader, such as the shipped <em>Document Viewer</em> in Ubuntu:</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-document_zoom2.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-basic-document_zoom2-300x240.png" alt="msword-basic-document_zoom" title="msword-basic-document_zoom" width="300" height="240" class="aligncenter size-medium wp-image-411" /></a></p>
<p><a name="Assigning-compound-data-types-in-LiveDocx"></a></p>
<h3>Assigning compound data types in LiveDocx</h3>
<p>In addition to the scalar data types, which were assigned to the template in the previous example, you can also assign compound data types, such as an associative array. Consider the template <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/telephone-bill-template.doc">template.doc</a> <small>[20.5 KB]</small> and the resulting document <a href="http://www.phplivedocx.org/wp-content/uploads/2009/01/telephone-bill-document.pdf">document.pdf</a> <small>[77.6 KB]</small>. In particular, take a look at the following section of the template (click to enlarge):</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-complex-template_zoom.png"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-complex-template_zoom-300x225.png" alt="msword-complex-template_zoom" title="msword-complex-template_zoom" width="300" height="225" class="aligncenter size-medium wp-image-412" /></a></p>
<p>The section of the template between the bookmarks<br />
<img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-bookmark.png" alt="msword-bookmark" title="msword-bookmark" width="8" height="15" class="alignnone size-full wp-image-413" /><br />
 and <img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/msword-bookmark.png" alt="msword-bookmark" title="msword-bookmark" width="8" height="15" class="alignnone size-full wp-image-413" /> is repeated in the final document to produce rows of a table. One sub-array of the following associate array is used for each row.</p>
<p>Using the following PHP 5 code, we are going to populate the template with an associative array of telephone connection data. For clarity, this example shows only the part in which an associative array is assigned. The instantiation of LiveDocx and the document creation and retrievable processes are identical to the previous examples and have been omitted:</p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showCodeTxt('php-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// instantiate LiveDocx </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$billConnections</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 441'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:01'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 442'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:02'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 443'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:03'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_number'</span>&nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'+11 (0)222 333 444'</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'connection_duration'</span> =&gt; <span style="color:#FF0000;">'00:01:04'</span>, </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fee'</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; <span style="color:#FF0000;">'1.15'</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">assign</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'connection'</span>, <span style="color:#0000FF;">$billConnections</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// create and retrieve document </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The resulting document contains the following table with the data from the assigned associate array (click to zoom):</p>
<p><a href="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/docviewer-complex-template_zoom.jpg"><img src="http://www.gsdesign.ro/blog/wp-content/uploads/2009/11/docviewer-complex-template_zoom-212x300.jpg" alt="docviewer-complex-template_zoom" title="docviewer-complex-template_zoom" width="212" height="300" class="aligncenter size-medium wp-image-416" /></a></p>
<p><a name="Generating-image-files-with-LiveDocx"></a></p>
<h3>Generating image files with LiveDocx</h3>
<p>In addition to the word processing file formats listed above that are supported by LiveDocx, you can also save the resulting documents as one or more image files. For this purpose, <em>Zend_Service_LiveDocx_MailMerge</em> offers the methods <em>getAllBitmaps()</em> and <em>getBitmaps()</em>:</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showCodeTxt('php-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// instantiate LiveDocx </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// get all bitmaps </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// (zoomFactor, format) </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$bitmaps</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">getAllBitmaps</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#FF0000;">'png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Similarly, it is possible to retrieve images for pages in a specific range:</p>
<div class="igBar"><span id="lphp-13"><a href="#" onclick="javascript:showCodeTxt('php-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-13">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// get just bitmaps in specified range </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// (fromPage, toPage, zoomFactor, format) </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$bitmaps</span> = <span style="color:#0000FF;">$phpLiveDocx</span>-&gt;<span style="color:#006600;">getBitmaps</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">2</span>, <span style="color:#CC66CC;color:#800000;">2</span>, <span style="color:#CC66CC;color:#800000;">100</span>, <span style="color:#FF0000;">'png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Note that <em>zoomFactor</em> parameter. This is a per cent value, in the range of 10% to 400%. These methods are ideally suited to generating thumbnail images of the created document, for example, to display in the browser as a preview.</p>
<p>The actual image files can be written to disk by iterating through the <em>$bitmaps</em> array. There is one page of binary data per record in the array:</p>
<div class="igBar"><span id="lphp-14"><a href="#" onclick="javascript:showCodeTxt('php-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-14">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// write to disk </span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// (one page per record) </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">foreach</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$bitmaps</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$pageNumber</span> =&gt; <span style="color:#0000FF;">$bitmapData</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$filename</span> = <a href="http://www.php.net/sprintf"><span style="color:#000066;">sprintf</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'documentPage%d.png'</span>, <span style="color:#0000FF;">$pageNumber</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; file_put_contents<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$filename</span>, <span style="color:#0000FF;">$bitmapData</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/printf"><span style="color:#000066;">printf</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Written %d bytes to disk as %s.%s'</span>, <a href="http://www.php.net/filesize"><span style="color:#000066;">filesize</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$filename</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0000FF;">$filename</span>, PHP_EOL<span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><a name="Deploying-LiveDocx-in-your-own-applications"></a></p>
<h2>Deploying LiveDocx in your own applications</h2>
<p>The code, which constitutes the PHP 5 implementation of LiveDocx, shipped in the Zend Framework, is released under the <a href="http://is.gd/3RMhL">New BSD license</a> and thus may be deployed, modified and redistributed in most projects, according to that terms of the license. The actual LiveDocx SOAP server, however, is proprietary software. There are three ways in which the SOAP service can be deployed in your own applications.</p>
<ol>
<li style="padding-bottom: 0.8em;"> <strong>Free public server</strong><br />
For the vast majority of applications, developers choose this approach. The default LiveDocx server that is referenced in the Zend Framework components is the free public server. It may be used in your own applications completely free of charge. <a href="http://is.gd/3QlkN">Sign up</a> for a LiveDocx account.</li>
<li style="padding-bottom: 0.8em;"> <strong>Premium hosted server</strong><br />
In the case that your application generates several thousand documents per hour, you may consider paying a small monthly fee to have access to your own personal LiveDocx server. In association with leading hosting providers, you can rent such a premium hosted server.</li>
<li> <strong>Local licensed server</strong><br />
In the case that your application generates more than about ten thousand documents her hour, you may consider installing a LiveDocx server in your local network. Having direct access in a local gigabit network is by far the fastest way of deploying LiveDocx.</li>
</ol>
<p><a name="Learn-more"></a></p>
<h2>Learn more</h2>
<p style="margin-bottom: 0px;">This article has scratched the surface of what you can do with LiveDocx. If you would like to learn more about this new powerful document generation platform, please take a look at the following resources:</p>
<p><a name="LiveDocx-in-PHP-5"></a></p>
<h3 style="font-size: 1em;">LiveDocx in PHP 5</h3>
<ul>
<li><a href="http://is.gd/3YySX">phpLiveDocx blog</a>.</li>
<li><a href="http://is.gd/3YyTT">phpLiveDocx technical articles</a>.</li>
</ul>
</div>
<div><a name="LiveDocx-SOAP-service"></a></p>
<h3 style="font-size: 1em;">LiveDocx SOAP service</h3>
<ul>
<li><a href="http://is.gd/3YyV8">LiveDocx blog</a>.</li>
<li><a href="http://is.gd/3YyXM">LiveDocx API reference</a>.</li>
</ul>
<p>Please do not hesitate to <a href="http://is.gd/3Yz3L">contact the author</a> or <a href="http://is.gd/3Yz56">request technical support</a> in the support forum (free of charge) at any time.</p>
<p><a name="Footnotes"></a></p>
<h2>Footnotes</h2>
<p><a name="foot-01"></a><small>[1]</small><br />
<a href="http://is.gd/3SsCE">domPDF</a>, <a href="http://is.gd/3SsPF">HTML 2 (F)PDF</a>, <a href="http://is.gd/3SsS3">HTML_ToPDF</a>, <a href="http://is.gd/3SsUM">mPDF</a> etc.</p>
<p><a name="foot-02"></a><small>[2]</small> <a href="http://is.gd/3SsWJ">Zend_Pdf</a>, <a href="http://is.gd/3SsYi">PDFlib</a>, <a href="http://is.gd/3St08">FPDF</a>, <a href="http://is.gd/3St1W">Cpdf</a> etc.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Lcb7pPDqCmxFdwddnPK8vbzd074/0/da"><img src="http://feedads.g.doubleclick.net/~a/Lcb7pPDqCmxFdwddnPK8vbzd074/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Lcb7pPDqCmxFdwddnPK8vbzd074/1/da"><img src="http://feedads.g.doubleclick.net/~a/Lcb7pPDqCmxFdwddnPK8vbzd074/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/WOsivpZv404" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/pdf-generation-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/pdf-generation-with-zend-framework/</feedburner:origLink></item>
		<item>
		<title>Running for charity</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/vGiN5RvNmfk/</link>
		<comments>http://www.gsdesign.ro/blog/running-for-charity/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 05:00:30 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=400</guid>
		<description><![CDATA[I havent posted in a while, will try and restart, but for now i am writing this non-geek related post. I'm taking part in the Berlin Marathon 2009 on 20/09/2009 to raise money for British Heart Foundation and would really welcome your support. Please take a moment to sponsor me. It's really easy - you [...]]]></description>
			<content:encoded><![CDATA[<p>I havent posted in a while, will try and restart, but for now i am writing this non-geek related post.</p>
<p>I'm taking part in the Berlin Marathon 2009 on 20/09/2009 to raise money for British Heart Foundation and would really welcome your support.</p>
<p>Please take a moment to sponsor me. It's really easy - you can donate online by credit or debit card at the following address:</p>
<p><a href="http://original.justgiving.com/gabrielsolomon">http://original.justgiving.com/gabrielsolomon</a></p>
<p>All donations are secure and sent electronically to British Heart Foundation.  If you are a UK taxpayer, Justgiving will add an automatic 28% bonus to your donation at no cost to you.  Please join me in supporting British Heart Foundation and a fabulous cause!</p>
<p>Thanks and best wishes.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/KeSMCvWY0JAZq1gUUwOLruaok9o/0/da"><img src="http://feedads.g.doubleclick.net/~a/KeSMCvWY0JAZq1gUUwOLruaok9o/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/KeSMCvWY0JAZq1gUUwOLruaok9o/1/da"><img src="http://feedads.g.doubleclick.net/~a/KeSMCvWY0JAZq1gUUwOLruaok9o/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/vGiN5RvNmfk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/running-for-charity/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/running-for-charity/</feedburner:origLink></item>
		<item>
		<title>Replication / Mirroring as Master-master with Subversion using svnsync</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/PC7xqTm5F-o/</link>
		<comments>http://www.gsdesign.ro/blog/replication-mirroring-as-master-master-with-subversion-using-svnsync/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 20:29:38 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[php advanced]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svk]]></category>
		<category><![CDATA[svnsync]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=398</guid>
		<description><![CDATA[For me it all started when my VPS had an error and all my SVN repos were lost. Plus even though i had purchased a backup system from the hosting company that was suppose to do a full server backup automatic and incrementally, i only had a backup from 20 days earlier because the system [...]]]></description>
			<content:encoded><![CDATA[<p>For me it all started when my VPS had an error and all my SVN repos were lost. Plus even though i had purchased a backup system from the hosting company that was suppose to do a full server backup automatic and incrementally, i only had a backup from 20 days earlier because the system failed at that point in time and didnt run since.</p>
<p>But enough with my problems, at that point i decided to make a copy of my repos from the remote server to my local machine.<br />
And i would commit into the local one and it should automaticly sync to the remote one. Plus it would need to do this both ways and in real time since i had some external people commiting in the remote server. Easier said then done i camed to find out.</p>
<h3>The reasons why</h3>
<p>Well for me there are 3 main reasons:<br />
1. as a backup system ( dont want to be put in the 20 days old backup situation again )<br />
2. for faster commits and updates<br />
3. independent of the internet connection ( it hasnt failed in quite a while, but just in case, or for the times its a bit slow )</p>
<h3>The alternatives</h3>
<p>It seems that this topic is a bit popular, and there are a few places on the internet where people are interested in this. You can check out <a href="http://stackoverflow.com/questions/148625/how-to-get-master-master-replication-with-subversion">this question on stackoverflow</a> for one.</p>
<p><strong>1. Git-SVN</strong><br />
This is one alternative that a lot of people have been recommended. The benefits they are you get the best out of both worlds, you can still use the Subversion in the main repo, but you get the power of GIT for your local copy.<br />
Although this sounds very cool, i am more of a GUI guy and really enjoy the subversion integration in my IDE ( <a href="http://www.gsdesign.ro/blog/netbeans-review/">Netbeans</a> ) so i would have to pass this options.</p>
<p><strong>2. SVK</strong></p>
<blockquote><p>
svk is a decentralized version control system built with the robust Subversion filesystem. It supports repository mirroring, disconnected operation, history-sensitive merging, and integrates with other version control systems, as well as popular visual merge tools.
</p></blockquote>
<p>At first i read <a href="http://lajavaloca.wordpress.com/2008/06/03/using-svk-to-synchronize-svn-repositories/">this article</a> about SVK and it seemed to be what i was looking for. But after playing with it for a while i saw that i would need to have a single repo where all my comits would go and that would be synced to several outside repos. But i was looking for a way to have the exact replica of what it is on the remote server so in the case of a failure i could restore them from my backup.</p>
<p>If you are still interested in this you can also read <a href="http://svk.bestpractical.com/view/UsingSVKAsARepositoryMirroringSystem">this</a> and <a href="http://developer.mindtouch.com/User:PeteE/Synchronizing_SVN_Repositories_With_Svk">this</a>.</p>
<p><strong>3. svnsync + webdav proxy</strong><br />
I knew about svnsync but it only supports read-only copies of your repo. But after reading a small comment on stackoverflow i started looking and find out you can have read-write copies using svnsync and webdav proxy.<br />
What is basicly happening is that your local copy handles the read operations and it forwards the commits to the main repo.</p>
<p>There are a few tricky parts on this solution, that involve the locks and updating of all the replicas of the main repo. This are done by a series of hooks in the main repo.<br />
If youre interested in this solution you can find information about implementing it in this articles:<br />
<a href="http://www.tty1.net/blog/2007-08-26-subversion-proxy_en.html">Subversion transparent proxy with svnsync + webdav proxy</a><br />
<a href="http://www.rvo-consulting.com/2008/02/21/subversion-diy-write-through-proxy/">subversion diy write through proxy</a><br />
<a href="http://www.slideshare.net/normanmaurer/apacheconeusvnreplication">Subversion on-the-fly replication</a></p>
<h3>conclusion</h3>
<p>Honestly i don't have one yet <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> , but i plant to try using svnsnyc and see how that goes.<br />
I hope you got a big picture of what your options are and now you can decide what suits you best.</p>
<p>Cheers</p>

<p><a href="http://feedads.g.doubleclick.net/~a/PW3bQFc1_yoP3Qopn1aDn7rblMI/0/da"><img src="http://feedads.g.doubleclick.net/~a/PW3bQFc1_yoP3Qopn1aDn7rblMI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/PW3bQFc1_yoP3Qopn1aDn7rblMI/1/da"><img src="http://feedads.g.doubleclick.net/~a/PW3bQFc1_yoP3Qopn1aDn7rblMI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/PC7xqTm5F-o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/replication-mirroring-as-master-master-with-subversion-using-svnsync/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/replication-mirroring-as-master-master-with-subversion-using-svnsync/</feedburner:origLink></item>
		<item>
		<title>audit_log_user_command(): Connection refused</title>
		<link>http://feedproxy.google.com/~r/gsdesign/bzmE/~3/R1e8J2yUz0E/</link>
		<comments>http://www.gsdesign.ro/blog/audit_log_user_command-connection-refused/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 18:54:22 +0000</pubDate>
		<dc:creator>Gabi Solomon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://www.gsdesign.ro/blog/?p=396</guid>
		<description><![CDATA[This error happend to me when i runned a command on my Centos VPS. audit_log_user_command(): Connection refused And after some googling it seems that a lot of Centos users are running into this when executing SUDO. But it seens that this is a bug in Centos kernel, and its not fixed yet. My problem was [...]]]></description>
			<content:encoded><![CDATA[<p>This error happend to me when i runned a command on my Centos VPS. </p>
<blockquote><p>
audit_log_user_command(): Connection refused
</p></blockquote>
<p>And after some googling it seems that a lot of Centos users are running into this when executing SUDO.<br />
But it seens that this is a bug in Centos kernel, and its not fixed yet.<br />
My problem was that i was running the commands logged as root ( silly me ).<br />
Hope you are too, because otherwise i have no sollution for you <img src='http://www.gsdesign.ro/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .</p>
<p>Cheers</p>

<p><a href="http://feedads.g.doubleclick.net/~a/6kXFGg6sPCikkjKhHxPsF_9BzDo/0/da"><img src="http://feedads.g.doubleclick.net/~a/6kXFGg6sPCikkjKhHxPsF_9BzDo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/6kXFGg6sPCikkjKhHxPsF_9BzDo/1/da"><img src="http://feedads.g.doubleclick.net/~a/6kXFGg6sPCikkjKhHxPsF_9BzDo/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/gsdesign/bzmE/~4/R1e8J2yUz0E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.gsdesign.ro/blog/audit_log_user_command-connection-refused/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.gsdesign.ro/blog/audit_log_user_command-connection-refused/</feedburner:origLink></item>
	</channel>
</rss>

