瀏覽代碼

Adding new documentation for release v4.5.0

Jonny Wenmoth 9 年之前
父節點
當前提交
b1886a3295

二進制
.jekyll-metadata


+ 1 - 1
_site/3.0/2-installation/index.html

@@ -329,7 +329,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 1 - 1
_site/3.0/3-usage/index.html

@@ -528,7 +528,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 1 - 1
_site/3.0/4-advanced/index.html

@@ -558,7 +558,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 1 - 1
_site/3.0/5-troubleshooting/index.html

@@ -467,7 +467,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 2 - 2
_site/3.0/index.html

@@ -191,7 +191,7 @@
 
 <ul>
   <li>Load webpages through the PhantomJS headless browser</li>
-  <li>View detailed response data including page content, headers, status<br />
+  <li>View detailed response data including page content, headers, status
 code etc.</li>
   <li>Handle redirects</li>
   <li>View javascript console errors</li>
@@ -323,7 +323,7 @@ code etc.</li>
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 1 - 1
_site/4.0/2-installation/index.html

@@ -320,7 +320,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 68 - 1
_site/4.0/3-usage/index.html

@@ -204,8 +204,10 @@
   <li><a href="#screen-captures">Screen Captures</a></li>
   <li><a href="#output-to-pdf">Output To PDF</a></li>
   <li><a href="#set-viewport-size">Set Viewport Size</a></li>
+  <li><a href="#set-background-color">Set Background Color</a></li>
   <li><a href="#custom-timeout">Custom Timeout</a></li>
   <li><a href="#delay-page-render">Delay Page Render</a></li>
+  <li><a href="#on-load-finished">On Load Finished</a></li>
   <li><a href="#phantomjs-options">PhantomJS Options</a></li>
   <li><a href="#exceptions">Exceptions</a></li>
 </ul>
@@ -429,6 +431,11 @@
     <span class="o">...</span>
     </code></pre></figure>
 
+<blockquote>
+  <h4 id="note-2">Note</h4>
+  <p>Sometimes you may want to wait for all the resources on the page to load before saving a capture to disk. This can be achieved by either <a href="#delay-page-render">delaying the page render</a> or <a href="#on-load-finished">waiting for all resources to load</a>.</p>
+</blockquote>
+
 <h2 id="output-to-pdf">Output To PDF</h2>
 
 <p>You can output a page to PDF by creating a PDF request and setting the path you wish to save the document to.</p>
@@ -448,6 +455,19 @@
     
     <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">send</span><span class="p">(</span><span class="nv">$request</span><span class="p">,</span> <span class="nv">$response</span><span class="p">);</span></code></pre></figure>
 
