Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

## Pattern issue with PDF forms developed from Designer

Level 4

We have XDP form (attached sample) which needs a field to have 10 leading and 8 trailing digits. we have added this pattern to all options (Data/Display/Edit/Validation) num{zzzzzzzzz9.zzzzzzz9} and also added leading and trailing digit number to field tab.

issue start appearing when we have to put trailing digits more than 5.

we put 135,235,234.2509, it shows 135,235,234.25090

we put 135,235,234.250885 it shows 135,235,234.25088501

we put 1,132,235,234.25024 it shows 1,132,235,234.25024009

It put trailing digits randomly and we cannot have this behavior.

Is there a way to fix it or approach differently?

1 Accepted Solution

Level 10

Your patterns aren't correct for the decimal places.

Use num{z,zzz,zzz,zz9.88888888} instead. The 8 stands for an optional decimal place which is not 0.

1,132,235,234.25024 will be formatted as 1,132,235,234.25024 an 1,132,235,234.25000000 as 1,132,235,234.25.

To display a fixed number of decimal places use 9 instead of 8.

num{z,zzz,zzz,zz9.99999999} will show always 8 decimal places.

num{z,zzz,zzz,zz9.99998888} will show at least 4 and up to 8 decimal places.

To allow entering of numbers either with or without separators and optional decimal places combine two patterns.

num{zzzzzzzzz9.88888888}|num{z,zzz,zzz,zz9.88888888}

11 Replies

