Hi Paul,
the parse error is caused by the double quotes in the JSON value (not the curly braces).
The parsing works as follows: A PXML-RTL expression is evaluated firstly by the RTL evaluator by searching the PXML-RTL expression for substrings of the pattern {expr} and replacing these by their evaluation result. The result of this substitution is then evaluated in a second pass by the PXML evaluator.
Examples:
Example 1 (a numeric property):
PXML-RTL-expression: 1+{2+3}*4+{5*6}+9
Expression after RTL evaluation: 1+5*4+30+9
Expression after PXML evaluation: 60
Example 2 (a string property, the variable aVariable is set to "foo"):
PXML-RTL-expression: "{aVariable}"+" "+format(4,ARABIC)
Expression after RTL evaluation: "foo"+" "+format(4,ARABIC)
Expression after PXML evaluation: "foo 4"
Example 3 (a string property, the variable aVariable is set to ""foo""):
PXML-RTL-expression: "{aVariable}"+" "+format(4,ARABIC)
Expression after RTL evaluation: ""foo""+" "+format(4,ARABIC)
Expression after PXML evaluation: ERROR because ""f is not a valid start of a PXML-expression
Example 4 (a string property, the variable aVariable is set to "\042foo\042" (\042 is the octal escape for a double quote)):
PXML-RTL-expression: "{aVariable}"+" "+format(4,ARABIC)
Expression after RTL evaluation: "\042foo\042"+" "+format(4,ARABIC)
Expression after PXML evaluation: ""foo" 4"
Example 5 (a string property, the variable aVariable is set to ""foo""):
PXML-RTL-expression: "{aVariable.replaceAll(34.toChar(),"\\042")}"+" "+format(4,ARABIC)
Expression after RTL evaluation: "\042foo\042"+" "+format(4,ARABIC)
Expression after PXML evaluation: ""foo" 4"
So the fix for your problem is to replace any double quotes in the variable by an octal escape.
This you can do by using the RTL replaceAll() method so that your expression would look as follows: "{pr_header.qr_code.replaceAll(34.toChar),"\\042")}"+format(getTotalNumberOfPhysicalPages(),ARABIC)
Your worries regarding the usage of a PXML total page number function like getTotalNumberOfPhysicalPages() are unfounded.
Issues like the need to delay printing until the total number of pages is known, is taken care of. Likewise the bar code images are updated in the preview window as soon as the total number of pages is known.
I am asking myself however if doing it this way isn't overcomplicating things a little.
The mechanism, for what we call the "Page n of m" problem in conjunction with bar codes, is designed to drive an enveloping machine so handle a batch print of documents with variable page length.
If I understand you correctly, then you are not actually interested in actual page numbers but you "just" need a number to bring images into an order.
If this is the case, why don't you simply define a variable in the report that is incremented with each print of the variable pr_header.qr_code like this:
LET aCounter=aCounter+1
PRINT pr_header.*, aCounter
.. and then use the literal code value property with this expression like this: codeValue="{{pr_header.qr_code+";"+aCounter}}"
Then things are straightforward you also don't need to quote the JSON.