I'm creating a pdf report with itext and I'm having a problem. I create a line separator and immediately below I create a pdfTable. The problem is that de top border of the table is over the line separator I just created. Is any way to down a couple of lines in order to draw the next component with itext and solve this?
Thank you
Please take a look at the API documentation of the PdfPTable class. You'll fond methods such as setSpacingBefore(float spacing) and setSpacingAfter(float spacing). In you case, you could something like:
table.setSpacingBefore(6);
This will introduce a spacing of 6 user units (which by default corresponds with about 1/12 of an inch) before the table.
The spacing you need for "a couple of lines" depends on the leading. The default fonts size is 12 and the default leading is 1.5 times the font size. Two lines would be (2 x (12 x 1.5)) or 36 user units (about half an inch).
Related
I'm trying to build an app that has just a single portrait oriented view. There is a title on top and results label at the bottom of the view, these are locked to top and bottom and center, no problem here.
Now this is the tricky part. I have 9 rows of labels, most single row but couple span out to 2 rows. I want them to spread out evenly between the title and the result-label.
I lock the first label to top-left, lock the leading edges and then set equal vertical distance constraints between the labels. Otherwise ok but the last labels on 3.5 inch display overrun my results -label.
So I adjust either the fontsize or make vertical distance between labels smaller or both. 3.5 inch problem fixed but now there is a big empty gap between the last label and result. On iPhone 6 its really ugly.
I have tried all sorts of methods but can't just get this working.
So basically: how do I reserve 10 % of view height from top and 20 % from bottom and tell Xcode to use the rest 70 % (and all of it) for my 9 rows of label, evenly?
Thanks for help!
Would have posted an image but no rank for such things...
If I understand you right, you need several flexible spaces that will all be the same size. One space in-between each of the labels.
Create UIViews to put between each label, set them all to have equal widths or heights and anchor each one to the views it is supposed to sit between.
I got this idea from another SO question: Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5
The above image was taken from an Android app. I am looking to do the same thing on iOS. I know how to do it using a background image for the dots, but it doesn't look like the Android developer used an image for the dots. Anyone know how this can be done?
I've found the way to do it with content hugging/compression resistance.
Here is the interface builder solution:
Left label has a phrase and lots of dots with line breaking = truncate tail. Content hugging/compression resistance do the rest of job.
I think you can do this without any code. Just use two labels with their baselines aligned, and with a horizontal spacing constraint of 0. The left label would have its text left aligned with say 10 dots added to the end of the string, and the line break mode set to "clips". The right label would also be left aligned, so its text would always be right up against the dots.
After Edit: I couldn't get this to work in IB. It may be possible in code using constraints, but I haven't tried that. It seems like you should be able to do it with 3 labels, with the two outside ones pinned to the edges of the view, and a flexible label in the middle whose text would be dots.
You can use NSAttributedString to format in that way.
Use two colors in two ranges, even bold font for 2nd part.
And calculate the total width (length of your text) and fill dots (.) in between those.
An idea to fill dots:
lets say you have 30 characters space.
str1 contains 10, str2 contains 6, then use 30-(10+6) then in a loop
for(30-(10+6) times) {
[mainString appendString:#"."]
}
I created this report in iReport Professional 4.5.1 and deployed it to JasperReports Server today. The total page width is 792 pixels. In my report I have some horizontal lines that are 752 pixels wide. When I run the report in JR Server the horizontal lines stretch all the way over to the right side of my monitor. This happens when I schedule the report and ask JR Server to save it as an HTML file, but when I schedule the report and save the output as a PDF the lines are the correct size.
How can I keep the horizontal lines from stretching? The stretch type for each line is set to "no stretch." My other report elements are managing to hold their position.
Thanks,
Lisa
Try using cell borders to draw those lines instead of a static "horizontal lines."
Thanks, Sam! Your answer helped me solve this. My report is a 6-column report and I have labels that I only print in the first column. Cell borders wouldn't work because there would be lots of gaps. However, I realized that my horizontal line did not need to be 752px wide; it only needs to be slightly wider than the width of the first column and the report will take care of copying it into the subsequent columns for me. I set the horizontal lines to 127px wide and now I have an unbroken horizontal line that runs through all of my columns. I can't believe that didn't occur to me when I was creating the report in iReport.
I use iReport to create reports, and I would like to know if there is a way to set the width of "optically grouped fields". They should be set to the minimal size that still displays longest text. I have Static Text on left side and Text Field right of them. This Text Fields are set to the width 150 and alignment to right, but I'd like to set smaller size to wipe out white spaces.
Consider some thing like this
Name: Paul
Surname: Smither
And want automatically to
Name: Paul
Surname: Smither
etc. can be smaller then preset size but no bigger.
Is there a way?? even some component
You cannot change the element width dynamically without using Java frameworks.
The quote from JasperReports Ultimate Guide:
ELEMENT SIZE
The width and height attributes are mandatory and represent the size
of the report element measured in pixels. Other element stretching
settings may instruct the reporting engine to ignore the specified
element height. Even in this case, the attributes remain mandatory
since even when the height is calculated dynamically, the element will
not be smaller than the originally specified height.
You can read this article for better understanding the mechanism of changing the element size.
If it's genuinely just a couple of fields that come from the same row in the dataset, then you could hack something together.
Use a monospace font
Define your maximum field length with a String set to N spaces. For example:
$P{MaxLengthString} default value is 10 spaces: " "
Change your field text from $F{FirstName} to this:
$P{MaxLengthString}.substring(
$P{MaxLengthString}.length() + $F{FirstName}.length() - java.lang.Math.max($F{FirstName}.length(), $F{LastName}.length())
) + $F{FirstName}
That is... er... a bit more complex. And it only works with monospace fonts. And I can't believe I really suggested this. Don't do it. (But it ought to work.)
I have a number of tables in an eclipse SWT application. They are Table/TableViewer tables and consist of a header, a row down the left with text and a series of graphics going across. There are 32 columns other than the text column, numbered from 0 to 31.
On Windows 7 and XP in classic mode, the text is fine, but in XP normal mode, they are truncated so they appear to go 0 1 2 3 4 5 6 7 8 9 1. 1. 1. 1. 1. etc. There is clearly enough room for the text either way.
If I just set the default width to 28 instead of 25, as I found it, they are then fine, but obviously that isn't very good as then I need more room for the interface in Windows 7 and XP Classic, where it was already ok.
I tried getting average width from fontmetrics but the text comes back as 5, in all modes. I can't find any way of either reducing of the padding (which would be the best way), or finding out how much padding there is (which would do). Do I need to draw the column headers manually?
ps: Sorry for the JFace / SWT, have only just started with this and not clear on the differences yet!
Calling TableColumn#pack() should give a column exactly the width it needs to display its content without wasting any space or truncating its content. This includes the column's header text.
You should use the TableLayout for a more dynamic size calculation of your table headers. A good starting point is the following blog article: http://eclipsenuggets.blogspot.com/2007/11/one-of-less-prominent-novelties-in.html