- Label sheet setup – preparing measures needed for page and table setup.
- Page setup – setting margins and zero-height footer.
- Table setup – setting cell size and margins.
- Paragraph setup – setting no spacing between lines.
- Docentric List tagging element setup – using mode for horizontal table rendering.
- Docentric Barcode, Field (and others) tagging elements setup – binding them to the report data source data such as barcode, product name, price, etc.
- Text box setup, if text boxes are used – setting text direction, margins, alignment, etc.
We will demonstrate a technique for designing a label sheet template for the Product labels report in the Retail module. Let’s say that we want to design a template for a 3 x 6 label sheet on A4 paper in the portrait orientation:
First of all, we need to calculate measures that will be used for designing this label sheet template in MS Word.
Label sheet setup
We will be using A4 paper of portrait orientation, with the 3 x 6 label layout.
|Label Width (lw)||6.35 cm|
|Label Height (lh)||4.66 cm|
|Page Top Margin (ptm)||0.87 cm|
|Page Bottom Margin (pbm)||0.87 cm|
|Page Left Margin (plm)||0.775 cm|
|Page Right Margin (prm)||0.775 cm|
|Label Gap Around (lgar)||0 cm|
|Label Gap Across (lgac)||0.2 cm|
|Label Corner Radius||0.15 cm|
The A4 paper size measures 21.0 cm x 29.7 cm. Let’s check if our measures from the above table work:
|21.0 cm (Page Width) =||0.77 cm (Page Left Margin) + 0.78 cm (Page Right Margin) +
3 * 6.35 cm (Label Width) + 2 * 0,2 cm (Label Gap Across)
|29.7 cm (Page Height) =||0.87 cm (Page Top Margin) + 0.87 cm (Page Bottom Margin) +
6 * 4.66 cm (Label Height) + 5 * 0 cm (Label Gap Around)
We will implement the 3 x 6 label sheet layout using a Word 3 x 6 table. The table will serve as a layout grid where each table cell will represent a single label, and will be called Label Area. Also, a table cell will include Label Gap Across on its right side, and Label Gap Around on its bottom side. This means that the top-left corner of a label content will exactly match the top-left corner of a table cell. Consequently, the last table cell in each table row will expand into the area of Page Right Margin which means that we have to decrease it by the Label Gap Across value. It also means that the last row will expand into the area of Page Bottom Margin in case that we have Label Gap Around greater than zero.
Table cells should have the top and left margins set in such a way that they will simplify positioning of a label content in the right place within its table cell (i.e. within its Label Area). That’s why we also need to measure and keep track of Label Top Margin and Label Left Margin.
|Page Top Margin (ptm)||0.87 cm|
|Corrected Page Bottom Margin (cpbm)||Page Bottom Margin – Label Gap Around
= 0.87 cm – 0 cm = 0.87 cm
|Page Left Margin (plm)||0.77 cm|
|Corrected Page Right Margin (cprm)||Page Right Margin – Label Gap Across
= 0.78 cm – 0.2 cm = 0.58 cm
|Label Area Width (law)||Label Width + Label Gap Across
= 6.35 cm + 0.2 cm = 6.55 cm
|Label Area Height (lah)||Label Height + Label Gap Around
= 4.66 cm + 0 cm = 4.66 cm
|Label Top Margin (ltm)||0.7 cm|
|Label Left Margin (llm)||0.6 cm|
Notice how these measures appear in the picture below:
The A4 paper size measures 21.0 cm x 29.7 cm. Just in case, let’s check if our new measures from the above table work:
|21.0 cm (Page Width) =||0.77 cm (Page Left Margin) + 0.58 cm (Corrected Page Right Margin) +
3 * 6.55 cm (Label Area Width)
|29.7 cm (Page Height) =||0.87 cm (Page Top Margin) + 0.87 cm (Corrected Page Bottom Margin) +
6 * 4.66 cm (Label Area Height)
After we have prepared and calculated all needed measures, we can begin to design our label sheet template in MS Word. But first, we need to create a new Docentric template.
Create Docentric template
Docentric templates are just ordinary Word documents, so start with creating a new blank Word document which you can then turn it into a Docentric template by clicking the Use As Template button on the Docentric AX ribbon. In Open File Dialog select the prepared DDSP (Docentric Data Source Package) file for the RetailLabel SSRS report. See how to get this DDSP file >>
Docentric AX ribbon tab is now activated and Element Tree and Data Source panes are open. Next, we will customize the size of the page margins using the measures prepared in the Label sheet setup step.
Open the Page Setup form in order to set custom margins to values calculated in Label sheet setup for design in MS Word.
Note that Bottom margin is set to 0 cm. This is because the default empty paragraph in the document body would otherwise produce an additional empty page at the end of the generated document. We also need to decrease the height of Page footer (i.e. an empty default paragraph in the footer) otherwise the height of the bottom margins (0 cm) will not apply.
Decrease the font of the default empty paragraph in the page footer to minimal possible size: 1.
Insert 3 x 1 table in the document body.
Remove the table borders.
Click the View Gridlines button to turn on table gridlines. Note that the gridlines are not part of the document content and will not get printed.
Table cell size
Adjust the table cell size to be equal to the label area size, i.e. 6.55 cm x 4.66 cm – these are the Label Area Width and Label Area Height values calculated in Label sheet setup for design in MS Word. Open the Table Properties window. As you can see the table width is set to 19.65 cm. This is a number that we get if we add the width of the three table cells (3 * 6.55 cm = 19.65 cm).
Check the Row height property. It should be set to the Exactly value. You can also turn off the Allow row to break across pages option.
Table cell margin
Set Top and Left cell margin to the Label Top Margin and Label Left Margin values measured in Label sheet setup for design in MS Word. These are the values that determine the top-left corner of label content within Label Area, i.e. each table cell.
You can check if Cell margins are the same as the whole table.
Turn formatting marks on. After we press the button as on the picture below, we will see paragraph marks, dots (for spaces), arrows (for tab characters), and other hidden formatting symbols.
Position the cursor in the first table cell and press the Enter key. Mark the paragraph mark, open the Paragraph form and make sure that there is no spacing between paragraph lines – by setting Before to 0 pt, After to 0 pt, and Line spacing to Single.
List tagging element setup
The report data source contains a list of product labels with their properties such as product bar code, name, price, etc. Our goal is to get printed one product label per table cell, row by row. In other words, we need to render this collection in such way that each item get rendered in the single table cell from beginning to end of the current row, row after row. The number of the filled table cells in the output document equals to the number of the product labels that have been prepared for printing in the report data source.
List tagging element introduces a special mode for such scenarios that are called horizontal rendering. We need to place a List tagging element in the first table cell and to select Table Cell as Render Mode (Step 4). The List element should be bound to RetailLabelTmp, a collection of product labels from the report data source (Step 3).
Design the label using Docentric’s tagging elements
Barcode tagging element
While you are positioned in the List element, click the Barcode button from the Tagging Elements button group on the Docentric AX ribbon tab. The Barcode tagging element is inserted within the List element. Bind this element to the ItemBarCodeNum data field (Step 3) and select the appropriate Symbology (Step 4). In our case it is Code 128.
Use arrow keys to navigate between Docentric tagging elements
Use the keyboard arrow keys instead of the mouse pointer to navigate between Docentric tagging elements (MS Word content controls) and the rest of the document content.
The next thing we need to do is to place a new Field tagging element within the List element and below the Barcode element, right before the last inserted paragraph mark (inserted by pressing the Enter key). Bind this Field tagging element to the VariantId data field (Step 3).
Using Xpath expressions
Below VariantId we want to print out the Text1 data field that usually contains the name of the product. Let’s say that the product name should be written out in upper case. To achieve this we can use XPath editor to select the upper-case() XPath function and create an appropriate XPath expression.
Changing Field tagging element content
When you bind a Field tagging element to a data field, the content of the Field element is filled with the data field name, or in our case, with the corresponding XPath expression. And if the names of data fields are too long, then their bounded Field elements become too long as well, which can result in a messy or distorted template layout. That’s why it is very useful to edit and adjust the content of a Field tagging element after binding it to a data field. For example, we will change @PriceNoDecimals to @P for the sake of a undistorted layout.
Shading and font effects
We can use all Word formatting features while designing templates. To make background color to, e.g. black, click the Shading button on the Home ribbon in MS Word and select the black color. The font color automatically becomes white.
We can also use Font effects such as Superscript to achieve some advanced layouts as on the picture below.
Using text boxes in the label design
We can use text boxes and other shapes when designing a template. In a text box we can place any tagging element except the Barcode element (because it represents a shape). This means that text boxes can contain dynamic data as well. In this template we are going to use a vertical textbox with Rotation of 270 degree, all margins set to 0 cm and Vertical alignment relative to Margin. You can also take advantage of Horizontal position options, taking into account that Label Gap Across value is 0.2 cm. Label Gap Across stands for horizontal space between two labels on sheet and has been defined in the Label sheet setup step.
We can also put dynamic content in the text box, if needed. Let’s say that we want to print out the current company name inside the text box. Place a new Field tagging element within the text box and bind it to the company name from the GeneralData data section of the report data source.
The finished template looks as follows:
Generate the preview from the template by clicking the Preview button on the Docentric AX ribbon tab. The resulting document should look like this:
MS Word offers different techniques for designing labels. You can even employ Word’s built-in wizard to quickly get the layout grid (table) and start from there with templating. Nevertheless, be careful on how label content is being positioned within a table cell; perhaps the measurements (top and left page margin, label width and height, horizontal and vertical gaps between labels, etc.) from this article should have been conducted differently.
If you have a scenario that does not fit into the techniques described in this article, please contact us. We are happy to discuss your particular case.