Introduzione
La console 8.3 e successive tra le varie funzioni, offre la possibilità di generare un'immagine per un codice a barre e di associarla a un campo della console. Questa funzione è utile quando in una newsletter si vuole inserire un codice a barre ad esempio per uno sconto o una promozione legata a un prodotto.
La pagina frontend di sui parleremo sotto (barcode.aspx), andrà ad eseguire il render e a stampare l'immagine del codice a barre, a partire da una sequenza numerica /alfa numerica recuperata dinamicamente su "IdOptin" e argomenti "hash", passati alla pagina.
Questa pagina, per stampare correttamente il codice a barre, richiede la sequenza numerica, precedentemente salvata in uno dei campi di informazioni personali della console. Questo requisito è stato introdotto al fine di impedire l'utilizzo fraudolento delle URL e dei relativi codici a barre generati.
Barcode.aspx risiede nella "frontend" root di ogni console 8.3 o versione successiva e non salva nessuna delle immagini barcode sullo spazio fisico della console. Questo al fine di evitare il sovraccarico del server.
Dall'editor della console, il codice a barre sarà visualizzato con il suo valore di default.
Come generale l'URL
Può essere riferita direttamente dal "src" di un HTML tag usando :
Url di base
http://<consoleurl>/frontend/Barcode.aspx
Url completa con Params
<img src=http://<ConsoleHost>/frontend/Barcode.aspx?idoptin=[_idoptin]&hash=[_hash]&BarcodeHeight=60&SymbologyId=14&NarrowBarWidth=2&bearerbarsmode=0&BitmapTargetFormat=1&Ratio=0&TargetDynField=[LatestShippedOrderID]&FontHeight=0,2 />
L'esempio sopra, richiede un codice a barre i2of5 formattato ( SymbologyId = 14 ), l'impostazione di 60px di altezza e un font di 0.2. Ciascuna simbologia ha il suo settaggio specifico (dalla lunghezza della sequenza numerica, partirà la sua costruzione)
Non dimenticare di sostituire <consolehost> con l'URL reale della tua console MailUp e di riempire il campo destinatario LatestShippedOrderID con un vero codice a barre numerico.
Il campo symbology 14 lo puoi riempire con una lunghezza qualsiasi.
Esempio di Output di un codice a barre
Qi sotto un esempo di Interleaved 2 of 5 realizzato da una sequenza a 14 digits
Parametri richiesti ( Tabella 1)
Nome | Obbligatorio? | Descrizione |
---|---|---|
IdOptIn | y | User Id destinatario |
Hash | y | Hash destinatario |
BarcodeHeight | y | Altezza (in px) dell'immagine codice a barre |
SymbologyId | y | Id rappresentante il formato codice a barre ( 14 = ITF ) |
TargetDynField | y | Il campo dinamico contenente la sequenza numerica barcode |
NarrowBarWidth | n | Larghezza (in pixel) della narrow bar |
BearerBarsmode | n | Imposta quali le barre di tolleranza il codice a barre utilizza ( 0 = Nessuno, 1 = Orizzontale, 2 = Intera ) |
BearerBarsSize | n | Larghezza (in pizel) della barre di tolleranza ( si applica solo se BearerBarsmode > 0 ) |
Ratio | n | Il numero di volte la wide bar sarà visualizzata per ciascun narrow bar |
ChecksumAdd | n | Questo Boolean definisce se la sequenza numerica deve essere completata con una cifra di controllo calcolata ( default è false ) |
IsNumberVisible | n | Se true, visualizza la sequenza numerica di ingresso sotto il codice a barre |
FontHeight | n | Altezza font in punti, usare il punto come separatore |
Symbology format Id reference ( Tabella 2 )
SymbologyId | Symbology name |
---|---|
1 | Codabar |
2 | Code11 |
3 | Code128 |
4 | Code39 |
5 | Code39Ext |
6 | Code93 |
7 | Code93Ext |
8 | Deutsche Post Ident Code |
9 | Deutsche Post Leit Code |
10 | Ean218 |
11 | Ean13 |
12 | Ean14 |
13 | Ean8 |
14 | Interleaved 2 of 5 |
15 | ITF14 |
16 | Msi |
17 | Numly |
18 | Opc |
19 | Planet |
20 | Postnet |
21 | Pzn |
22 | Royal Mail 4 state |
23 | Royal Tnt Post Kix |
24 | Industrial 2 of 5 |
25 | Singapore post 4 State |
26 | SSCC18 |
27 | Swiss Post Parcel |
28 | UPCA |
29 | UPCE |
30 | USP Sack label |
31 | USP Tray label |
BUILD UP YOUR BARCODE URL
Since there's no built in functionality helping you to display a barcode inside the markup, you'll need to build yourself the URL.
No panic, it takes two minutes . Ok, maybe only three
Please follow the brief guide prepared to build your own Barcode Image URL :
- Open any text editor you're comfortable to work with ( we recommend Notepad++ but Windows Notepad will be fine either way)
- Paste in the editable window the following snippet : http://<ConsoleHost>/frontend/Barcode.aspx?idoptin=[_idoptin]&hash=[_hash]&BarcodeHeight=60&SymbologyId=14&NarrowBarWidth=2&bearerbarsmode=0&BitmapTargetFormat=1&Ratio=0&TargetDynField=[LatestShippedOrderID]&FontHeight=0,2
- Now replace those parts of the query string marked in red with actual information : <consolehost> must be replace with your console URL ( for instance a8g5c.mailup.com ) and LatestShippedOrderId with the Dynamic Field you've defined holding ( and filled in with ) the barcode numeric number.
- Select it entirely ( CTRL + A ) and copy it to clipboard ( CTRL +C )
- Now open your web browser and Log into your MailUp console
- Click on Messages–> Email–> New–> Create New Email as below
- Type in subject textbox and jump to the HTML editor area, then click on the HTML tab at the bottom of it and click on the "<> HTML" tab as shown in the below screen shot
- Write a plain and empty HTML Img tag such as <img src="" /> in the writable area of the editor as below
- Now it's time to fill the Image tag "src "property with the actual barcode module path : barcode image path must always display an absolute path : <img src="PASTE HERE YOUR BARCODE URL PREVIOUSLY COPIED FROM NOTEPAD" />
- Click on Save. Now you should be seeing the barcode rendered in the preview window as below
RENDERING FAILURE
The application may receive a wrong sequence format against a certain symbology : the application won't display any error message but it will display instead an empty 1x1 pixel image so that the calling image won't appear as broken.