Home
Analytics
Absolute Positioning of Page Elements?
robilco
Hi All,
I'm looking at a customer requirement I'd like to fulfil using BIRT: Absolute Positioning.
Does BIRT have the capability to position report elements at absolute locations (x & y page coordinates/pixels) ?
If anyone has experience with this, I'd appreciate some advice.
Cheers,
Ronan
Find more posts tagged with
Comments
mluggen
Hi Ronan,
Not really sure what exactly you like to position absolutely? Dynamic data or fixed elements which repeat them self on each page?
For the second you can do this through the Master Page. (By setting the margins of the elements.) The first is technically not really possible as the output is dependent the amount of entries you want to show. (You can try to have a new page per entry and doing the same by setting the element margins to set the position exactly.)
HTH
Michael
robilco
<blockquote class='ipsBlockquote' data-author="'mluggen'" data-cid="113810" data-time="1359712964" data-date="01 February 2013 - 03:02 AM"><p>
Hi Ronan,<br />
<br />
Not really sure what exactly you like to position absolutely? Dynamic data or fixed elements which repeat them self on each page?<br />
<br />
For the second you can do this through the Master Page. (By setting the margins of the elements.) The first is technically not really possible as the output is dependent the amount of entries you want to show. (You can try to have a new page per entry and doing the same by setting the element margins to set the position exactly.)<br />
<br />
HTH<br />
Michael<br /></p></blockquote>
<br />
Thanks Michael,<br />
<br />
I'd just like to position elements at fixed locations on the page in my PDF.<br />
<br />
These fixed locations will be unknown until runtime, and passed to me as x & y values.<br />
<br />
So, ideally I'd like to put a script or style into my rptdesign with some tokens that I can replace at runtime with exact x & y locations.<br />
<br />
Ronan
robilco
I've got it working for HTML output, using the rptdesin below.<br />
<br />
But it does not work for PDF outputs.<br />
<br />
<blockquote class='ipsBlockquote' ><p>
<?xml version="1.0" encoding="UTF-8"?><br />
<report xmlns="<a class='bbc_url' href='
http://www.eclipse.org/birt/2005/design'>http://www.eclipse.org/birt/2005/design"</a>
; version="3.2.22" id="1"><br />
<property name="createdBy">Eclipse BIRT Designer Version 3.7.1 Build <3.7.1.v20110913-1734></property><br />
<property name="units">in</property><br />
<property name="iconFile">/templates/blank_report.gif</property><br />
<property name="bidiLayoutOrientation">ltr</property><br />
<property name="imageDPI">96</property><br />
<styles><br />
<style name="report" id="4"><br />
<property name="fontFamily">sans-serif</property><br />
<property name="fontSize">10pt</property><br />
</style><br />
</styles><br />
<page-setup><br />
<simple-master-page name="Simple MasterPage" id="2"/><br />
</page-setup><br />
<body><br />
<text name="test11" id="11"><br />
<expression name="bookmark" type="javascript">"test11"</expression><br />
<property name="contentType">html</property><br />
<text-property name="content"><![CDATA[111<br />
<script><br />
var el = document.getElementById('test11');<br />
el.style.position = "absolute";<br />
el.style.top = 100;<br />
el.style.left = 100;<br />
</script>]]></text-property><br />
</text><br />
<text name="test22" id="13"><br />
<expression name="bookmark" type="javascript">"test22"</expression><br />
<property name="contentType">html</property><br />
<text-property name="content"><![CDATA[222<br />
<script><br />
var el = document.getElementById('test22');<br />
el.style.position = "absolute";<br />
el.style.top = 100;<br />
el.style.left = 125;<br />
</script>]]></text-property><br />
</text><br />
</body><br />
</report><br /></p></blockquote>
mluggen
Hi Ronan,<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'robilco'" data-cid="113811" data-time="1359717342" data-date="01 February 2013 - 04:15 AM"><p>
So, ideally I'd like to put a script or style into my rptdesign with some tokens that I can replace at runtime with exact x & y locations.<br /></p></blockquote>
<br />
Okay if you like to do positioning based on the values you have to do some scripting.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'robilco'" data-cid="113814" data-time="1359720470" data-date="01 February 2013 - 05:07 AM"><p>
I've got it working for HTML output, using the rptdesin below.<br />
<br />
But it does not work for PDF outputs.<br /></p></blockquote>
<br />
This is quite normal as your code is changing the position of the elements at the time the HTML is shown. The PDF does not have this possibility to change stuff after the fact.<br />
<br />
You need to do scripting which is influencing already the generation of the report. (Have a look here <a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php#reportitemexamples'>http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php#reportitemexamples</a>
; as a head start)<br />
<br />
This will lead you to some code for the elements like this in the element onCreate() function:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>this.getStyle().paddingLeft = this.getValue()+"mm";</pre>
<br />
You need to hack a bit around to get the both values into the same field.<br />
<br />
HTH<br />
Michael
robilco
The Problem with padding is that is it relative.<br />
<br />
<blockquote class='ipsBlockquote' ><p>
<?xml version="1.0" encoding="UTF-8"?><br />
<report xmlns="<a class='bbc_url' href='
http://www.eclipse.org/birt/2005/design'>http://www.eclipse.org/birt/2005/design"</a>
; version="3.2.22" id="1"><br />
<property name="createdBy">Eclipse BIRT Designer Version 3.7.1 Build <3.7.1.v20110913-1734></property><br />
<property name="units">in</property><br />
<property name="iconFile">/templates/blank_report.gif</property><br />
<property name="layoutPreference">fixed layout</property><br />
<property name="bidiLayoutOrientation">ltr</property><br />
<property name="imageDPI">96</property><br />
<styles><br />
<style name="report" id="4"><br />
<property name="fontFamily">sans-serif</property><br />
<property name="fontSize">10pt</property><br />
</style><br />
<style name="Style222" id="14"><br />
<property name="paddingTop">125pt</property><br />
<property name="paddingLeft">150pt</property><br />
</style><br />
</styles><br />
<page-setup><br />
<simple-master-page name="Simple MasterPage" id="2"/><br />
</page-setup><br />
<body><br />
<image id="17"><br />
<property name="height">3.9583333333333335in</property><br />
<property name="width">7.572916666666667in</property><br />
<property name="source">url</property><br />
<expression name="uri" type="constant"><a class='bbc_url' href='
https://www.google.com/images/srpr/logo3w.png</expression>'>https://www.google.com/images/srpr/logo3w.png</expression></a><br
/>
</image><br />
<text name="test22" id="13"><br />
<property name="style">Style222</property><br />
<expression name="bookmark" type="javascript">"test22"</expression><br />
<property name="contentType">html</property><br />
<text-property name="content"><![CDATA[222]]></text-property><br />
</text><br />
</body><br />
</report><br /></p></blockquote>
<br />
In this example, the image appears first, then the Text element is rendered afterwards, having the padding applied to its relative placement.<br />
I want that element to be placed 125pt/100pt from the top of the document, not relative to its un-padded starting position.<br />
<br />
Ronan
mluggen
<blockquote class='ipsBlockquote' data-author="'robilco'" data-cid="113820" data-time="1359732203" data-date="01 February 2013 - 08:23 AM"><p>
The Problem with padding is that is it relative.<br />
<br />
<br />
<br />
In this example, the image appears first, then the Text element is rendered afterwards, having the padding applied to its relative placement.<br />
I want that element to be placed 125pt/100pt from the top of the document, not relative to its un-padded starting position.<br />
<br />
Ronan<br /></p></blockquote>
<br />
Hi Ronan,<br />
<br />
I don't think it is possible to position elements like you wan't on top of another element. You can try if the image is not changing each time to create a CSS Style with a backround image for a (e.g.) cell and than in this cell achieving the positioning with the padding of the element.<br />
<br />
Probably there is an easier solution, do you want describe your use case?<br />
<br />
Regards,<br />
Michael
robilco
<blockquote class='ipsBlockquote' data-author="'mluggen'" data-cid="113821" data-time="1359733170" data-date="01 February 2013 - 08:39 AM"><p>
Hi Ronan,<br />
<br />
I don't think it is possible to position elements like you wan't on top of another element. You can try if the image is not changing each time to create a CSS Style with a backround image for a (e.g.) cell and than in this cell achieving the positioning with the padding of the element.<br />
<br />
Probably there is an easier solution, do you want describe your use case?<br />
<br />
Regards,<br />
Michael<br /></p></blockquote>
<br />
My use case is pretty straight-forward.<br />
I need to print documents that have characters at fixed positions on the page, so the documents will be machine readable.<br />
These fixed positions will be supplied at runtime, as different users have different machines to read documents. (Although that's not too important as I can run the report design through a preprocessing step, replacing tokens with the absolute positions before running)<br />
<br />
Ronan