An Oracle blog about BI Publisher

  • RTF
    December 18, 2009

Avery Labels

I have seen various postings on being able to use BIP with Avery label templates. Im not limited to Avery here, there are other templates out there too. I have recently been working with John and colleagues over in Oklahoma City who were desperate; desperate might be too strong a word but they needed, at least, to get BIP generating their address labels.

Problem was, existing solutions, my efforts so far have fallen into this category, would work for a page or even a couple but after that things started to slip down the page and you started to get addresses spanning labels and it degenerated into a big mess very quickly.

If you take a look at Avery's templates


You'll notice that they put in the nice Word shapes to show you where the label is on the paper. Looks great and your mind, as a template developer falls immediately to using a shape file and manipulating it for a really groovy BIP template. Sadly, the shape manipulation support is not aware of margins and headers and footers. So it will keep repeating the label shape off the bottom of the page and on to the next. Its not an easy thing to address. I once spoke to Edward (RTF parser builder extraordinaire) about the shape support. They are not bound by the margins, etc so can be placed any where on the page leading to issues when you want repeat them down the page.

So the shape approach is out; I took a closer look at the Avery template.


There is actually a table behind the scenes keeping the shapes in their place. Worth a look. I went down the path of a previous post, using a single row and a for-each loop. I ran into another problem with keeping rows on the page and getting addresses to run across and then down. That was out then.

During this time I was writing the old school cross-tabbing post. That got me thinking about another solution.

Rather than trying to work with a row of a table; how about a single cell and some cross tabbing tricks. Looking closer at the table:



We have that nasty spacer column to deal with. All we need is the top left cell with the spacer column. A little bit of table manipulating and I had a single cell made up of the top left cell extended by the spacer column. Graphic shows the modified top left cell and the next below with the spacer column still present.

If I can repeat that cell across the page and then down I will get the spacing I need to get the document to print on the label paper.

Here's the template:Avery5.jpg

Not much to it really, just a couple of neat tricks with some help from template meister Hok-Min. Heres the data structure we were working with:



<STREET>1 Oracle Street</STREET>

<CITY>Redwood Shores</CITY>





<STREET>2 Oracle Street</STREET>

<CITY>Redwood Shores</CITY>





Here are the fields and their contents:

FE<?for-each:ADDRESS[position() mod 3=1]?>
FEC<?for-each@column:. | following-sibling::ADDRESS[position()<3]?>
STREET <?.?>
EFE <?end for-each?>
EFE<?end for-each?>
The first loop outside of the cell is looping over the ADDRESS in groups of three. The inner loop uses the @column to repeat the column (actually just the cell) the:
  . | following-sibling::ADDRESS[position()<3]

command, has the loop only looping triplets of columns across the page. We check that the following record number in the loop is less than 3.

I use <?.?> to just drop in the complete ADDRESS block ie all of its children in one go. you could equally drop in the individual fields too. One word of advice; you may need to adjust the font size to get the correct number of rows to show on each page. The template I was working with was 3x10 and needed 9 point font for Calibri. Arial needed to be 8 point.

If you're interested you can get the RTF template and some sample data for the 3x10 Avery label layout

Join the discussion

Comments ( 8 )
  • Vetri Sunday, December 20, 2009
    Here is a sample, i have fixed avery
  • Samantha Brian Tuesday, March 16, 2010
    I like the blog, but could not find how to subscribe to receive the updates by email. Can you please let me know?
  • Binish Gopal Wednesday, July 28, 2010
    Thanks Tim for this nice post.
    What output format would you recommend for this? PDF of RTF? When I tried RTF output, the row heights are enforced to 1", for many rows its less than that!!
    When I tried PDF output, there were two problems:
    1. the header space is more than the avery template
    2. each columns are slightly smaller than the avery template
    I was using oracle ebiz 11.5.10 xml publisher to do this.
    Do you know why this is happening and know of any workaround or solution?
  • CouncilMan Sunday, August 8, 2010
    Trailers Coming SoonResident Evil Afterlife, n a world ravaged by a virus infection, turning its victims into the Undead, Alice (Milla Jovovich), continues on her journey to find survivors and lead them to safety. Her deadly battle with the Umbrella Corporation reaches new heights, but Alice gets some unexpected help from an old friend. A new lead that promises a safe haven from the Undead takes them to Los Angeles, but when they arrive the city is overrun by thousands of Undead – and Alice and her comrades are about to step into a deadly trap.
  • resident evil online Monday, September 20, 2010
    So far for me this was my favorite in the series... though none were much good haha!
  • Rico Finnel Thursday, September 23, 2010
    Hey, awesome website. I actually came across this on Yahoo, and I am happy I did. I will definately be coming back here more often. Wish I could add to the conversation and bring a bit more to the table, but am just absorbing as much info as I can at the moment.
    Thank You
    watch movies online
  • guest Friday, September 12, 2014

    I am trying to do the same for a chart to print across 4 columns then down. I always end of getting no data to display. I then place it in a for each-group and it displays the chart but repeats it. Need help.

  • guest Tuesday, February 21, 2017

    how do now add page break by state to this example.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.