tags:

views:

401

answers:

2

Our client's request is to have tables in PDF with rounded corner. I only have Apache FOP processor at my disposal and it doesn't support the rounded corner attribute. It also doesn't support floats, so floating rounded images to left and to right cannot be done.

Do you have any suggestions on how to do this?

+2  A: 

You can create the table as a Scalable Vector Graphics(SVG) object, and include that as an external-image in your XSL-FO document. SVG supports rounded corners, and FOP supports SVG.

I believe you can also just create a rounded rectangle SVG and use that as a background to your content, and put the table in front of it. I think I did this once, but I cannot seem to locate the code...

Spike Williams
A: 

As long as it is fixed width and dont expect things to 'float' dynamically width-wise like css, I have done this:

Get a rounded corner background image and have it as long as you expect to be on the page (note if you expect things to go onto multiple pages, then this won't work out so well hehe). I use it on headers/footers and things that start a new page (in the body region) that I know won't go more than 1 page.

Then I decide if i need a fixed height ... if so you can just use a background image with no fancyness...

if the height will vary, then I just use the top of the image for one part and the bottom of the image for another part. something like this:

<fo:block-container>
  <fo:block-container background-image="url(images/rounded_corner_image.png)" 
  background-repeat="no-repeat"
  background-position-horizontal="15px" 
  background-position-vertical="top"              
  background-color="white"
  >
  <!-- 
  So it used the top of the image for as long as the block-container exists heightwise.
  I may have had some whitespace in my image and need to move image into place so think I used background-position-horizontal since i had 15px of whitespace i wanted to cut off 
  Also you may set a height above if definatley know you don't need it to 'auto-expand', just make sure you have content that can't overflow if setting height (like a table with Name: Address: fields)
  -->
    <fo:block margin="70px 70px 0px 70px">
      Need to add some margins before starting content since dont want to text to touch the top and sides of of the rounded corner/borders plus add whitespace for content.
    </fo:block>
  </fo:block-container>

  <fo:block-container background-image="url(images/rounded_corner_image.png)" 
  background-repeat="no-repeat"
  background-position-horizontal="15px"
  background-position-vertical="bottom"
  padding="0px 0px 20px 0px"
  background-color="white"
  >
    <fo:block margin="0px 70px 70px 70px">
      Need to add some margins before starting content since dont want to text to touch bottom and sides of of the rounded corner/borders.
    </fo:block>
  </fo:block-container>

</fo:block-container>

Theres various ways to go at it i think. like i had content at the bottom so i just use the bottom knowing i am definately going to have at least 70px of content to show the bottom gradient of my rounded corners.... you may just decide on putting all your content in the first block-container and giving the 2nd block-container a fixed height of 70px to only show the bottom background-image (i think this is possible even though if no content is present in that bottom container [forget xsl-fo rules]). Using FOP trunk and works out nicely.

armyofda12mnkeys