Jump to content

Formatting price


Olivier

Recommended Posts

Hi friends, I have to build a FusionPro template with a text rule to be able to have prices like this :

https://www.dropbox.com/s/h6dgisrjhjgmgd0/Capture%20d%27%C3%A9cran%202018-05-14%2010.08.41.png?dl=0

 

I know how to use the € as a superscript but need help to place the cents bellow the €.

 

Help is more than welcome ! :)

 

Best regards,

Olivier

FusionPro 10.0.26

AcrobatPro 10.1.16

InDesign CC2017

MacOS 10.12.6

Link to comment
Share on other sites

It's hard to know exactly what you need to do without seeing at least the data. You could create a table, or use something like a repeatable component. But if the price is always going to be on a fixed position on the page like that, then I think the easiest thing is just to have three separate text frames: One for the integral price, one for the Euro symbol, and one for the cents. You only need two rules to populate the two frames with the parts of the price, something like this:

// "Whole" amount
var price = parseFloat("$3".replace(/[^\d\.]/g, ''));
return Int(price);

and:

// Cents
var price = parseFloat("$3".replace(/[^\d\.]/g, ''));
return FormatNumber("00", Math.round((price % 1) * 100));

Or, inject both parts in OnRecordStart:

var price = parseFloat("$3".replace(/[^\d\.]/g, ''));
FusionPro.Composition.AddVariable("WholePrice", Int(price));
FusionPro.Composition.AddVariable("Cents", FormatNumber("00", Math.round((price % 1) * 100)));

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...