Jump to content

Space and Alignment issues in PDF


mkchechu

Recommended Posts

Hi,

We have integrated the JasperReports to our product. We have noticed that the look and feel among the different outputs say HTML, PDF and XLS are different. The space between the labels and text values (in Header section) in HTML output is as expected whereas there is more space in PDF. Also Vertical alignment for the columns is bottom aligned, but in PDF is it is top aligned. It looks as expected in HTML & XLS but not in PDF. We need only specified 1 space between labels and text values, and column should be bottom aligned in PDF output.

I have attached screen shot for your perusal.

Please advise us.

Thanks!!

 

Link to comment
Share on other sites

  • 1 year later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

mkchechu
Wrote:

Hi,

We have integrated the JasperReports to our product. We have noticed that the look and feel among the different outputs say HTML, PDF and XLS are different. The space between the labels and text values (in Header section) in HTML output is as expected whereas there is more space in PDF. Also Vertical alignment for the columns is bottom aligned, but in PDF is it is top aligned. It looks as expected in HTML & XLS but not in PDF. We need only specified 1 space between labels and text values, and column should be bottom aligned in PDF output.

I have attached screen shot for your perusal.

Please advise us.

Thanks!!

 

>> We have noticed that the look and feel among the different outputs say HTML, PDF and XLS are different.  ...Vertical alignment for the columns is bottom aligned, but in PDF is it is top aligned. It looks as expected in HTML & XLS but not in PDF.

I have run into this problem as well when I use different fonts:  Times-Roman for the label's PDF Font, and Courier for the text value.  If I use the same font, I don't have the problem that I have noticed.

For example, where the static label is top aligned, I have to make the text value verticalAlignment="Middle" for them to match (for you, since you want a "Bottom" alignment, you may have no recourse).

But I have run into a situation where I cannot rectify the vertical alignment.  With our web app, we make use of a text editor called tinyMCE for entry of certain parameters which will be printed on the JasperReport.  It adds tags such as "p" and "b" (within angle brackets, of course -- see "Text Field Expression" code below).  I have to convert the text in a variable so that it can be processed properly by jasper, using styled text.

However, once I specify styled text, Jasper appears to ignore the vertical alignment of "Middle" that I had specified, and it reverts to "Top" alignment (except when running the report from iReport!).

What is puzzling is that when I run the report from iReport 2.0.5, use of styled text doesn't undo my vertical alignment specification.

Anyway, I figured that I could add a style tag in the "Text Field Expression" specifying vertical alignment of "Middle".  However, specification of vertical alignment with the style tag is not having any effect.

The version of the Jasper engine embedded in our purchased web application is 2.05, so we may be somewhat constrained in our options, since I guess both styled text and PDF fonts are deprecated.  I will submit a bug report to see whether this have been fixed in recent versions.

René

Code:
Text Field Expression for $P{PaymentSched}:"<style verticalAlignment="Middle">" + $P{PaymentSched}.replaceAll("<p></p>","<br />").replaceAll("</p><p>","<br /><br />").replaceAll("<p>","").replaceAll("</p>","<br />").replaceAll("<b>","<style isBold="true" pdfFontName="Helvetica-Bold">").replaceAll("</b>","</style>").replaceAll(" "," ") + "</style>"
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...