I want to create a page with 2 independent columns. If the text does not fit in one colum on one page it should be continued on the next page with the same column setup.
I tried using setColumnsArray and selectColumn the problem with this is, that if the first column is full it continues on the next column instead on the next page.
It there a posibility to achive this?
Thank You
See Sample10 which is doing exactly what you are asking for:
PHP Source code: http://www.tcpdf.org/examples/example_010.phps
Final PDF: http://www.tcpdf.org/examples/example_010.pdf
Sample7 might help too but column spreads over multiple pages:
PHP Source code: http://www.tcpdf.org/examples/example_007.phps
Final PDF: http://www.tcpdf.org/examples/example_007.pdf
I solved the problem now without writing everything in html.
I used to following aproache:
Save the top of the columns with getY and getPage.
Write the first column
Use setY and setPage to go back to the top of the second column
Use setX to move the seconds column on the right side.
Using the following hack to get around the problem with different page borders on right and left pages on the second column:
if ($curPage<>$pdf->getPage())
{
$curPage=$pdf->getPage();
if (($curPage % 2)==1)
{
$xPos+=15;
}
else
{
$xPos-=15;
}
}
$pdf->SetX($xPos);
Related
I have a problem with a HTML table generated with a PHP class and saved into a variable.
This variable also contains text, saved before the table, but the table is displayed before the text.
Here's what I do :
Put a text in a variable :
$RET='Awesome introduction';
Generate a table with a class of my own (it's still a simple table) :
$TAB=new class_table();
$TAB::add_th('Column'); // saves 'Column' in a 'th' 3D array
$TAB::close_line(); // $num_tr++
$TAB::add_td('Cell'); // saves 'Cell' in a 'td' 3D array
$TAB::display(); // generate the table
When I do this :
$RET='Awesome introduction';
$RET.=$TAB::display();
echo $RET;
... I've got the table before the text.
When I do this :
echo 'Awesome introduction';
$TAB::display();
... I've got the table after the text, and that's correct.
When I generate my table without the class, it's correct too, of course.
Do you know if it's normal (maybe the class' call is executed in first ?) and if I can workaround this ?
I ask because this code is a just a easy sample, the real one is much complex and called with AJAX (and a console.log proves that the table is generated before the text). I hope I'm clear enough.
Thank you.
Yes, probably Completely normal. This Display class is probably doing exactly that. Displaying, not returning values. You are assigning nothing to the $RET.= , You can prove it by echoing it a second time, it will print your header a second time but not your table. At the time that you assign nothing to RET you output the table, probably with print statements or echo statements in the Display class. There maybe be some way to use the eval function to capture the output of the Display class, but that's above my pay grade. (This would just be a comment, but i haven't earned the privilege.)
How to check if a cell has a bottom border using PHPexcel? I am working on a very funky template the sales force of my company have assembled.
The lines could go on and on inside the "Why?" block so that is why I need to check for that last bottom border to move on in my loop.
Example:
This will check the entire G column until it is empty
NumCells = Range("G" & Rows.Count).End(xlUp).Row +1
If Range("G" & NumCells).Borders(xlEdgeBottom).LineStyle = xlContinuous Then
*Continue with code
I ended up using something like this (didn't really find the bottom border a reliable solution). This will just simply grab the data inside of the following cell ranges (B25:B29):
$objPHPExcel->setActiveSheetIndex($sheetIndex)->rangeToArray('B25:B29');
I am working on two column layout input comes from an editor which has images and text. Images can come as one column or full width. Everything works fine when I insert images in one column. But when I insert image as 2 column it fits perfectly in the column but the text after that is somewhat not aligned.
Text covers the after space correctly but when it goes to second column some space from the top till where the image ends on the first column is blank and starts after that.
if ($this->myResetColumn) {
$this->resetColumns();
$this->setEqualColumns($this->myCols, $this->myWidth);
$this->setXY($this->GetX(), $this->GetY());
$this->selectColumn();
}
$this->writeHTML($content, true, false, true, false, $align);
Second Question
It there a way, I can make few checks while the writeHTML() function is executing or I have to change the function itself, which will not be a good idea to change the source code.
For AddPage, I override it, after the line at the end like this
$this->startPage($orientation, $format, $tocpage);
if (condition) {
// some function call
}
but writeHTML() is a lengthy function to override and it will lose many options it has.
I'm making some pdf document from php code using fpdf library. In that document i have created two cell like this
$pdf->Cell(100,100,"Text inside first column",1,0,'L');
$pdf->Cell(35,35,'Text inside second column ',1,0,'C');
above code works well, out put have two cells, first one has size of 100x100 and second has 35x35 , and second cell was just right to the first cell.
but i need to print that second sell inside the first cell
is there any way in fpdf ?
can anyone help me?
I'm not sure what you want exactly achive, but maybe this AddOn could help you to do this:
http://www.interpid.eu/fpdf-table
Other way would be moving the pointer, something like this:
$pdf->Cell(100,100,"Text inside first column",1,0,'L');
$pdf->SetX($pdf->GetX() - 35);
$pdf->Cell(35,35,'Text inside second column ',1,0,'C');
In Nested cell X-axis and Y-axis, I have achieved like this
`$pdf->Cell(190,20,"",1,0,'L');
$pdf->SetX($pdf->GetX() - 189);
$pdf->Cell(100,10,'First ',2,0,'L');
$pdf->Cell(90,10,'March/2020 ',2,0,'R');
$pdf->SetY($pdf->GetY() +5);
$pdf->Cell(100,10,'MCB,UBl Omni, HBL Konnect, Alfalah , Mobi Cash ',2,0,'L');
$pdf->SetY($pdf->GetY() +5);`enter code here`
$pdf->Cell(139,10,'third text he`enter code here`re ',2,0,'L');
$pdf->Cell(50,10,'Lahore',2,0,'R');`
I have a weird question. I want to create script in javascript (or PHP if I have to, I'm just more comfortable in javascript) that reads through a table until it finds specific text (know how to do that) and then returns the text three cells to the right.
To be specific, I want a script that finds a row for a specific printer on this site and returns the printer's status. I know how to select unique text, but not so much about nonunique text.
Try this
$('.epi-dataTable tr:gt(0) td:first-child:contains("printerName")')
.closest('tr').find('td:eq(4)').text();
var printerName = 'yourname',
status = $(':contains(' + printerName + ')').siblings().eq(2).text();
If I understood your question correctly, this is how you could do it using jQuery:
$("td").filter(function() {
return $(this).text() === yourSeachText;
}).next().next().next().text();
Clarifying: the filter function will select only the column whose text equals your search text, and each call to next will return the column's next sibling - another td. Three calls later, you have the column you want, so you can get its text.
Update: you might also be interested in this question, if the site you're querying is not in the same domain as your script. If it is, you can simply load its contents to a div before querying it:
$("#placeholder").load("http://clusters.andrew.cmu.edu/printerstats/", function() {
// The contents were loaded to #placeholder, do your query here
});
If it's not, then you'll have to load that html data somehow, and according to an anwser to that question, your best route is really to do it in PHP (or at least use it to echo the other site's contents to your own).