Document Printer

@emre
When document printer is selected, the & symbol causes an error.

There is a problem while printing. Check printer and printer template settings.
Error Message:
An error occurred while parsing EntityName, Line 67 position 155

It wont print when there is an & symbol anywhere in the template, product names or product tags

Can this be resolved?

1 Like

You can encode them.

I stole this…

… from this cool guy.

This is the function text.

function encode(text)
{
  return text.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
    return '&#' + i.charCodeAt(0) + ';';
  });
}
2 Likes

Excellent thanks very much

Just testing here, some products also include ’ and " these product names will not print when {CALL:util.encode(’{NAME}’)}

This script fixes the & Issue but creates another Is there a solution where I can have both.

Try this.

function encode (text) {
    return text.replace(/&/g, '&amp;')
               .replace(/</g, '&lt;')
               .replace(/>/g, '&gt;')
               .replace(/"/g, '&quot;')
               .replace(/'/g, '&apos;');
               
}
2 Likes

No this still does not resolve the issue. Everything works except for the ' I tried replacing the &apos; with &#39; but still no luck.
&apos; works in the document body but when its encoded it won’t

I also noticed the Order Tag Note wont accept a quote symbol "

I need these in product names and and in misc item Order Tag Note to show lengths. Eg. 6’ 10"

Can you post your template so I can test it on my side.

 [LAYOUT]
-- General layout
 <Section FontFamily="Calibri" Margin="0" LineHeight="1">
 <Paragraph FontSize="12" TextAlignment="Center" Padding="0,0,0,10">
 <Image Height="60" Width="300" Source="C:\Logo.png"/><LineBreak/>
 <Run FontSize="20">Reciept #{TICKET ID}</Run>
 </Paragraph>
 <Table FontSize="12">
 <Table.Columns>
      <TableColumn Width="*"/>
 </Table.Columns>
 <TableRowGroup><TableRow>
 	<TableCell><Paragraph>Date: {TICKET DATE}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Right">Time: {TIME}</Paragraph></TableCell>
 </TableRow>
 {ENTITIES}
 <TableRow>
	<TableCell><Paragraph>Cashier:{USER NAME}</Paragraph></TableCell>
 	<TableCell><Paragraph></Paragraph></TableCell>
 </TableRow></TableRowGroup>
 </Table>


 <Table  FontSize="12" BorderThickness="0,0,0,1" BorderBrush="Black">
 <Table.Columns>
       <TableColumn Width="2*"/>
       <TableColumn Width="14*"/>
       <TableColumn Width="4*"/>
 </Table.Columns>
 <TableRowGroup>
 <TableRow>
 	<TableCell BorderThickness="0,0,0,2" BorderBrush="Black"><Paragraph FontSize="14" TextAlignment="Left"><Bold>Qty</Bold></Paragraph></TableCell>
 	<TableCell BorderThickness="0,0,0,2" BorderBrush="Black"><Paragraph FontSize="14" TextAlignment="Left"><Bold>Description</Bold></Paragraph></TableCell>
     <TableCell BorderThickness="0,0,0,2" BorderBrush="Black"><Paragraph FontSize="14" TextAlignment="Right"><Bold>Total</Bold></Paragraph></TableCell>
 </TableRow>
 </TableRowGroup>
 {ORDERS}
 </Table>

 <Table FontSize="12" Padding="0,10">
 <Table.Columns>
       <TableColumn Width="15*"/>
       <TableColumn Width="5*"/>
</Table.Columns>
 {DISCOUNTS}
 {SERVICES}
 {TAXES}
 <TableRowGroup><TableRow>
 	<TableCell><Paragraph FontSize="14" TextAlignment="Right"><Bold>Total:</Bold></Paragraph></TableCell>
 	<TableCell><Paragraph FontSize="14" TextAlignment="Right"><Bold>€{TICKET TOTAL}</Bold></Paragraph></TableCell>
 </TableRow></TableRowGroup>
 {PAYMENTS}
 [<TableRowGroup><TableRow>
 	<TableCell><Paragraph FontSize="14" TextAlignment="Right">Change:</Paragraph></TableCell>
 	<TableCell><Paragraph FontSize="14" TextAlignment="Right">€{CHANGE TOTAL}</Paragraph></TableCell>
 </TableRow></TableRowGroup>
 ]
 [<TableRowGroup><TableRow>
 	<TableCell><Paragraph FontSize="12" TextAlignment="Right">Total Gift:</Paragraph></TableCell>
 	<TableCell><Paragraph FontSize="12" TextAlignment="Right">€{ORDER STATE TOTAL:Gift}</Paragraph></TableCell>
 </TableRow></TableRowGroup>]
 [<TableRowGroup><TableRow>
 	<TableCell><Paragraph FontSize="14" TextAlignment="Right"><Bold>Balance Due:</Bold></Paragraph></TableCell>
 	<TableCell><Paragraph FontSize="14" TextAlignment="Right"><Bold>€{BALANCE}</Bold></Paragraph></TableCell>
 </TableRow></TableRowGroup>]
 </Table>

 [<Paragraph  FontSize="12" TextAlignment="Center" BorderThickness="0,0.5,0,0.5" BorderBrush="Black" Padding="10">
 <Bold>YOU SAVED €[=F((TN('{CALCULATION TOTAL:Round}')*-1)+(TN('{CALCULATION TOTAL:Discount}')*-1)+(TN('{ORDER TAG TOTAL:Discount Custom}')*-1))] TODAY. THANK YOU!</Bold>
 </Paragraph>]
 </Paragraph>
 <Paragraph>
 <BAR>{TICKET ID}<LineBreak/>
 </Paragraph>

 </Section>

 [DISCOUNTS]
 <TableRowGroup><TableRow>
 	<TableCell><Paragraph TextAlignment="Right">{CALCULATION NAME} %{CALCULATION AMOUNT}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Right">€{CALCULATION TOTAL}</Paragraph></TableCell>
 </TableRow></TableRowGroup>

 [SERVICES]
 <TableRowGroup><TableRow>
 	<TableCell><Paragraph TextAlignment="Right">{CALCULATION NAME}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Right">€{CALCULATION TOTAL}</Paragraph></TableCell>
</TableRow></TableRowGroup>

 [PAYMENTS]
 <TableRowGroup><TableRow>
 	<TableCell><Paragraph TextAlignment="Right">{PAYMENT NAME}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Right">€{PAYMENT AMOUNT}</Paragraph></TableCell>
</TableRow></TableRowGroup>

 [TAXES]
 <TableRowGroup><TableRow>
 	<TableCell><Paragraph TextAlignment="Right">Subtotal:</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Right">€{TAXABLE AMOUNT}</Paragraph></TableCell>
 </TableRow>
 <TableRow>
 	<TableCell><Paragraph TextAlignment="Right">@{TAX NAME}:</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Right">€{TAX AMOUNT}</Paragraph></TableCell>
 </TableRow></TableRowGroup>

 [ORDERS]
 -- Default format for orders
 <TableRowGroup>
 <TableRow>
 	<TableCell><Paragraph>{QUANTITY}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Left">{CALL:util.encode('{NAME}')}</Paragraph></TableCell>
     <TableCell><Paragraph TextAlignment="Right">€{TOTAL PRICE}</Paragraph></TableCell>
 </TableRow>
 </TableRowGroup>
 {ORDER TAGS}

 [ORDERS:Gift]
 -- Format for gifted orders
 <TableRowGroup>
 <TableRow>
 	<TableCell><Paragraph>- {QUANTITY}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Left">{CALL:util.encode('{NAME}')}</Paragraph></TableCell>
     <TableCell><Paragraph TextAlignment="Right"><Bold>GIFT!</Bold></Paragraph></TableCell>
 </TableRow>
 </TableRowGroup>
 {ORDER TAGS}

 [ORDERS:Misc]
 -- Format for gifted orders
 <TableRowGroup>
 <TableRow>
 	<TableCell><Paragraph>{QUANTITY}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Left">{CALL:util.encode('{ORDER TAG NOTE:Misc Item Description}')}</Paragraph></TableCell>
     <TableCell><Paragraph TextAlignment="Right">€{TOTAL PRICE}</Paragraph></TableCell>
 </TableRow>
 </TableRowGroup>

 [ORDERS:Void]
-- Nothing will print for void lines

 [ORDER TAGS]
 -- Format for order tags
 <TableRowGroup>
 <TableRow>
     <TableCell><Paragraph TextAlignment="Right">* </Paragraph></TableCell>
     <TableCell><Paragraph TextAlignment="Left">{CALL:util.encode('{ORDER TAG NAME}')}</Paragraph></TableCell>
     <TableCell><Paragraph TextAlignment="Right">[€{ORDER TAG TOTAL}]</Paragraph></TableCell>
 </TableRow>
 </TableRowGroup>


[ENTITIES:Customer]
 -- Customer entity format
 <TableRow>
 	<TableCell><Paragraph>Customer: {CALL:util.encode('{ENTITY DATA: Customer}')}</Paragraph></TableCell>
 	<TableCell><Paragraph TextAlignment="Right">{CALL:util.encode('{ENTITY NAME}')}</Paragraph></TableCell>
 </TableRow>

Also this code would not work so i removed it
[{CALL:util.encode('{ENTITY DATA:Customer:Company Name}')}<LineBreak/>]
It will not show even if there is data It works without the [ ]

EDIT: I’m having trouble with adding this template in code box but you get the idea of what im doing

OK I found a better solution. For parts you want to allow any characters you can use <![CDATA[{NAME}]]> format. CDATA is a standard XML tag that is useful to process text data.

However that xml tag will be stripped by [ ] printer template processor so it will work fine with next update (.55)

1 Like

Is there an option to hide text overflow on the documnet printer? I would like to limit the descriptions to one line.

I have tried TextTrimming="CharacterEllipsis" and TextWrapping="NoWrap" but they are not recognised

Have you tried a simple expression? Something like:

[='{DESCRIPTION}'.substr(0,10)]

No that does not work

Where / How you’ve tried it?