Level 4
```<?xml version="1.0" encoding="UTF-8"?>
<?xfa generator="Designer_V6.5.0.20201118.1.940732" APIVersion="3.6.20252.0"?>
<template xmlns="http://www.xfa.org/schema/xfa-template/3.6/">
<?formServer defaultPDFRenderFormat acrobat11.0dynamic?>
<subform name="form1" layout="tb" locale="en_US" restoreState="auto">
<pageSet>
<pageArea name="Page1" id="Page1">
<contentArea x="0.25in" y="0.25in" w="576pt" h="756pt"/>
<medium stock="default" short="612pt" long="792pt"/>
<?templateDesigner expand 1?></pageArea>
<?templateDesigner expand 1?></pageSet>
<subform w="576pt" h="756pt">
<draw name="Quantity" w="27.869mm" h="6.35mm">
<value>
<text>Quantity</text>
</value>
<ui>
<textEdit/>
</ui>
<font weight="bold"/>
</draw>
<field name="quantityfield" w="60.678mm" x="31.75mm" h="6.421mm">
<ui>
<numericEdit>
<border>
<edge presence="hidden"/>
<edge presence="hidden"/>
<edge/>
<edge presence="hidden"/>
</border>
<margin/>
</numericEdit>
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</ui>
<font size="8pt" typeface="Charles Modern" weight="bold" letterSpacing="-0.005em" kerningMode="pair"/>
<margin topInset="0mm" bottomInset="0mm" leftInset="0mm" rightInset="0mm"/>
<para vAlign="middle" marginLeft="3pt" spaceAbove="0pt" spaceBelow="0pt"/>
<value>
</value>
<assist>
<toolTip>Quantity</toolTip>
<speak>Quantity</speak>
</assist>
<bind>
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</bind>
<format>
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</format>
<validate>
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</validate>
</field>
<field name="DollarField" w="56.302mm" h="5.334mm" x="69.85mm" y="66.675mm">
<ui>
<numericEdit>
<border>
<edge presence="hidden"/>
<edge thickness="0.0882mm" presence="hidden"/>
<edge thickness="0.0882mm"/>
<edge thickness="0.0882mm" presence="hidden"/>
<corner presence="hidden" thickness="0.176mm"/>
<corner thickness="0.088mm" presence="hidden"/>
<corner thickness="0.088mm"/>
<corner thickness="0.088mm" presence="hidden"/>
</border>
<margin/>
</numericEdit>
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</ui>
<font size="8pt" typeface="Charles Modern" kerningMode="pair" letterSpacing="-0.005em" weight="bold"/>
<margin topInset="0mm" bottomInset="0mm" leftInset="0mm" rightInset="2.4694mm"/>
<para vAlign="bottom" marginLeft="3.002pt" spaceBelow="1pt"/>
<value>
<decimal fracDigits="-1"/>
</value>
<caption reserve="2.0472mm">
<value>
<text>\$ </text>
</value>
<font size="8pt" typeface="Charles Modern" baselineShift="0pt" kerningMode="pair" letterSpacing="-0.005em"/>
<para vAlign="bottom" spaceAbove="0pt" spaceBelow="1pt" textIndent="0pt" marginLeft="0pt" marginRight="0pt"/>
</caption>
<assist>
</assist>
<format>
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</format>
<bind match="none">
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</bind>
<validate>
<picture>num{z,zzz,zzz,zz9.zzzzzzz9}</picture>
</validate>
</field>
<?templateDesigner expand 1?></subform>
<proto/>
<desc>
<text name="version">6.5.0.20210825.1.942814.932721</text>
</desc>
<?templateDesigner expand 1?></subform>
<?templateDesigner DefaultPreviewDynamic 1?>
<?templateDesigner DefaultRunAt client?>
<?templateDesigner Grid show:1, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?>
<?templateDesigner DefaultLanguage JavaScript?>
<?acrobat JavaScript strictScoping?>
<?templateDesigner WidowOrphanControl 0?>
<?templateDesigner SavePDFWithLog 0?>
<?templateDesigner FormTargetVersion 36?>
<?templateDesigner Zoom 90?>
<?templateDesigner SaveTaggedPDF 0?>
<?templateDesigner SavePDFWithEmbeddedFonts 0?>
<?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?></template>
<config xmlns="http://www.xfa.org/schema/xci/3.0/">
<agent name="designer">
<!--  [0..n]  -->
<destination>pdf</destination>
<pdf>
<!--  [0..n]  -->
<fontInfo/>
</pdf>
</agent>
<present>
<!--  [0..n]  -->
<pdf>
<!--  [0..n]  -->
<fontInfo>
<embed>0</embed>
</fontInfo>
<tagged>0</tagged>
<version>1.7</version>
</pdf>
<xdp>
<packets>*</packets>
</xdp>
</present>
<psMap>
<font typeface="Charles Modern" psName="CharlesModern-Bold" weight="bold" posture="normal"/>
<font typeface="Charles Modern" psName="CharlesModern" weight="normal" posture="normal"/>
<font typeface="Charles Modern Light" psName="CharlesModern-Light" weight="normal" posture="normal"/>
</psMap>
</config>
<localeSet xmlns="http://www.xfa.org/schema/xfa-locale-set/2.7/">
<locale name="en_US" desc="English (United States)">
<calendarSymbols name="gregorian">
<monthNames>
<month>January</month>
<month>February</month>
<month>March</month>
<month>April</month>
<month>May</month>
<month>June</month>
<month>July</month>
<month>August</month>
<month>September</month>
<month>October</month>
<month>November</month>
<month>December</month>
</monthNames>
<monthNames abbr="1">
<month>Jan</month>
<month>Feb</month>
<month>Mar</month>
<month>Apr</month>
<month>May</month>
<month>Jun</month>
<month>Jul</month>
<month>Aug</month>
<month>Sep</month>
<month>Oct</month>
<month>Nov</month>
<month>Dec</month>
</monthNames>
<dayNames>
<day>Sunday</day>
<day>Monday</day>
<day>Tuesday</day>
<day>Wednesday</day>
<day>Thursday</day>
<day>Friday</day>
<day>Saturday</day>
</dayNames>
<dayNames abbr="1">
<day>Sun</day>
<day>Mon</day>
<day>Tue</day>
<day>Wed</day>
<day>Thu</day>
<day>Fri</day>
<day>Sat</day>
</dayNames>
<meridiemNames>
<meridiem>AM</meridiem>
<meridiem>PM</meridiem>
</meridiemNames>
<eraNames>
<era>BC</era>
</eraNames>
</calendarSymbols>
<datePatterns>
<datePattern name="full">EEEE, MMMM D, YYYY</datePattern>
<datePattern name="long">MMMM D, YYYY</datePattern>
<datePattern name="med">MMM D, YYYY</datePattern>
<datePattern name="short">M/D/YY</datePattern>
</datePatterns>
<timePatterns>
<timePattern name="full">h:MM:SS A Z</timePattern>
<timePattern name="long">h:MM:SS A Z</timePattern>
<timePattern name="med">h:MM:SS A</timePattern>
<timePattern name="short">h:MM A</timePattern>
</timePatterns>
<dateTimeSymbols>GyMdkHmsSEDFwWahKzZ</dateTimeSymbols>
<numberPatterns>
<numberPattern name="numeric">z,zz9.zzz</numberPattern>
<numberPattern name="currency">\$z,zz9.99|(\$z,zz9.99)</numberPattern>
<numberPattern name="percent">z,zz9%</numberPattern>
</numberPatterns>
<numberSymbols>
<numberSymbol name="decimal">.</numberSymbol>
<numberSymbol name="grouping">,</numberSymbol>
<numberSymbol name="percent">%</numberSymbol>
<numberSymbol name="minus">-</numberSymbol>
<numberSymbol name="zero">0</numberSymbol>
</numberSymbols>
<currencySymbols>
<currencySymbol name="symbol">\$</currencySymbol>
<currencySymbol name="isoname">USD</currencySymbol>
<currencySymbol name="decimal">.</currencySymbol>
</currencySymbols>
<typefaces>
<typeface name="Minion Pro"/>
<typeface name="Courier Std"/>
<typeface name="Kozuka Gothic Pro-VI M"/>
<typeface name="Kozuka Mincho Pro-VI R"/>
</typefaces>
</locale>
</localeSet>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<xmp:CreatorTool>Designer 6.5</xmp:CreatorTool>
<pdfuaid:part>1</pdfuaid:part>
<pdf:Producer>Designer 6.5</pdf:Producer>
<xmpMM:DocumentID>uuid:61640cd3-7c86-45db-9541-46c82d3a5a42</xmpMM:DocumentID>
<desc:version rdf:parseType="Resource">
<rdf:value>6.5.0.20210825.1.942814.932721</rdf:value>
<desc:ref>/template/subform[1]</desc:ref>
</desc:version>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta></xdp:xdp>```

