examples/api-samples/public/docs/sample35.html in groupdocs-1.6.0 vs examples/api-samples/public/docs/sample35.html in groupdocs-1.7.0

- old
+ new

@@ -29,13 +29,13 @@ </div> <p>GET request</p> </div> - <div class="content"><div class='highlight'><pre>get <span class="string">'/sample35'</span> <span class="keyword">do</span> - haml <span class="symbol">:sample35</span> -<span class="keyword">end</span></pre></div></div> + <div class="content"><div class='highlight'><pre>get <span class="hljs-string">'/sample-35-how-to-get-fields-and-their-data-from-pdf-file'</span> <span class="hljs-keyword">do</span> + haml <span class="hljs-symbol">:sample35</span> +<span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-2"> @@ -46,11 +46,11 @@ </div> <p>POST request</p> </div> - <div class="content"><div class='highlight'><pre>post <span class="string">'/sample35'</span> <span class="keyword">do</span></pre></div></div> + <div class="content"><div class='highlight'><pre>post <span class="hljs-string">'/sample-35-how-to-get-fields-and-their-data-from-pdf-file'</span> <span class="hljs-keyword">do</span></pre></div></div> </li> <li id="section-3"> @@ -61,18 +61,18 @@ </div> <p>Set variables</p> </div> - <div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:clientId</span>] - set <span class="symbol">:private_key</span>, params[<span class="symbol">:privateKey</span>] - set <span class="symbol">:source</span>, params[<span class="symbol">:source</span>] - set <span class="symbol">:file_id</span>, params[<span class="symbol">:fileId</span>] - set <span class="symbol">:url</span>, params[<span class="symbol">:url</span>] - set <span class="symbol">:path</span>, params[<span class="symbol">:basePath</span>] + <div class="content"><div class='highlight'><pre> set <span class="hljs-symbol">:client_id</span>, params[<span class="hljs-symbol">:clientId</span>] + set <span class="hljs-symbol">:private_key</span>, params[<span class="hljs-symbol">:privateKey</span>] + set <span class="hljs-symbol">:source</span>, params[<span class="hljs-symbol">:source</span>] + set <span class="hljs-symbol">:file_id</span>, params[<span class="hljs-symbol">:fileId</span>] + set <span class="hljs-symbol">:url</span>, params[<span class="hljs-symbol">:url</span>] + set <span class="hljs-symbol">:base_path</span>, params[<span class="hljs-symbol">:basePath</span>] - <span class="keyword">begin</span></pre></div></div> + <span class="hljs-keyword">begin</span></pre></div></div> </li> <li id="section-4"> @@ -83,11 +83,11 @@ </div> <p>Check required variables</p> </div> - <div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.client_id.empty? <span class="keyword">or</span> settings.private_key.empty?</pre></div></div> + <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'Please enter all required parameters'</span> <span class="hljs-keyword">if</span> settings.client_id.empty? <span class="hljs-keyword">or</span> settings.private_key.empty?</pre></div></div> </li> <li id="section-5"> @@ -98,17 +98,17 @@ </div> <p>Prepare base path</p> </div> - <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.base_path.empty? - base_path = <span class="string">'https://api.groupdocs.com'</span> - <span class="keyword">elsif</span> settings.base_path.match(<span class="string">'/v2.0'</span>) - base_path = settings.base_path.split(<span class="string">'/v2.0'</span>)[<span class="number">0</span>] - <span class="keyword">else</span> + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> settings.base_path.empty? + base_path = <span class="hljs-string">'https://api.groupdocs.com'</span> + <span class="hljs-keyword">elsif</span> settings.base_path.match(<span class="hljs-string">'/v2.0'</span>) + base_path = settings.base_path.split(<span class="hljs-string">'/v2.0'</span>)[<span class="hljs-number">0</span>] + <span class="hljs-keyword">else</span> base_path = settings.base_path - <span class="keyword">end</span></pre></div></div> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-6"> @@ -119,11 +119,11 @@ </div> <p>Configure your access to API server.</p> </div> - <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs| + <div class="content"><div class='highlight'><pre> <span class="hljs-constant">GroupDocs</span>.configure <span class="hljs-keyword">do</span> |groupdocs| groupdocs.client_id = settings.client_id groupdocs.private_key = settings.private_key</pre></div></div> </li> @@ -136,13 +136,13 @@ </div> <p>Optionally specify API server and version</p> </div> - <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="comment"># default is 'https://api.groupdocs.com'</span> + <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="hljs-comment"># default is 'https://api.groupdocs.com'</span> - <span class="keyword">end</span></pre></div></div> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-8"> @@ -153,12 +153,12 @@ </div> <p>Get document by file GUID</p> </div> - <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.source - <span class="keyword">when</span> <span class="string">'guid'</span></pre></div></div> + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">case</span> settings.source + <span class="hljs-keyword">when</span> <span class="hljs-string">'guid'</span></pre></div></div> </li> <li id="section-9"> @@ -169,12 +169,12 @@ </div> <p>Create instance of File</p> </div> - <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> =&gt; settings.file_id}) - <span class="keyword">when</span> <span class="string">'local'</span></pre></div></div> + <div class="content"><div class='highlight'><pre> file = <span class="hljs-constant">GroupDocs::Storage::File</span>.new({<span class="hljs-symbol">:guid</span> =&gt; settings.file_id}) + <span class="hljs-keyword">when</span> <span class="hljs-string">'local'</span></pre></div></div> </li> <li id="section-10"> @@ -185,11 +185,11 @@ </div> <p>Construct path</p> </div> - <div class="content"><div class='highlight'><pre> file_path = <span class="string">"<span class="subst">#{<span class="constant">Dir</span>.tmpdir}</span>/<span class="subst">#{params[<span class="symbol">:file</span>][<span class="symbol">:filename</span>]}</span>"</span></pre></div></div> + <div class="content"><div class='highlight'><pre> file_path = <span class="hljs-string">"<span class="hljs-subst">#{<span class="hljs-constant">Dir</span>.tmpdir}</span>/<span class="hljs-subst">#{params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:filename</span>]}</span>"</span></pre></div></div> </li> <li id="section-11"> @@ -200,11 +200,11 @@ </div> <p>Open file</p> </div> - <div class="content"><div class='highlight'><pre> <span class="constant">File</span>.open(file_path, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:file</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div> + <div class="content"><div class='highlight'><pre> <span class="hljs-constant">File</span>.open(file_path, <span class="hljs-string">'wb'</span>) { |f| f.write(params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:tempfile</span>].read) }</pre></div></div> </li> <li id="section-12"> @@ -215,12 +215,12 @@ </div> <p>Make a request to API using client_id and private_key</p> </div> - <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(file_path, {}) - <span class="keyword">when</span> <span class="string">'url'</span></pre></div></div> + <div class="content"><div class='highlight'><pre> file = <span class="hljs-constant">GroupDocs::Storage::File</span>.upload!(file_path, {}) + <span class="hljs-keyword">when</span> <span class="hljs-string">'url'</span></pre></div></div> </li> <li id="section-13"> @@ -231,14 +231,14 @@ </div> <p>Upload file from defined url</p> </div> - <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url) - <span class="keyword">else</span> - raise <span class="string">'Wrong GUID source.'</span> - <span class="keyword">end</span></pre></div></div> + <div class="content"><div class='highlight'><pre> file = <span class="hljs-constant">GroupDocs::Storage::File</span>.upload_web!(settings.url) + <span class="hljs-keyword">else</span> + raise <span class="hljs-string">'Wrong GUID source.'</span> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-14"> @@ -249,11 +249,11 @@ </div> <p>Raise exception if something went wrong</p> </div> - <div class="content"><div class='highlight'><pre> raise <span class="string">'No such file'</span> <span class="keyword">unless</span> file.is_a?(<span class="constant">GroupDocs::Storage::File</span>)</pre></div></div> + <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'No such file'</span> <span class="hljs-keyword">unless</span> file.is_a?(<span class="hljs-constant">GroupDocs::Storage::File</span>)</pre></div></div> </li> <li id="section-15"> @@ -275,11 +275,11 @@ <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-16">&#182;</a> </div> - <p>Get array of document&#39;s fields</p> + <p>Get array of document’s fields</p> </div> <div class="content"><div class='highlight'><pre> fields = document.fields!</pre></div></div> @@ -294,43 +294,42 @@ </div> <p>Create the fields for form</p> </div> - <div class="content"><div class='highlight'><pre> html = <span class="string">''</span> - fields.map <span class="keyword">do</span> |e| + <div class="content"><div class='highlight'><pre> html = <span class="hljs-string">''</span> + fields.map <span class="hljs-keyword">do</span> |e| - <span class="keyword">case</span> e.type - <span class="keyword">when</span> <span class="string">'Text'</span> - signature = <span class="string">"&lt;br/&gt;&lt;label for='<span class="subst">#{e.name}</span>'&gt;<span class="subst">#{e.name}</span> <span class="subst">#{e.mandatory == <span class="keyword">false</span> ? <span class="string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="symbol">:</span> <span class="string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;input type='text' name='<span class="subst">#{e.name}</span>'&gt;&lt;/input&gt;&lt;br/&gt;&lt;br/&gt;"</span> + <span class="hljs-keyword">case</span> e.type + <span class="hljs-keyword">when</span> <span class="hljs-string">'Text'</span> + signature = <span class="hljs-string">"&lt;br/&gt;&lt;label for='<span class="hljs-subst">#{e.name}</span>'&gt;<span class="hljs-subst">#{e.name}</span> <span class="hljs-subst">#{e.mandatory == <span class="hljs-keyword">false</span> ? <span class="hljs-string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="hljs-symbol">:</span> <span class="hljs-string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;input type='text' name='<span class="hljs-subst">#{e.name}</span>'&gt;&lt;/input&gt;&lt;br/&gt;&lt;br/&gt;"</span> html &lt;&lt; signature - <span class="keyword">when</span> <span class="string">'RadioButton'</span> - i = <span class="number">0</span> - html.scan(e.name).empty? ? <span class="string">''</span> <span class="symbol">:</span> i += <span class="number">1</span> - radio = <span class="string">"&lt;br/&gt;&lt;label for='<span class="subst">#{e.name}</span>'&gt;<span class="subst">#{e.name}</span> <span class="subst">#{e.mandatory == <span class="keyword">false</span> ? <span class="string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="symbol">:</span> <span class="string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;input type='radio' name='<span class="subst">#{e.name}</span>' value='<span class="subst">#{i}</span>' &gt;&lt;/input&gt;&lt;br/&gt;&lt;br/&gt;"</span> + <span class="hljs-keyword">when</span> <span class="hljs-string">'RadioButton'</span> + i = <span class="hljs-number">0</span> + html.scan(e.name).empty? ? <span class="hljs-string">''</span> <span class="hljs-symbol">:</span> i += <span class="hljs-number">1</span> + radio = <span class="hljs-string">"&lt;br/&gt;&lt;label for='<span class="hljs-subst">#{e.name}</span>'&gt;<span class="hljs-subst">#{e.name}</span> <span class="hljs-subst">#{e.mandatory == <span class="hljs-keyword">false</span> ? <span class="hljs-string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="hljs-symbol">:</span> <span class="hljs-string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;input type='radio' name='<span class="hljs-subst">#{e.name}</span>' value='<span class="hljs-subst">#{i}</span>' &gt;&lt;/input&gt;&lt;br/&gt;&lt;br/&gt;"</span> html &lt;&lt; radio - <span class="keyword">when</span> <span class="string">'Checkbox'</span> - checkbox = <span class="string">"&lt;br/&gt;&lt;label for='<span class="subst">#{e.name}</span>'&gt;<span class="subst">#{e.name}</span> <span class="subst">#{e.mandatory == <span class="keyword">false</span> ? <span class="string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="symbol">:</span> <span class="string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;input type='checkbox' name='<span class="subst">#{e.name}</span>' &gt;&lt;/input&gt;&lt;br/&gt;&lt;br/&gt;"</span> + <span class="hljs-keyword">when</span> <span class="hljs-string">'Checkbox'</span> + checkbox = <span class="hljs-string">"&lt;br/&gt;&lt;label for='<span class="hljs-subst">#{e.name}</span>'&gt;<span class="hljs-subst">#{e.name}</span> <span class="hljs-subst">#{e.mandatory == <span class="hljs-keyword">false</span> ? <span class="hljs-string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="hljs-symbol">:</span> <span class="hljs-string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;input type='checkbox' name='<span class="hljs-subst">#{e.name}</span>' &gt;&lt;/input&gt;&lt;br/&gt;&lt;br/&gt;"</span> html &lt;&lt; checkbox - <span class="keyword">when</span> <span class="string">'Combobox'</span> - combobox = <span class="string">"&lt;br/&gt;&lt;label for='<span class="subst">#{e.name}</span>'&gt;<span class="subst">#{e.name}</span> <span class="subst">#{e.mandatory == <span class="keyword">false</span> ? <span class="string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="symbol">:</span> <span class="string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;select name='<span class="subst">#{e.name}</span>'&gt;"</span> - e.acceptableValues.each { |e| combobox &lt;&lt; <span class="string">"&lt;option name='<span class="subst">#{e}</span>'&gt;<span class="subst">#{e}</span>&lt;/option&gt;"</span>} - combobox &lt;&lt; <span class="string">"&lt;/select&gt;&lt;br/&gt;&lt;br/&gt;"</span> + <span class="hljs-keyword">when</span> <span class="hljs-string">'Combobox'</span> + combobox = <span class="hljs-string">"&lt;br/&gt;&lt;label for='<span class="hljs-subst">#{e.name}</span>'&gt;<span class="hljs-subst">#{e.name}</span> <span class="hljs-subst">#{e.mandatory == <span class="hljs-keyword">false</span> ? <span class="hljs-string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="hljs-symbol">:</span> <span class="hljs-string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;select name='<span class="hljs-subst">#{e.name}</span>'&gt;"</span> + e.acceptableValues.each { |e| combobox &lt;&lt; <span class="hljs-string">"&lt;option name='<span class="hljs-subst">#{e}</span>'&gt;<span class="hljs-subst">#{e}</span>&lt;/option&gt;"</span>} + combobox &lt;&lt; <span class="hljs-string">"&lt;/select&gt;&lt;br/&gt;&lt;br/&gt;"</span> html &lt;&lt; combobox - <span class="keyword">when</span> <span class="string">'Listbox'</span> - listbox = <span class="string">"&lt;br/&gt;&lt;label for='<span class="subst">#{e.name}</span>'&gt;<span class="subst">#{e.name}</span> <span class="subst">#{e.mandatory == <span class="keyword">false</span> ? <span class="string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="symbol">:</span> <span class="string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;select multiple name='<span class="subst">#{e.name}</span>[]'&gt;"</span> - e.acceptableValues.each { |e| listbox &lt;&lt; <span class="string">"&lt;option name='<span class="subst">#{e}</span>'&gt;<span class="subst">#{e}</span>&lt;/option&gt;"</span>} - listbox &lt;&lt; <span class="string">"&lt;/select&gt;&lt;br/&gt;&lt;br/&gt;"</span> + <span class="hljs-keyword">when</span> <span class="hljs-string">'Listbox'</span> + listbox = <span class="hljs-string">"&lt;br/&gt;&lt;label for='<span class="hljs-subst">#{e.name}</span>'&gt;<span class="hljs-subst">#{e.name}</span> <span class="hljs-subst">#{e.mandatory == <span class="hljs-keyword">false</span> ? <span class="hljs-string">'&lt;span class="optional"&gt;(Optional)&lt;/span&gt;'</span> <span class="hljs-symbol">:</span> <span class="hljs-string">'&lt;span class="optional"&gt;(Required)&lt;/span&gt;'</span>}</span>&lt;/label&gt;&lt;br/&gt;&lt;select multiple name='<span class="hljs-subst">#{e.name}</span>[]'&gt;"</span> + e.acceptableValues.each { |e| listbox &lt;&lt; <span class="hljs-string">"&lt;option name='<span class="hljs-subst">#{e}</span>'&gt;<span class="hljs-subst">#{e}</span>&lt;/option&gt;"</span>} + listbox &lt;&lt; <span class="hljs-string">"&lt;/select&gt;&lt;br/&gt;&lt;br/&gt;"</span> html &lt;&lt; listbox - <span class="keyword">end</span> + <span class="hljs-keyword">end</span> - <span class="keyword">end</span> + <span class="hljs-keyword">end</span> - - <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e + <span class="hljs-keyword">rescue</span> <span class="hljs-constant">Exception</span> =&gt; e err = e.message - <span class="keyword">end</span></pre></div></div> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-18"> @@ -341,12 +340,12 @@ </div> <p>Set variables for template</p> </div> - <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample35</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:userId</span> =&gt; settings.client_id, <span class="symbol">:privateKey</span> =&gt; settings.private_key, <span class="symbol">:base_path</span> =&gt; settings.path, <span class="symbol">:fileId</span> =&gt; document.file.guid, <span class="symbol">:html</span> =&gt; html, <span class="symbol">:err</span> =&gt; err} -<span class="keyword">end</span></pre></div></div> + <div class="content"><div class='highlight'><pre> haml <span class="hljs-symbol">:sample35</span>, <span class="hljs-symbol">:locals</span> =&gt; {<span class="hljs-symbol">:userId</span> =&gt; settings.client_id, <span class="hljs-symbol">:privateKey</span> =&gt; settings.private_key, <span class="hljs-symbol">:fileId</span> =&gt; document.file.guid, <span class="hljs-symbol">:base_path</span> =&gt; settings.base_path, <span class="hljs-symbol">:html</span> =&gt; html, <span class="hljs-symbol">:err</span> =&gt; err} +<span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-19"> @@ -357,13 +356,13 @@ </div> <p>GET request</p> </div> - <div class="content"><div class='highlight'><pre>get <span class="string">'/sample35/check'</span> <span class="keyword">do</span> - haml <span class="symbol">:sample35</span> -<span class="keyword">end</span></pre></div></div> + <div class="content"><div class='highlight'><pre>get <span class="hljs-string">'//sample-35-how-to-get-fields-and-their-data-from-pdf-file/check'</span> <span class="hljs-keyword">do</span> + haml <span class="hljs-symbol">:sample35</span> +<span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-20"> @@ -374,17 +373,17 @@ </div> <p>POST request</p> </div> - <div class="content"><div class='highlight'><pre>post <span class="string">'/sample35/check'</span> <span class="keyword">do</span> - set <span class="symbol">:client_id</span>, params[<span class="symbol">:clientId</span>] - set <span class="symbol">:private_key</span>, params[<span class="symbol">:privateKey</span>] - set <span class="symbol">:path</span>, params[<span class="symbol">:basePath</span>] - set <span class="symbol">:file_id</span>, params[<span class="symbol">:fileId</span>] + <div class="content"><div class='highlight'><pre>post <span class="hljs-string">'//sample-35-how-to-get-fields-and-their-data-from-pdf-file/check'</span> <span class="hljs-keyword">do</span> + set <span class="hljs-symbol">:client_id</span>, params[<span class="hljs-symbol">:clientId</span>] + set <span class="hljs-symbol">:private_key</span>, params[<span class="hljs-symbol">:privateKey</span>] + set <span class="hljs-symbol">:base_path</span>, params[<span class="hljs-symbol">:basePath</span>] + set <span class="hljs-symbol">:file_id</span>, params[<span class="hljs-symbol">:fileId</span>] - <span class="keyword">begin</span></pre></div></div> + <span class="hljs-keyword">begin</span></pre></div></div> </li> <li id="section-21"> @@ -395,17 +394,17 @@ </div> <p>Prepare base path</p> </div> - <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.base_path.empty? - base_path = <span class="string">'https://api.groupdocs.com'</span> - <span class="keyword">elsif</span> settings.base_path.match(<span class="string">'/v2.0'</span>) - base_path = settings.base_path.split(<span class="string">'/v2.0'</span>)[<span class="number">0</span>] - <span class="keyword">else</span> + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> settings.base_path.empty? + base_path = <span class="hljs-string">'https://api.groupdocs.com'</span> + <span class="hljs-keyword">elsif</span> settings.base_path.match(<span class="hljs-string">'/v2.0'</span>) + base_path = settings.base_path.split(<span class="hljs-string">'/v2.0'</span>)[<span class="hljs-number">0</span>] + <span class="hljs-keyword">else</span> base_path = settings.base_path - <span class="keyword">end</span></pre></div></div> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-22"> @@ -416,11 +415,11 @@ </div> <p>Get document by file GUID</p> </div> - <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs| + <div class="content"><div class='highlight'><pre> <span class="hljs-constant">GroupDocs</span>.configure <span class="hljs-keyword">do</span> |groupdocs| groupdocs.client_id = settings.client_id groupdocs.private_key = settings.private_key</pre></div></div> </li> @@ -433,12 +432,12 @@ </div> <p>Optionally specify API server and version</p> </div> - <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="comment"># default is 'https://api.groupdocs.com'</span> - <span class="keyword">end</span></pre></div></div> + <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="hljs-comment"># default is 'https://api.groupdocs.com'</span> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-24"> @@ -463,11 +462,11 @@ </div> <p>Create instance of File</p> </div> - <div class="content"><div class='highlight'><pre> document = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> =&gt; settings.file_id}).to_document</pre></div></div> + <div class="content"><div class='highlight'><pre> document = <span class="hljs-constant">GroupDocs::Storage::File</span>.new({<span class="hljs-symbol">:guid</span> =&gt; settings.file_id}).to_document</pre></div></div> </li> <li id="section-26"> @@ -478,22 +477,22 @@ </div> <p>Create datasource with fields</p> </div> - <div class="content"><div class='highlight'><pre> datasource = <span class="constant">GroupDocs::DataSource</span>.new</pre></div></div> + <div class="content"><div class='highlight'><pre> datasource = <span class="hljs-constant">GroupDocs::DataSource</span>.new</pre></div></div> </li> <li id="section-27"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-27">&#182;</a> </div> - <p>Get array of document&#39;s fields</p> + <p>Get array of document’s fields</p> </div> <div class="content"><div class='highlight'><pre> fields = document.fields!()</pre></div></div> @@ -525,47 +524,47 @@ </div> <p>Create Field instance and fill the fields</p> </div> - <div class="content"><div class='highlight'><pre> fields.each <span class="keyword">do</span> |field| - <span class="keyword">if</span> field.type == <span class="string">'Text'</span> - datasource.fields &lt;&lt; <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> field.name, <span class="symbol">type:</span> <span class="symbol">:text</span>, <span class="symbol">values:</span> [params[field.name.to_sym]]) - <span class="keyword">end</span> + <div class="content"><div class='highlight'><pre> fields.each <span class="hljs-keyword">do</span> |field| + <span class="hljs-keyword">if</span> field.type == <span class="hljs-string">'Text'</span> + datasource.fields &lt;&lt; <span class="hljs-constant">GroupDocs::DataSource::Field</span>.new(<span class="hljs-symbol">name:</span> field.name, <span class="hljs-symbol">type:</span> <span class="hljs-symbol">:text</span>, <span class="hljs-symbol">values:</span> [params[field.name.to_sym]]) + <span class="hljs-keyword">end</span> - <span class="keyword">if</span> field.type == <span class="string">"RadioButton"</span> &amp;&amp; params[field.name.to_sym] - datasource.fields &lt;&lt; <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> field.name, <span class="symbol">type:</span> <span class="string">'integer'</span>, <span class="symbol">values:</span> [params[field.name.to_sym]]) + <span class="hljs-keyword">if</span> field.type == <span class="hljs-string">"RadioButton"</span> &amp;&amp; params[field.name.to_sym] + datasource.fields &lt;&lt; <span class="hljs-constant">GroupDocs::DataSource::Field</span>.new(<span class="hljs-symbol">name:</span> field.name, <span class="hljs-symbol">type:</span> <span class="hljs-string">'integer'</span>, <span class="hljs-symbol">values:</span> [params[field.name.to_sym]]) - <span class="keyword">end</span> + <span class="hljs-keyword">end</span> - <span class="keyword">if</span> field.type == <span class="string">"Checkbox"</span> &amp;&amp; params[field.name.to_sym] == <span class="string">'on'</span> - datasource.fields &lt;&lt; <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> field.name, <span class="symbol">type:</span> <span class="string">'boolean'</span>, <span class="symbol">values:</span> [<span class="keyword">true</span>]) - <span class="keyword">end</span> + <span class="hljs-keyword">if</span> field.type == <span class="hljs-string">"Checkbox"</span> &amp;&amp; params[field.name.to_sym] == <span class="hljs-string">'on'</span> + datasource.fields &lt;&lt; <span class="hljs-constant">GroupDocs::DataSource::Field</span>.new(<span class="hljs-symbol">name:</span> field.name, <span class="hljs-symbol">type:</span> <span class="hljs-string">'boolean'</span>, <span class="hljs-symbol">values:</span> [<span class="hljs-keyword">true</span>]) + <span class="hljs-keyword">end</span> - <span class="keyword">if</span> field.type == <span class="string">"Combobox"</span> &amp;&amp; params[field.name.to_sym] - i = <span class="number">0</span> - value = <span class="keyword">nil</span> - field.acceptableValues.each <span class="keyword">do</span> |e| - e == params[field.name] ? value = i <span class="symbol">:</span> <span class="string">''</span> - i += <span class="number">1</span> - <span class="keyword">end</span> + <span class="hljs-keyword">if</span> field.type == <span class="hljs-string">"Combobox"</span> &amp;&amp; params[field.name.to_sym] + i = <span class="hljs-number">0</span> + value = <span class="hljs-keyword">nil</span> + field.acceptableValues.each <span class="hljs-keyword">do</span> |e| + e == params[field.name] ? value = i <span class="hljs-symbol">:</span> <span class="hljs-string">''</span> + i += <span class="hljs-number">1</span> + <span class="hljs-keyword">end</span> - datasource.fields &lt;&lt; <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> field.name, <span class="symbol">type:</span> <span class="string">'integer'</span>, <span class="symbol">values:</span> [value]) - <span class="keyword">end</span> + datasource.fields &lt;&lt; <span class="hljs-constant">GroupDocs::DataSource::Field</span>.new(<span class="hljs-symbol">name:</span> field.name, <span class="hljs-symbol">type:</span> <span class="hljs-string">'integer'</span>, <span class="hljs-symbol">values:</span> [value]) + <span class="hljs-keyword">end</span> - <span class="keyword">if</span> field.type == <span class="string">"Listbox"</span> &amp;&amp; params[field.name.to_sym] - i = <span class="number">0</span> - value = <span class="keyword">nil</span> - field.acceptableValues.each <span class="keyword">do</span> |e| - e == params[field.name] ? value = i <span class="symbol">:</span> <span class="string">''</span> - i += <span class="number">1</span> - <span class="keyword">end</span> - datasource.fields &lt;&lt; <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> field.name, <span class="symbol">type:</span> <span class="string">'integer'</span>, <span class="symbol">values:</span> [value]) + <span class="hljs-keyword">if</span> field.type == <span class="hljs-string">"Listbox"</span> &amp;&amp; params[field.name.to_sym] + i = <span class="hljs-number">0</span> + value = <span class="hljs-keyword">nil</span> + field.acceptableValues.each <span class="hljs-keyword">do</span> |e| + e == params[field.name] ? value = i <span class="hljs-symbol">:</span> <span class="hljs-string">''</span> + i += <span class="hljs-number">1</span> + <span class="hljs-keyword">end</span> + datasource.fields &lt;&lt; <span class="hljs-constant">GroupDocs::DataSource::Field</span>.new(<span class="hljs-symbol">name:</span> field.name, <span class="hljs-symbol">type:</span> <span class="hljs-string">'integer'</span>, <span class="hljs-symbol">values:</span> [value]) - <span class="keyword">end</span> + <span class="hljs-keyword">end</span> - <span class="keyword">end</span></pre></div></div> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-30"> @@ -591,13 +590,13 @@ </div> <p>Creates new job to merge datasource into document.</p> </div> - <div class="content"><div class='highlight'><pre> job = document.datasource!(datasource, {<span class="symbol">:new_type</span> =&gt; <span class="string">'pdf'</span>}) + <div class="content"><div class='highlight'><pre> job = document.datasource!(datasource, {<span class="hljs-symbol">:new_type</span> =&gt; <span class="hljs-string">'pdf'</span>}) - i = <span class="number">0</span></pre></div></div> + i = <span class="hljs-number">0</span></pre></div></div> </li> <li id="section-32"> @@ -608,16 +607,16 @@ </div> <p>Checks status of Job.</p> </div> - <div class="content"><div class='highlight'><pre> <span class="keyword">while</span> i&lt;<span class="number">5</span> <span class="keyword">do</span> - sleep(<span class="number">5</span>) - job_status = <span class="constant">GroupDocs::Job</span>.get!(job.id) - <span class="keyword">break</span> <span class="keyword">if</span> job_status.status == <span class="symbol">:archived</span> - i += <span class="number">1</span> - <span class="keyword">end</span></pre></div></div> + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">while</span> i&lt;<span class="hljs-number">5</span> <span class="hljs-keyword">do</span> + sleep(<span class="hljs-number">5</span>) + job_status = <span class="hljs-constant">GroupDocs::Job</span>.get!(job.id) + <span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> job_status.status == <span class="hljs-symbol">:archived</span> + i += <span class="hljs-number">1</span> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-33"> @@ -643,11 +642,11 @@ </div> <p>Set converted document GUID</p> </div> - <div class="content"><div class='highlight'><pre> guid = document[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].guid</pre></div></div> + <div class="content"><div class='highlight'><pre> guid = document[<span class="hljs-symbol">:inputs</span>][<span class="hljs-number">0</span>].outputs[<span class="hljs-number">0</span>].guid</pre></div></div> </li> <li id="section-35"> @@ -658,11 +657,11 @@ </div> <p>Prepare to sign url</p> </div> - <div class="content"><div class='highlight'><pre> iframe = <span class="string">"/document-viewer/embed/<span class="subst">#{guid}</span>"</span></pre></div></div> + <div class="content"><div class='highlight'><pre> iframe = <span class="hljs-string">"/document-viewer/embed/<span class="hljs-subst">#{guid}</span>"</span></pre></div></div> </li> <li id="section-36"> @@ -673,11 +672,11 @@ </div> <p>Construct result string</p> </div> - <div class="content"><div class='highlight'><pre> url = <span class="constant">GroupDocs::Api::Request</span>.new(<span class="symbol">:path</span> =&gt; iframe).prepare_and_sign_url</pre></div></div> + <div class="content"><div class='highlight'><pre> url = <span class="hljs-constant">GroupDocs::Api::Request</span>.new(<span class="hljs-symbol">:path</span> =&gt; iframe).prepare_and_sign_url</pre></div></div> </li> <li id="section-37"> @@ -688,18 +687,18 @@ </div> <p>Generate iframe URL</p> </div> - <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> base_path - <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span> - iframe = <span class="string">"https://stage-api-groupdocs.dynabic.com<span class="subst">#{url}</span>"</span> - <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span> - iframe = <span class="string">"https://dev-apps.groupdocs.com<span class="subst">#{url}</span>"</span> - <span class="keyword">else</span> - iframe = <span class="string">"https://apps.groupdocs.com<span class="subst">#{url}</span>"</span> - <span class="keyword">end</span></pre></div></div> + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">case</span> base_path + <span class="hljs-keyword">when</span> <span class="hljs-string">'https://stage-api-groupdocs.dynabic.com'</span> + iframe = <span class="hljs-string">"https://stage-apps-groupdocs.dynabic.com/<span class="hljs-subst">#{url}</span>"</span> + <span class="hljs-keyword">when</span> <span class="hljs-string">'https://dev-api-groupdocs.dynabic.com'</span> + iframe = <span class="hljs-string">"https://dev-apps-groupdocs.dynabic.com<span class="hljs-subst">#{url}</span>"</span> + <span class="hljs-keyword">else</span> + iframe = <span class="hljs-string">"https://apps.groupdocs.com<span class="hljs-subst">#{url}</span>"</span> + <span class="hljs-keyword">end</span></pre></div></div> </li> <li id="section-38"> @@ -710,17 +709,17 @@ </div> <p>Make iframe</p> </div> - <div class="content"><div class='highlight'><pre> iframe = <span class="string">"&lt;iframe id='downloadframe' src='<span class="subst">#{iframe}</span>' width='800' height='1000'&gt;&lt;/iframe&gt;"</span> + <div class="content"><div class='highlight'><pre> iframe = <span class="hljs-string">"&lt;iframe id='downloadframe' src='<span class="hljs-subst">#{iframe}</span>' width='800' height='1000'&gt;&lt;/iframe&gt;"</span> - <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e + <span class="hljs-keyword">rescue</span> <span class="hljs-constant">Exception</span> =&gt; e err = e.message - <span class="keyword">end</span> + <span class="hljs-keyword">end</span> - haml <span class="symbol">:sample35</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:userId</span> =&gt; settings.client_id, <span class="symbol">:privateKey</span> =&gt; settings.private_key, <span class="symbol">:iframe</span> =&gt; iframe, <span class="symbol">:err</span> =&gt; err} -<span class="keyword">end</span></pre></div></div> + haml <span class="hljs-symbol">:sample35</span>, <span class="hljs-symbol">:locals</span> =&gt; {<span class="hljs-symbol">:userId</span> =&gt; settings.client_id, <span class="hljs-symbol">:privateKey</span> =&gt; settings.private_key, <span class="hljs-symbol">:iframe</span> =&gt; iframe, <span class="hljs-symbol">:err</span> =&gt; err} +<span class="hljs-keyword">end</span></pre></div></div> </li> </ul> </div>