michael_s Posted September 2, 2009 Share Posted September 2, 2009 Is there a way to specify line spacing other than Single/1_1_2/Double? In iReport, I've tried to set the markup type to HTML and then put <style type="text/css"> abc { ..... } </style> <div class="abc"> some text here that spills onto multiple lines <div> but that does not seem to work.We want to specify 2-5 pixels between lines in different sections of the report. We'll be doing this for dozens of reports over time, so splitting the text into single line text fields spaced 2-5 pixels apart will really slow production.Is there some other option I'm missing? I own relatively old PDF copies of the guides to Jasper Reports and iReport. If newer copies of either cover this scenario, please let me know and I'll just buy an upgrade.Thank you for the help. Post Edited by michael_s at 09/02/2009 15:10 Link to comment Share on other sites More sharing options...
lucianc Posted September 7, 2009 Share Posted September 7, 2009 JasperReports only supports the three line spacing values that you mentioned.Depending on your exact requirements, it might be possible to customize JR to do this. For instance, you could have a custom JRTextMeasurer implementation that sets a bigger lineSpacing value for certain text elements.Regards,Lucian Link to comment Share on other sites More sharing options...
michael_s Posted September 7, 2009 Author Share Posted September 7, 2009 Thanks so much for the response. I'll look into that. Link to comment Share on other sites More sharing options...
michael_s Posted September 9, 2009 Author Share Posted September 9, 2009 I have started to work on a solution, and would like to discuss getting it accepted into Jasper Reports. We want our reports to have the option of font height 40 dots (using Jasper/Java's 72 dpi) but with line spacing of 2 dots, or 14 line spacing 2.5, and similar. My solution is crude, and I welcome a better proposal - but it requires no changes to Jasper architecture. A superior solution would parameterize the spacing but would require more work.1. In src/net/sf/jasperreports/engine/JRTextElement.java under LINE_SPACING_DOUBLE byte constant, add constants for LINE_SPACING_ONE_DOT, LINE_SPACING_TWO_DOTS, LINE_SPACING_TWO_HALF_DOTS, etc... 2. In src/net/sf/jasperreports/engine/xml/JRXmlConstants.java under LINE_SPACING_DOUBLE String constant, add String constants for the same values created in JRTextElement. Change the lineSpacingMap lookup Map to include the new values as forward and reverse lookups.3. In src/net/sf/jasperreports/engine/xml/TextMeasurer.java, in the function initialize, add something like the following code before the switch (textElement.getLineSpacing())int fontHeight = textElement.getFontSize();float floatFontHeight = 12f; // semi-intelligent defaultif (fontHeight > 0){ floatFontHeight = (float)fontHeight;}Then in the switch, add a case for each of the new values like thiscase LINE_SPACING_THREE_DOTS: lineSpacing = 1f + ( 3f / floatFontHeight ); break;Other than that, I think all necessary changes are in /net/sf/jasperreports/engine/dtds to allow the new values. Again, it works, but it's ugly. Any thoughts? Link to comment Share on other sites More sharing options...
Teodor Danciu Posted September 25, 2009 Share Posted September 25, 2009 Hi, This feature very much depends on the output format that you target.Note that for XLS export, there is absolutely now way to control line spacing.This is the case with other document formats as well.For instance, in HTML/CSS, the line spacing is specified in percentage out of normal line height. So unless you are interested in AWT and PDF outputs, implementing this might not worth it. Thank you,Teodor Link to comment Share on other sites More sharing options...
pepevasc Posted February 7, 2011 Share Posted February 7, 2011 In jasper 3.7.4 there is a property named Line Spacing... where u can specify Post Edited by pepevasc at 02/07/2011 16:21 Link to comment Share on other sites More sharing options...
Teodor Danciu Posted April 19, 2011 Share Posted April 19, 2011 Hi,In the newly released JR 4.0.2, we added three new possible values for the line spacing type: AtLeast, Exact and Proportional.They work in conjunction with an additional numeric value specified by the lineSpacingSize property available for <paragraph> tag in JRXML.The API was refactored to move line spacing properties inside the JRParagraph interface, along with additional paragraph styling properties.Thank you,Teodor Link to comment Share on other sites More sharing options...
michael_s Posted April 19, 2011 Author Share Posted April 19, 2011 Thank you very much for implementing this! I really appreciate the efforts of the Jasper Reports team. Link to comment Share on other sites More sharing options...
visert Posted June 11, 2011 Share Posted June 11, 2011 I have a trouble with updating to 4.0.2 -> generating PDF file the text field go down (carriage return) for no apparent reason.The same report in 4.0.1 not show this "bug" (?) ... and if I generate the same jrxml in two design ambient (4.0.1 and 4.0.2) the report in 4.0.1 is printed in pdf correctly...in 4.0.2 not correctly (see attach).Is caused by linespacing new properites?I dont know... but for the moment I return to 4.0.1 because of my urgency iussue :-) bye Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now