Position texts based on x-y

Here should go questions about transforming XML with XSLT and FOP.
bright
Posts: 1
Joined: Thu Jul 02, 2009 8:41 am

Position texts based on x-y

Post by bright »

I am totally new in xsl but I need this quite urgently. so my apology if I ask silly questions.

basically what i have is a set of texts and an image of a form.
I know the x-y position of each field to be filled in for this form, and and i have values for each of these fields.

What i want to do is, I want to set this image as the background, and position text values for each field according to their x-y position.

then I'll use this xml/xsl file pair together with FOP to generate a pdf document.

I generate this xml file using a java program with information such as field value & field coordinates, and form image provided.

My question is, how do I define xsl file and so that I can create my xml file with x-y position as attributes and field values so that I can use it to generate a pdf file?


eg.

image: C:/form1.jpg
FIELD1 = "this is my name";
FIELD1 x position = 102px;
FIELD1 y position = 250px;
FIELD2 = "my addresss";
FIELD2 x position = 132px;
FIELD2 y position = 290px;

so how do i go about with the above example?


What I want is more like a floating drawing objects for each of these items.

Also for the background image, it should be the background of whole page rather than inserting an image. It can be an image ON the page if everything is "floating" rather than "inline".


Cheers
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: Position texts based on x-y

Post by Dan »

You should generate a FO file like the one below:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body margin="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body" font="12pt Times">

<fo:block>
<fo:external-graphic src="http://www.oxygenxml.com/img/newVisualSchemaEditor1.gif"
background-position-horizontal="left" background-position-vertical="top"
/>

<fo:block-container position="absolute"
top="20pt" left="40pt" height="14pt" width="40pt">
<fo:block font="10pt Arial" color="red" border="2px solid red">Over</fo:block>
</fo:block-container>

</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
If you transform this with the XEP FO processor you will get a floating block with a red border over the image. The block can be positioned using the top, and left attributes. Your XSL should generate a similar file.

Cheers,
Dan
Post Reply