+<p>You can set an optional repeating header and/or footer to the PDF output.</p>
+
+<figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x">    </span><span class="cp">&lt;?php</span>
+
+    <span class="o">...</span>
+    
+    <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setRepeatingHeader</span><span class="p">(</span><span class="s1">&#39;&lt;h1&gt;Header &lt;span style=&quot;float:right&quot;&gt;%pageNum% / %pageTotal%&lt;/span&gt;&lt;/h1&gt;&#39;</span><span class="p">[,</span> <span class="nx">height</span><span class="p">]);</span>
+    <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setRepeatingFooter</span><span class="p">(</span><span class="s1">&#39;&lt;footer&gt;Footer &lt;span style=&quot;float:right&quot;&gt;%pageNum% / %pageTotal%&lt;/span&gt;&lt;/footer&gt;&#39;</span><span class="p">[,</span> <span class="nx">height</span><span class="p">]);</span>
+    
+    <span class="o">...</span></code></pre></figure>
+
+<p>The <code>setRepeatingHeader</code> and <code>setRepeatingFooter</code> methods take an optional second parameter that allows you to set the height of the header and/or footer. This defaults to <code>1cm</code>. You may also use the <code>%pageNum%</code> and <code>%pageTotal%</code> placeholders to output the current page and total page count for each. Inline styles can be applied to the injected header and footer tags allowing you to define the look and feel.</p>
+
 <p>You can set the paper size and margin of the PDF.</p>
 
 <figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x">    </span><span class="cp">&lt;?php</span>
@@ -490,6 +510,11 @@
     <span class="o">...</span>
     </code></pre></figure>
 
+<blockquote>
+  <h4 id="note-3">Note</h4>
+  <p>Sometimes you may want to wait for all the resources on the page to load before outputting to PDF. This can be achieved by either <a href="#delay-page-render">delaying the page render</a> or <a href="#on-load-finished">waiting for all resources to load</a>.</p>
+</blockquote>
+
 <h2 id="set-viewport-size">Set Viewport Size</h2>
 
 <p>You can easily set the viewport size for a request:</p>
@@ -507,6 +532,24 @@
     <span class="o">...</span>
     </code></pre></figure>
 
+<h2 id="set-background-color">Set Background Color</h2>
+
+<p>You can force the background color of the requested page by setting  a <code>backgroundColor</code> body style:</p>
+
+<figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x">    </span><span class="cp">&lt;?php</span>
+
+    <span class="o">...</span>
+    
+    <span class="nv">$request</span>  <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createRequest</span><span class="p">(</span><span class="s1">&#39;http://jonnyw.me&#39;</span><span class="p">);</span>
+    <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setBodyStyles</span><span class="p">(</span><span class="k">array</span><span class="p">(</span>
+        <span class="s1">&#39;backgroundColor&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;#ff0000&#39;</span>
+    <span class="p">));</span>
+    
+    <span class="o">...</span>
+    </code></pre></figure>
+
+<p>The <code>setBodyStyles</code> method can be used to set any valid CSS styles on the body tag; it is not limited to just background color.</p>
+
 <h2 id="custom-timeout">Custom Timeout</h2>
 
 <p>By default, each request will timeout after 5 seconds. You can set a custom timeout period (in milliseconds) for each request:</p>
@@ -539,6 +582,30 @@
     <span class="o">...</span>
     </code></pre></figure>
 
+<h2 id="on-load-finished">On Load Finished</h2>
+
+<p>Another way of delaying the page render is to wait until all the resources on the page have finished loading. This includes things like images, AJAX requests etc. This can be achieved by telling the client to lazy load the request.</p>
+
+<figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x">    </span><span class="cp">&lt;?php</span>
+
+    <span class="o">...</span>
+    
+    <span class="k">use</span> <span class="nx">JonnyW\PhantomJs\Client</span><span class="p">;</span>
+    
+    <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
+    <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">isLazy</span><span class="p">();</span> <span class="c1">// Tells the client to wait for all resources before rendering</span>
+
+    <span class="nv">$request</span>  <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createRequest</span><span class="p">();</span>
+    <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setTimeout</span><span class="p">(</span><span class="mi">5000</span><span class="p">);</span> <span class="c1">// Will render page if this timeout is reached and resources haven&#39;t finished loading</span>
+
+    <span class="o">...</span>
+    </code></pre></figure>
+
+<blockquote>
+  <h4 id="note-4">Note</h4>
+  <p>It is recommended that you set a timeout on the request when lazy loading. This guarantees that the request will return content after a period of time even if page resources are still loading. Without this you may run into issues on pages that poll resources at short intervals.</p>
+</blockquote>
+
 <h2 id="phantomjs-options">PhantomJS Options</h2>
 
 <p>The PhantomJS API contains a range of command line options that can be passed when executing the PhantomJS executable. These can also be passed in via the client before a request:</p>
@@ -642,7 +709,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 21 - 17
_site/4.0/4-custom-scripts/index.html

@@ -230,59 +230,63 @@
   </thead>
   <tbody>
     <tr>
-      <td><a href="http://">global_variables.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/global_variables.partial">global_variables.partial</a></td>
       <td>Allows any javascript variables to be injected at the top of the script.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_clip_rect.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_clip_rect.partial">page_clip_rect.partial</a></td>
       <td>If the request is a screen capture, this will define the page clipping rectangle.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_custom_headers.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_custom_headers.partial">page_custom_headers.partial</a></td>
       <td>Set any custom headers on the page object.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_on_error.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_on_error.partial">page_on_error.partial</a></td>
       <td>Defines the code that is executed on page error.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_on_resource_received.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_on_resource_received.partial">page_on_resource_received.partial</a></td>
       <td>Defines the code that is executed on resource receive.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_on_resource_timeout.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_on_resource_timeout.partial">page_on_resource_timeout.partial</a></td>
       <td>Defines the code that is executed on resource timeout.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_open.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_open.partial">page_open.partial</a></td>
       <td>Defines the code that is executed on page open.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_paper_size.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_paper_size.partial">page_paper_size.partial</a></td>
       <td>If the request is PDF output, this will set up the paper size.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_settings.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_settings.partial">page_settings.partial</a></td>
       <td>Defines any page settings most notably the resource timeout value.</td>
     </tr>
     <tr>
-      <td><a href="http://">page_viewport_size.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_viewport_size.partial">page_viewport_size.partial</a></td>
       <td>Set up the viewport size if defined in the request.</td>
     </tr>
     <tr>
-      <td><a href="http://">phantom_on_error.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/page_body_styles.partial">page_body_styles.partial</a></td>
+      <td>Set CSS styles on the body tag of the requested page.</td>
+    </tr>
+    <tr>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/phantom_on_error.partial">phantom_on_error.partial</a></td>
       <td>Defines the code that is execute on PhantomJS error.</td>
     </tr>
     <tr>
-      <td><a href="http://">procedure_capture.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/procedure_capture.partial">procedure_capture.partial</a></td>
       <td>Defines the code that is executed if the request is a capture request.</td>
     </tr>
     <tr>
-      <td><a href="http://">procedure_default.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/procedure_default.partial">procedure_default.partial</a></td>
       <td>Defines the code that is executed for a default request.</td>
     </tr>
     <tr>
-      <td><a href="http://">procedure_pdf.partial</a></td>
+      <td><a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/procedure_pdf.partial">procedure_pdf.partial</a></td>
       <td>Defines the code that is executed if the request is a PDF request.</td>
     </tr>
   </tbody>
@@ -290,7 +294,7 @@
 
 <blockquote>
   <h4 id="note-1">Note</h4>
-  <p>It may pay to check out the <a href="http://">default script template</a> to see where each of these blocks are rendered when compiling the PhantomJS script.</p>
+  <p>It may pay to check out the <a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/http_default.proc">default script template</a> to see where each of these blocks are rendered when compiling the PhantomJS script.</p>
 </blockquote>
 
 <p>To override a partial block with your own code first you need to create a file with the same name as the block that you are overriding. Make sure that this file can be read by your application.</p>
@@ -513,7 +517,7 @@
 
 <blockquote>
   <h4 id="note-5">Note</h4>
-  <p>You may choose to support <a href="#partial-script-injection">partial script blocks</a> in your template. It is worth checking out the <a href="http://">default script template</a> to get an idea on how this is achieved.</p>
+  <p>You may choose to support <a href="#partial-script-injection">partial script blocks</a> in your template. It is worth checking out the <a href="https://github.com/jonnnnyw/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Resources/procedures/http_default.proc">default script template</a> to get an idea on how this is achieved.</p>
 </blockquote>
 
 <h2 id="using-custom-request-parameters-in-your-script">Using custom request parameters in your script</h2>
@@ -732,7 +736,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 1 - 1
_site/4.0/5-caching/index.html

@@ -277,7 +277,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 2 - 2
_site/4.0/6-debugging/index.html

@@ -211,7 +211,7 @@
     <span class="k">use</span> <span class="nx">JonnyW\PhantomJs\Client</span><span class="p">;</span>
 
     <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
-    <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">debug</span><span class="p">(</span><span class="k">true</span><span class="p">);</span></code></pre></figure>
+    <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getEngine</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">debug</span><span class="p">(</span><span class="k">true</span><span class="p">);</span></code></pre></figure>
 
 <p>The client log can be inspected after making a request.</p>
 
@@ -290,7 +290,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 1 - 1
_site/4.0/7-troubleshooting/index.html

@@ -222,7 +222,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 14 - 17
_site/4.0/index.html

@@ -193,18 +193,13 @@
 	<div class="col-sm-10">
       
 	  <div class="article_body">
-	  <blockquote>
-  <h4 id="important">Important</h4>
-  <p>Currently when installing PHP PhantomJS on <strong>Linux OS</strong> you will need to compile your own version of PhantomJS for your system. This is due to an <a href="https://github.com/ariya/phantomjs/issues/12948">unresolved issue</a> with the PhantomJS Linux packages. An Ubuntu compiled version will be installed by default but this may not be compatible with your system.</p>
-</blockquote>
-
-<p>PHP PhantomJS is a flexible PHP library to load pages through the PhantomJS headless browser and return the page response. It is handy for testing websites that demand javascript support and also supports screen captures and PDF output.</p>
+	  <p>PHP PhantomJS is a flexible PHP library to load pages through the PhantomJS headless browser and return the page response. It is handy for testing websites that demand javascript support and also supports screen captures and PDF output.</p>
 
 <h2 id="feature-list">Feature List</h2>
 
 <ul>
   <li>Load webpages through the PhantomJS headless browser</li>
-  <li>View detailed response data including page content, headers, status<br />
+  <li>View detailed response data including page content, headers, status
 code etc.</li>
   <li>Handle redirects</li>
   <li>View javascript console errors</li>
@@ -212,8 +207,10 @@ code etc.</li>
   <li>Save screen captures to local disk</li>
   <li>Output web pages to PDF document</li>
   <li>Set viewport size</li>
+  <li>Set fixed header and footer for PDF output</li>
   <li>Define screen capture x, y, width and height parameters</li>
   <li>Delay page rendering for a specified time</li>
+  <li>Delay page rendering until page resources are fully loaded</li>
   <li>Execute PhantomJS with command line options</li>
   <li>Easily build and run custom PhantomJS scripts</li>
 </ul>
@@ -255,10 +252,10 @@ code etc.</li>
     
     <span class="nv">$ </span>composer require <span class="s2">&quot;jonnyw/php-phantomjs:4.*&quot;</span></code></pre></figure>
 
-<p>If you would like to use another installation method or would like to see more detailed installation instructions, see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/installation/">installation</a> documentation.</p>
+<p>If you would like to use another installation method or would like to see more detailed installation instructions, see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/2-installation/">installation</a> documentation.</p>
 
 <blockquote>
-  <h4 id="important-1">Important</h4>
+  <h4 id="important">Important</h4>
   <p>By default the PhantomJS library will look for the PhantomJS executable in the bin folder relative to where your script is running <code>~/bin/phantomjs</code>. If the executable cannot be found or if the path to your PhantomJS executable differs from the default location, for example you have installed PhantomJS globally, you will need to define the path to your PhantomJS executable manually.</p>
 
   <p><code>$client-&gt;getEngine()-&gt;setPath('/path/to/phantomjs');</code></p>
@@ -275,12 +272,12 @@ code etc.</li>
     <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Request </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Request</span>
 <span class="sd">     **/</span>
     <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createRequest</span><span class="p">(</span><span class="s1">&#39;http://jonnyw.me&#39;</span><span class="p">,</span> <span class="s1">&#39;GET&#39;</span><span class="p">);</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Response </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Response </span>
 <span class="sd">     **/</span>
     <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createResponse</span><span class="p">();</span>
 
@@ -308,7 +305,7 @@ code etc.</li>
     <span class="nv">$left</span>   <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
     
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\CaptureRequest</span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\CaptureRequest</span>
 <span class="sd">     **/</span>
     <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createCaptureRequest</span><span class="p">(</span><span class="s1">&#39;http://jonnyw.me&#39;</span><span class="p">,</span> <span class="s1">&#39;GET&#39;</span><span class="p">);</span>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setOutputFile</span><span class="p">(</span><span class="s1">&#39;/path/to/save/capture/file.jpg&#39;</span><span class="p">);</span>
@@ -316,7 +313,7 @@ code etc.</li>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setCaptureDimensions</span><span class="p">(</span><span class="nv">$width</span><span class="p">,</span> <span class="nv">$height</span><span class="p">,</span> <span class="nv">$top</span><span class="p">,</span> <span class="nv">$left</span><span class="p">);</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Response </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Response </span>
 <span class="sd">     **/</span>
     <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createResponse</span><span class="p">();</span>
 
@@ -333,7 +330,7 @@ code etc.</li>
     <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\PdfRequest</span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\PdfRequest</span>
 <span class="sd">     **/</span>
     <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createPdfRequest</span><span class="p">(</span><span class="s1">&#39;http://jonnyw.me&#39;</span><span class="p">,</span> <span class="s1">&#39;GET&#39;</span><span class="p">);</span>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setOutputFile</span><span class="p">(</span><span class="s1">&#39;/path/to/save/pdf/document.pdf&#39;</span><span class="p">);</span>
@@ -342,7 +339,7 @@ code etc.</li>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setMargin</span><span class="p">(</span><span class="s1">&#39;1cm&#39;</span><span class="p">);</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Response </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Response </span>
 <span class="sd">     **/</span>
     <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createResponse</span><span class="p">();</span>
 
@@ -350,7 +347,7 @@ code etc.</li>
     <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">send</span><span class="p">(</span><span class="nv">$request</span><span class="p">,</span> <span class="nv">$response</span><span class="p">);</span>
     </code></pre></figure>
 
-<p>For more detailed examples see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/usage/">usage</a> section, or you can <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/custom-scripts/">create your own custom scripts</a>.</p>
+<p>For more detailed examples see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/3-usage/">usage</a> section, or you can <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/4-custom-scripts/">create your own custom scripts</a>.</p>
 
 
 	  </div>
@@ -377,7 +374,7 @@ code etc.</li>
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 1 - 1
_site/404/index.html

@@ -214,7 +214,7 @@
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 14 - 17
_site/index.html

@@ -195,18 +195,13 @@
 
   <div>
     
-    <blockquote>
-  <h4 id="important">Important</h4>
-  <p>Currently when installing PHP PhantomJS on <strong>Linux OS</strong> you will need to compile your own version of PhantomJS for your system. This is due to an <a href="https://github.com/ariya/phantomjs/issues/12948">unresolved issue</a> with the PhantomJS Linux packages. An Ubuntu compiled version will be installed by default but this may not be compatible with your system.</p>
-</blockquote>
-
-<p>PHP PhantomJS is a flexible PHP library to load pages through the PhantomJS headless browser and return the page response. It is handy for testing websites that demand javascript support and also supports screen captures and PDF output.</p>
+    <p>PHP PhantomJS is a flexible PHP library to load pages through the PhantomJS headless browser and return the page response. It is handy for testing websites that demand javascript support and also supports screen captures and PDF output.</p>
 
 <h2 id="feature-list">Feature List</h2>
 
 <ul>
   <li>Load webpages through the PhantomJS headless browser</li>
-  <li>View detailed response data including page content, headers, status<br />
+  <li>View detailed response data including page content, headers, status
 code etc.</li>
   <li>Handle redirects</li>
   <li>View javascript console errors</li>
@@ -214,8 +209,10 @@ code etc.</li>
   <li>Save screen captures to local disk</li>
   <li>Output web pages to PDF document</li>
   <li>Set viewport size</li>
+  <li>Set fixed header and footer for PDF output</li>
   <li>Define screen capture x, y, width and height parameters</li>
   <li>Delay page rendering for a specified time</li>
+  <li>Delay page rendering until page resources are fully loaded</li>
   <li>Execute PhantomJS with command line options</li>
   <li>Easily build and run custom PhantomJS scripts</li>
 </ul>
@@ -257,10 +254,10 @@ code etc.</li>
     
     <span class="nv">$ </span>composer require <span class="s2">&quot;jonnyw/php-phantomjs:4.*&quot;</span></code></pre></figure>
 
-<p>If you would like to use another installation method or would like to see more detailed installation instructions, see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/installation/">installation</a> documentation.</p>
+<p>If you would like to use another installation method or would like to see more detailed installation instructions, see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/2-installation/">installation</a> documentation.</p>
 
 <blockquote>
-  <h4 id="important-1">Important</h4>
+  <h4 id="important">Important</h4>
   <p>By default the PhantomJS library will look for the PhantomJS executable in the bin folder relative to where your script is running <code>~/bin/phantomjs</code>. If the executable cannot be found or if the path to your PhantomJS executable differs from the default location, for example you have installed PhantomJS globally, you will need to define the path to your PhantomJS executable manually.</p>
 
   <p><code>$client-&gt;getEngine()-&gt;setPath('/path/to/phantomjs');</code></p>
@@ -277,12 +274,12 @@ code etc.</li>
     <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Request </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Request</span>
 <span class="sd">     **/</span>
     <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createRequest</span><span class="p">(</span><span class="s1">&#39;http://jonnyw.me&#39;</span><span class="p">,</span> <span class="s1">&#39;GET&#39;</span><span class="p">);</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Response </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Response </span>
 <span class="sd">     **/</span>
     <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createResponse</span><span class="p">();</span>
 
@@ -310,7 +307,7 @@ code etc.</li>
     <span class="nv">$left</span>   <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
     
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\CaptureRequest</span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\CaptureRequest</span>
 <span class="sd">     **/</span>
     <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createCaptureRequest</span><span class="p">(</span><span class="s1">&#39;http://jonnyw.me&#39;</span><span class="p">,</span> <span class="s1">&#39;GET&#39;</span><span class="p">);</span>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setOutputFile</span><span class="p">(</span><span class="s1">&#39;/path/to/save/capture/file.jpg&#39;</span><span class="p">);</span>
@@ -318,7 +315,7 @@ code etc.</li>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setCaptureDimensions</span><span class="p">(</span><span class="nv">$width</span><span class="p">,</span> <span class="nv">$height</span><span class="p">,</span> <span class="nv">$top</span><span class="p">,</span> <span class="nv">$left</span><span class="p">);</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Response </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Response </span>
 <span class="sd">     **/</span>
     <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createResponse</span><span class="p">();</span>
 
@@ -335,7 +332,7 @@ code etc.</li>
     <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\PdfRequest</span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\PdfRequest</span>
 <span class="sd">     **/</span>
     <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createPdfRequest</span><span class="p">(</span><span class="s1">&#39;http://jonnyw.me&#39;</span><span class="p">,</span> <span class="s1">&#39;GET&#39;</span><span class="p">);</span>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setOutputFile</span><span class="p">(</span><span class="s1">&#39;/path/to/save/pdf/document.pdf&#39;</span><span class="p">);</span>
@@ -344,7 +341,7 @@ code etc.</li>
     <span class="nv">$request</span><span class="o">-&gt;</span><span class="na">setMargin</span><span class="p">(</span><span class="s1">&#39;1cm&#39;</span><span class="p">);</span>
 
     <span class="sd">/** </span>
-<span class="sd">     * @see JonnyW\PhantomJs\Message\Response </span>
+<span class="sd">     * @see JonnyW\PhantomJs\Http\Response </span>
 <span class="sd">     **/</span>
     <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">getMessageFactory</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">createResponse</span><span class="p">();</span>
 
@@ -352,7 +349,7 @@ code etc.</li>
     <span class="nv">$client</span><span class="o">-&gt;</span><span class="na">send</span><span class="p">(</span><span class="nv">$request</span><span class="p">,</span> <span class="nv">$response</span><span class="p">);</span>
     </code></pre></figure>
 
-<p>For more detailed examples see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/usage/">usage</a> section, or you can <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/custom-scripts/">create your own custom scripts</a>.</p>
+<p>For more detailed examples see the <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/3-usage/">usage</a> section, or you can <a href="http://jonnnnyw.github.io/php-phantomjs/4.0/4-custom-scripts/">create your own custom scripts</a>.</p>
 
 
     
@@ -379,7 +376,7 @@ code etc.</li>
 		<footer>
 			<hr/>
 			<p>
-				&copy; 2015 PHP PhantomJs
+				&copy; 2016 PHP PhantomJs
 			</p>
 		</footer>
 	</div>

+ 2 - 0
_version_4/1-introduction.md

@@ -22,8 +22,10 @@ Feature List
 *  Save screen captures to local disk
 *  Output web pages to PDF document
 *  Set viewport size
+*  Set fixed header and footer for PDF output
 *  Define screen capture x, y, width and height parameters
 *  Delay page rendering for a specified time
+*  Delay page rendering until page resources are fully loaded
 *  Execute PhantomJS with command line options
 *  Easily build and run custom PhantomJS scripts
 

+ 49 - 0
_version_4/3-usage.md

@@ -20,6 +20,7 @@ This page contains some common examples of how to use the PHP PhantomJS library.
 * [Set Background Color](#set-background-color)
 * [Custom Timeout](#custom-timeout)
 * [Delay Page Render](#delay-page-render)
+* [On Load Finished](#on-load-finished)
 * [PhantomJS Options](#phantomjs-options)
 * [Exceptions](#exceptions)
 
@@ -219,6 +220,9 @@ You can also set the width, height, x and y axis for your screen capture:
     
 {% endhighlight %}
 
+> #### Note
+> Sometimes you may want to wait for all the resources on the page to load before saving a capture to disk. This can be achieved by either [delaying the page render](#delay-page-render) or [waiting for all resources to load](#on-load-finished).
+
 Output To PDF
 -------------
 
@@ -242,6 +246,23 @@ You can output a page to PDF by creating a PDF request and setting the path you
     $client->send($request, $response);
 {% endhighlight %}
 
+You can set an optional repeating header and/or footer to the PDF output.
+
+{% highlight php %}
+
+    <?php
+
+    ...
+    
+    $request->setRepeatingHeader('<h1>Header <span style="float:right">%pageNum% / %pageTotal%</span></h1>'[, height]);
+    $request->setRepeatingFooter('<footer>Footer <span style="float:right">%pageNum% / %pageTotal%</span></footer>'[, height]);
+    
+    ...
+
+{% endhighlight %}
+
+The `setRepeatingHeader` and `setRepeatingFooter` methods take an optional second parameter that allows you to set the height of the header and/or footer. This defaults to `1cm`. You may also use the `%pageNum%` and `%pageTotal%` placeholders to output the current page and total page count for each. Inline styles can be applied to the injected header and footer tags allowing you to define the look and feel.
+
 You can set the paper size and margin of the PDF.
 
 {% highlight php %}
@@ -293,6 +314,9 @@ Along with the paper orientation.
     
 {% endhighlight %}
 
+> #### Note
+> Sometimes you may want to wait for all the resources on the page to load before outputting to PDF. This can be achieved by either [delaying the page render](#delay-page-render) or [waiting for all resources to load](#on-load-finished).
+
 Set Viewport Size
 -----------------
 
@@ -376,6 +400,31 @@ Sometimes when saving a page to local disk you may want to wait until the page i
     
 {% endhighlight %}
 
+On Load Finished
+------------
+
+Another way of delaying the page render is to wait until all the resources on the page have finished loading. This includes things like images, AJAX requests etc. This can be achieved by telling the client to lazy load the request.
+
+{% highlight php %}
+
+    <?php
+
+    ...
+    
+    use JonnyW\PhantomJs\Client;
+    
+    $client = Client::getInstance();
+    $client->isLazy(); // Tells the client to wait for all resources before rendering
+
+    $request  = $client->getMessageFactory()->createRequest();
+    $request->setTimeout(5000); // Will render page if this timeout is reached and resources haven't finished loading
+
+    ...
+    
+{% endhighlight %}
+
+> #### Note
+> It is recommended that you set a timeout on the request when lazy loading. This guarantees that the request will return content after a period of time even if page resources are still loading. Without this you may run into issues on pages that poll resources at short intervals.
 
 PhantomJS Options
 -----------------