Employee

HI @manu-gupta ,

your patterns are too long. Max number of digits are 15, change to num{z,zzz,zzz,zz9.zzzz9} and it will work. In your case 10 digits before and 5 digits after the decimal point.

Kosta

Employee

Remove all the patterns and use the following script on the exit event of the field to add the trailing decimal zeros.

```var n = Number(this.rawValue);
this.rawValue = n.toFixed(8);```

Employee

@Mayank_Tiwari nice. Only thing is that without patterns you have to enter the numbers as 135235234.250885 but then it gets converted to 135,235,234.250885 .

Employee

Yes, this seems to be the default behavior of JavaScript in Designer.

Level 4

randomness is added when we add "limit trailing digits" to 8, when we remove it, also the script shared didnt help

Employee

@manu-gupta

I guess you are expecting the following outputs, right?

135,235,234.250885 >> 135,235,234.25088500

1,132,235,234.25024  >> 1,132,235,234.25024000

are you able to achieve it now? If yes, what pattern did you use?

Level 4

we are expecting whatever we type in prescribed format 10.8 decimal pattern

Like I said in other reply to @radzmar we are able to achieve solution PARTIALLY upto 10 leading and 7 trailing digits, with no script and no leading and trailing digits specified, only regex of num{zzzzzzzzz9.8888888}

but it is adding decimal point when whole number is supplied like 12345 --> is getting displayed as 12345.

So we need to know how we can get rid of it

Also we cannot limit leading and trailing digits

Manu

Level 10

Your patterns aren't correct for the decimal places.

Use num{z,zzz,zzz,zz9.88888888} instead. The 8 stands for an optional decimal place which is not 0.

1,132,235,234.25024 will be formatted as 1,132,235,234.25024 an 1,132,235,234.25000000 as 1,132,235,234.25.

To display a fixed number of decimal places use 9 instead of 8.

num{z,zzz,zzz,zz9.99999999} will show always 8 decimal places.

num{z,zzz,zzz,zz9.99998888} will show at least 4 and up to 8 decimal places.

To allow entering of numbers either with or without separators and optional decimal places combine two patterns.

num{zzzzzzzzz9.88888888}|num{z,zzz,zzz,zz9.88888888}

Level 4

Yes, we are able to achieve close to what we needed but with 7 digits after decimal.

Strangely, with this regex we are having extra decimal like

12345 is changing to 12345.

It is not getting removed or worst we have to add JS overhead to trim last char by getting the value and checking if last char is decimal

Any simpler approach to remove this extra decimal?

Employee

these patterns can be a handfull.

Try this approach:
Display pattern: num{z,zzz,zzz,zz9.88888888}

Edit pattern: num{zzzzzzzzz9.88888888}|num{z,zzz,zzz,zz9.88888888}

no validation and no data pattern.

This is the result: