FPDF align values on right - fpdf

I am using FPDF to generate a report, and i need to align the number on right taking the number on top(Year) by reference.
But I am having a problem on this align.
If i use a function Cell like this:
$pdf->Cell(0,5,$alue,'B',1,'D');
All values stay on right Overlapping.
I tried to use a function SetX but did not changed anything.
how it is now

Take a look at the documentation. It states that:
Cell width. If 0, the cell extends up to the right margin.
Since you're right-aligning your text and your Cell sits on the right margin of the page, it makes sense that it does not align properly.
Try specifying a width for your cell. For example, replace your example line of code with:
$pdf->Cell(50,5,$alue,'B',1,'D');

<?php
//right align
$pdf->Cell(50, 5, $alue, 0, 0, 'R' );
//Left Align
$pdf->Cell(50, 5, $alue, 0, 0, 'L' );
//Center Align
$pdf->Cell(50, 5, $alue, 0, 0, 'C' );
?>

Related

Ag-grid column grouping resize issue

In my developed grid with column grouping, there is white empty space is appear at end when resize the columns. Any Suggestion?[![enter image description here][1]][1]
You can call sizeColumnsToFit() after columnRowGroupChanged event:
columnRowGroupChanged A row group column was added or removed.
.html template event binding
(columnRowGroupChanged)="groupChanged($event)"
or .ts gridOptions event binding (don't forget to define [gridOptions] in .html)
this.gridOptions:{
onColumnRowGroupChanged : this.groupChanged.bind(this)
}
handling
groupChanged(params){
params.api.sizeColumnsToFit();
}
DEMO
Starting from ag-grid 23.1.0, we no longer have to use sizeColumnsToFit. Instead, in column definition, add flex: 1 to the last visible column.
This prevents all annoying jumps and weird grid behavior when resizing columns. In case user enlarge the column, horizontal scrollbar will appear, which is the expected behavior.
Please go over your code and change sizeColumnsToFit to the flex solution.
Flex also gives you control over relative column sizes, you can read more about it in the docs: https://www.ag-grid.com/javascript-grid-resizing/.
Example:
columnDefs = [{...}
...
{
headerName: 'HeaderA',
field: 'name',
...
flex: 1, // Adding this to last column definition
}]

Auto Size all columns to fit content

All my searches turned up for sizeColumnsToFit and autoSizeColumns which is not what I want.
My grids have many columns, so it scroll horizontal which is fine
But I cannot know in advance what would be the most space needed for the widest text in a column, so want the grid to auto size all columns to accommodate for whatever is the longest line of text in the cell.
Can one do that? (pretty much like have nowrap on a html table column, not that ag-grid wrap text, it just hide what is too long)
Grid Resizing:
https://www.ag-grid.com/javascript-grid-resizing/
sizeColumnsToFit - this tries to squeeze all the columns in the view - no horizontal scrolling
autoSizeAllColumns - this tries to size all columns to to fit the data - horizontal scrolling
// If you need to resize specific columns
var allColIds = params.columnApi.getAllColumns()
.map(column => column.colId);
params.columnApi.autoSizeColumns(allColIds);
// If you want to resize all columns
params.columnApi.autoSizeAllColumns();
I passed through this and it took me some time to make it work the way I wanted to, by that I mean :
Use all the available space
Make each column take the width required to display its content correctly
Solution :
Add the width parameter for each column (requires some manual tuning to set the right values)
Call gridApi.sizeColumnsToFit() in the onGridReady which will resize to take the available space while making sure that columns having bigger width will take more space
const gridOptions = {
...
columnDefs: [
{
...,
width: 100
},
{
...,
width: 50
},
...
],
...
onGridReady: (event) => event.api.sizeColumnsToFit();
};
Simply use flex instead of width in the column definitions. The grid will adjust automatically.
You can find a complete example for auto resizing all column.
column-sizing
Simply call autoSizeColumns() function, all columns will be resized according to content.
gridColumnApi.autoSizeColumns(allColumnIds, skipHeader);

How to use the full width when an UI element is invisible in iphone?

I have a label and a button like in the above picture. I like the label to use full width when I click on hide button.
I tried setting the width to 0, how ever it does not change the label with. Is this correct? or is there a better way to do this ?
blockingButton.frame = CGRectMake(blockingButton.frame.origin.x, blockingButton.frame.origin.y, 0, blockingButton.frame.height)
No, 0 can cause problems.
Try this:
blockingButton.frame = CGRectMake(blockingButton.frame.origin.x, blockingButton.frame.origin.y, self.view.frame.size.width, blockingButton.frame.height)

Get the size of wrapped text in Label

If I create a Label in a 500x500 area with wordwrap, how can I find out the height of the wrapped text ? I'm looking for the yellow height, not the salmon height.
Answer of #idrise doesn't work for system font And here I give a more flexible answer.
Assume we want to create a text/label which has a fixed width, but dynamic height according to text's length. for that you can use below code:
Label *lbl = Label::createWithSystemFont("aaa aaa aaa aaa aaa aaa", "Arial", 50);
lbl->setDimensions(FIXED_WIDTH, 0); // "0" means we don't care about wrapping vertically, hence `getContentSize().height` give a dynamic height according to text's length
////
auto dynamicHeight = title->getContentSize().height; // According to text's length :)
And obviously for fixed height you can do similarly.
Hope Help someone :]
This may seem a little counter intuitive.
First you set the dimensions with an excessively large height.
Calling getLineHeight and getStringNumLines will calculate the height based on the width passed.
You send the width and height back to setDimensions.
Now your labels getContentSize() will return the actual size of the text.
IE
label->setDimensions(width, 2000);
label->setDimensions(width,label->getStringNumLines() *
ceil(label->getLineHeight()));
They added the functionality you want:
Added three overflow type to new label: CLAMP, SHRINK, RESIZE_HEIGHT.
Overflow type is used to control label overflow result, In SHRINK mode, the font size will change dynamically to adapt the content size. In CLAMP mode, when label content goes out of the bounding box, it will be clipped, In RESIZE_HEIGHT mode, you can only change the width of label and the height is changed automatically. For example:
//Change the label's Overflow type
label->setOverflow(Label::Overflow::RESIZE_HEIGHT);
mTexto=Label::createWithTTF(mTextoHelp.c_str(),CCGetFont(), 30);
mTexto->setHeight(100.f);
mTexto->setOverflow(Label::Overflow::RESIZE_HEIGHT);
mTexto->setDimensions(mSize.width*0.8f, 0.f);

LWUIT Form.show() has a weird margin (or padding)

When i add a Form to LWUIT using form.show(), the form is not set exactly in the (0,0) coordinate, it's leaving like 20 pixels in the top and 3 on the left.
I'm developing for the Nokia SDK 1.1 FYI and i'm using their version of LWUIT
Let me know if there is a workaround on this.
Cheers!
Alberto
EDIT:
Here is how i'm creating the Form
Display.init(this);
this.view = new Form();
this.view.setLayout(new CoordinateLayout(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()));
this.view.setScrollableY(false);
this.view.show();
This shows a padding on the top and on the left side (Bigger on the top than on the left side)
See a screen shot:
Found the 2 Issues:
1) I had to set the titleArea padding and margins to 0 like this:
this.view.getTitleArea().getStyle().setMargin(0, 0, 0, 0);
this.view.getTitleArea().getStyle().setPadding(0, 0, 0, 0);
this.view.revalidate();
2) For the left padding, it was in the label where i was placing the photo, so just changing it's style (padding) to 0 made the trick
Cheers,