{"id":1493,"date":"2014-07-02T11:04:36","date_gmt":"2014-07-02T09:04:36","guid":{"rendered":"http:\/\/www.ozalto.com\/?p=1493"},"modified":"2014-07-02T11:02:46","modified_gmt":"2014-07-02T09:02:46","slug":"real-time-currency-conversion-within-adobe-indesign","status":"publish","type":"post","link":"https:\/\/www.ozalto.com\/en\/real-time-currency-conversion-within-adobe-indesign\/","title":{"rendered":"Real time Currency Conversion within Adobe InDesign"},"content":{"rendered":"<p>If you are working with <strong>financial data<\/strong> within <strong>Adobe InDesign<\/strong> in order to build catalogs, financial reports or menu maybe, you may need to <strong>convert prices from one currency to another.<\/strong><\/p>\n<p>Of course, you shouldn&#8217;t have to deal with currency conversion as<strong> it is your client &#8216;s responsibility to provide them<\/strong>. \u00a0But <strong>you end up in charge of the conversion of the 5000 prices<\/strong> in euros in US dollars within your indesign document.<\/p>\n<p><strong>What a tedious task.<\/strong> Put the calculator away, <strong>we are going to change all our prices<\/strong> in a blink. Ice on the cake\u00a0: <strong>In Real Time<\/strong> ! Prices conversion is not your nightmare any longer.<\/p>\n<h3>A) Nice euros prices<\/h3>\n<p>We are going to <strong>generate a dummy and really basic list of prices<\/strong> thanks to <strong>this website<\/strong>\u00a0:\u00a0<strong><a href=\"http:\/\/www.generatedata.com\/\" target=\"_blank\">generatedata<br \/>\n<\/a><\/strong>This is a <strong>really useful website<\/strong> for one looking for building<strong> quick and small databases.<\/strong><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/donnes_avec_rpix_pour_change.png\"><img decoding=\"async\" class=\"aligncenter  wp-image-1489\" alt=\"Donnes avec prix pour change\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/donnes_avec_rpix_pour_change.png\" width=\"551\" height=\"250\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/donnes_avec_rpix_pour_change.png 612w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/donnes_avec_rpix_pour_change-300x136.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/donnes_avec_rpix_pour_change-530x240.png 530w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/donnes_avec_rpix_pour_change-120x54.png 120w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><\/a><\/p>\n<p><strong>The last column hosts our euros prices.<\/strong> We want to <strong>convert them in dollars in real time with very few effort<\/strong>. We will use the <strong>EasyCatalog<\/strong> plugin and one of its unrecognised yet powerful feature\u00a0: the call to <strong>a javascript script<\/strong> !<\/p>\n<h3>B) Javascript Script<\/h3>\n<p>Our script is going to execute a <strong>HTTP request<\/strong> toward this website\u00a0:\u00a0\u00a0<a href=\"http:\/\/rate-exchange.appspot.com\" target=\"_blank\">rate-exchange.appspot.com<\/a> thanks to a\u00a0<strong>Socket Object.<\/strong> I take this opportunity to thank our <strong>great friend and colleague\u00a0Martinho da Gloria<\/strong> from\u00a0<a title=\"Automatication website\" href=\"http:\/\/www.automatication.com\/\" target=\"_blank\">Automatication<\/a>\u00a0for delivering a code designed for http requests.<\/p>\n<p>You can also use a script from\u00a0ChrisKoppieters\u00a0at\u00a0<a title=\"Rorohiko website\" href=\"https:\/\/www.rorohiko.com\/\" target=\"_blank\">Rorohiko<\/a>\u00a0: <a title=\"GetURL link\" href=\"http:\/\/rorohiko.blogspot.fr\/2008_07_01_archive.html\" target=\"_blank\">GetURL<\/a>\u00a0This script allows you to interrogate useful urls for as long you are not behind a proxy.<\/p>\n<p>All we have to now is to <strong>use this script with EasyCatalog.<\/strong><\/p>\n<h3>C) EasyCatalog &amp;\u00a0Javascript<\/h3>\n<p><span style=\"line-height: 1.5em;\">We will create a <strong>custom field<\/strong>, named\u00a0<\/span><strong style=\"line-height: 1.5em;\">&#8220;Prix en dollars US&#8221;<\/strong><span style=\"line-height: 1.5em;\"> and we will use the &#8220;<\/span><strong style=\"line-height: 1.5em;\">CALLSCRIPT<\/strong><span style=\"line-height: 1.5em;\">&#8221; function:<\/span><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/custom_field_callscript.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-1490\" alt=\"custom field with call script\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/custom_field_callscript.png\" width=\"626\" height=\"546\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/custom_field_callscript.png 626w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/custom_field_callscript-300x261.png 300w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/custom_field_callscript-424x370.png 424w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/custom_field_callscript-68x60.png 68w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/custom_field_callscript-361x315.png 361w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><\/p>\n<h3>D) Result<\/h3>\n<p>Et voil\u00e0, in a blink, <strong>all our euro prices are converted in US dollars\u00a0:<\/strong><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/euro_convertis_en_dollars.png\"><img decoding=\"async\" class=\"size-full wp-image-1491 aligncenter\" alt=\"euros convertis en dollars\" src=\"http:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/euro_convertis_en_dollars.png\" width=\"258\" height=\"317\" srcset=\"https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/euro_convertis_en_dollars.png 258w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/euro_convertis_en_dollars-244x300.png 244w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/euro_convertis_en_dollars-48x60.png 48w, https:\/\/www.ozalto.com\/wp-content\/uploads\/2014\/06\/euro_convertis_en_dollars-256x315.png 256w\" sizes=\"(max-width: 258px) 100vw, 258px\" \/><\/a><\/p>\n<p>What&#8217;s great here is that <strong>our dollars prices are dynamically linked to the &#8220;Prix&#8221; column values.<\/strong> If any value is subject to changes, then the price will be automatically converted again ! Our document can then be updated very easily !<\/p>\n<h3>E) Conclusion<\/h3>\n<p>Once again a graphic designer has not to deal with prices conversions. The clients has to. However we wanted to <strong>demonstrate through this example the feasibility of a real time currency conversion within InDesign<\/strong> thanks to the <strong>advanced features of EasyCatalog.<\/strong><\/p>\n<p>Advanced users will wonder <strong>why choose to call a script rather than using the MUL (multiple by) function and use a static value ?<\/strong> You can certainly do that with the same result. No worries. <strong>Our intention here was to push back the limits of the\u00a0EasyCatalog\/Javascript combination.<\/strong><\/p>\n<p>While preparing this post, we wondered what could be a\u00a0prime example of using a javascript with EasyCatalog. What would justify teh call to a javascript file. <strong>How could javascript extend the use of the EasyCatalog plugin ?<\/strong> We think that interrogating a http service can be a good example.<\/p>\n<p>In our case, more than a currency conversion, <strong>we bring reactivity as the ratio is calculated in real time.<\/strong> A Stock Market crash, a skyrocketing share, a supply shortage and eventually <strong>rates going up and down ?<\/strong> In a blink all the <strong>prices are calculated over<\/strong> without the need of looking for the rate at this time.<\/p>\n<p>Also, some websites offer to do <strong>currencies conversion regarding to specific past rates.<\/strong> This may be interesting for who may ever want to do <strong>comparison in prices evolution<\/strong> from one date to another. And who knows\u00a0: <a title=\"Bar graphs with InDesign &amp; EasyCatalog\" href=\"http:\/\/www.ozalto.com\/en\/bar-graphs-with-indesign-easycatalog\/\" target=\"_blank\">generate a nice bar graph<\/a> ?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are working with financial data within Adobe InDesign in order to build catalogs, financial reports or menu maybe, you may need to convert prices from one currency to another. Of course, you shouldn&#8217;t have to deal with currency conversion as it is your client &#8216;s responsibility to provide them. \u00a0But you end up [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1492,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[57,43,42],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1493\/"}],"collection":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/"}],"about":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/types\/post\/"}],"author":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/users\/2\/"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/comments\/?post=1493"}],"version-history":[{"count":0,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/posts\/1493\/revisions\/"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/1492\/"}],"wp:attachment":[{"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/media\/?parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/categories\/?post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ozalto.com\/en\/wp-json\/wp\/v2\/tags\/?post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}