post to textfield using tcpdf - php

I am unsure if I am going about this correctly. Why using TCPDF when I attempt to post it returns an empty textfield?
$pdf->Cell(35, 5, 'Job Number ');
$pdf->TextField($_POST["jobnum"], 50, 5);

You need to use the fourth $opt parameter see the TCPDF TextField reference and Acrobat API Reference
$pdf->TextField("jobnum", 50, 5, array(), array('v'=>$_POST["jobnum"] ) );

TCPDF requires the TextField() function to be like so: TextField("string", number, number)
so you need to make it like this:
$pdf->TextField("'".$_POST["jobnum"]."'", 50, 5);

Related

PHP - How to Fill Cell with color from FPDF Function

I have a table generated pdf via fpdf and I needed something that will auto-wrap my cells if I need so I stumbled upon this: https://github.com/gemul/fpdf-multicell-table/blob/master/pdf_mc_table.php
With that, I have the following command for my page header:
function Header(){
$this->SetFont('Arial', 'B', 15);
$this->Cell(100,10,'Otaku Loaning Org', 0 , 1);
$this->Ln(5);
$this->SetWidths(Array(21,30,15,15,27,31,31,));
$this->SetLineHeight(5);
$this->SetFont('Arial', 'B', 12);
$this->SetFillColor(180,180,255);
$this->SetDrawColor(50,50,100);
$this->Row(Array(
'Date',
'Name',
'Trans ID',
'Loan ID',
'Interest Charge',
'Amount Paid',
'Total'
));
}
It currently looks like this:
However, as you can see I prepared a line of code for the Cells to be filled with a color. I would appreciate if someone could provide some insights because I tried adding a seventh parameter to line 60 and set it as true but to no avail. Thank you!

How to set custom page size in fpdf php library?

I need some help with fPDF. I want to set up my custom page size (exactly: width 3 inch, and height 5 or 6 inch).
it will create number of pages again height parameter .
i set the size array(3,5). it will create 5 page. I
found fPDF() manual (http://www.fpdf.org/) but there are only ready formats like A4, B5 etc. I have to set up my own page format.
<?php
require_once('fpdf/fpdf.php');
//$fromat = array(3,5);
$pdf = new FPDF('p','in', [4.1,2.9]);
$pdf->SetTopMargin(50);
$pdf->Addpage();
$pdf->SetTitle("invoice");
$pdf->SetCreator("maqbool solutons");
$pdf->SetAuthor("my name");
$pdf->SetSubject("report");
$pdf->SetFont('Arial', 'B', '16');
$pdf->SetTextColor(155,14,9);// rgb
$pdf->SetDrawColor(155,14,9);
$pdf->SetfillColor(15,140,95);
$pdf->Cell(60,10, 'hello word');
$pdf->Cell(60,10,'powered by fpdf', 1, 0,'c',true);
$pdf->Cell(60,10,'powered by fpdf', 1, 2,'c');
$pdf->Cell(60,10,'powered by fpdf', 1, 1,'c');
$pdf->Image("images/coat.jpg", 10,20,10,35);
$pdf->MultiCell(94,10,"skldjfsldfsfjsdkfsjdlfjsdflkjsdflksjflksjdflskjfslkjfdslkfdjslkfdjslkfjslkfjslkfjsflkjsflkjsflksjflksjfslkjfslkjslkf",1,"L",false);
$pdf->Output("I", "invice.pdf");
?>[that is my file size][1]
when i add array of size
You should should define it in your constructor like so:
$pdf = new FPDF('P','in',[3,6]);
You can find more info in tutorial #1 and in the manual > AddPage
As said in the documentation, when you call the constructor or AddPage, you can either give a String or an Array containing the width and height:
// AddPage([string orientation [, mixed size [, int rotation]]])
$pdf->AddPage("P", [3, 5]); // assuming you are using 'in' as unit
Or directly using the constructor:
// __construct([string orientation [, string unit [, mixed size]]])
$pdf = new FPDF('P','in',[3, 5]);
I think you can set the page size with the constructor.
I have not tested it but this should show you the way:
$format=array(3,5);
$pdf=new FPDF('P','in',$format);
$pdf->Open();
....

How to add AliasNbPages to MultiCell

To display how many pages are in this pdf you can actually use
$pdf->AliasNbPages('{customNb}');
$pdf->Cell(0, 10, 'Page '.$this->PageNo().'/{customNb}', 0, 0, 'C');
This should print something like e.g.
Page 1/5
What if i'm using a MultiCell, how can I use AliasNbPages there ?
$pdf->MultiCell(34, 5, 'Page '.$pdf->PageNo() . '/{customNb}');
This returns
Page 1/{customNb}
I tried to pass it like sample above, also as a part of a variable
$foo = 'Page '.$pdf->PageNo() . '/{customNb}';
$pdf->MultiCell(34, 5, $foo);
But this all is not working as expacted. Is there an other way to solve this ???
Ok, I guess I found a solution....
obviously there is a problem using custom name for pageiterator.
If I simply call
$pdf->AliasNbPages();
and than use
$pdf->MultiCell(34, 5, 'Page '.$pdf->PageNo() . '/{nb}');
everything works like expacted.

Limit Laravel 5 pagination links

I have pagination with links [1, 2, 3, 4, 5, 6, 7, 8 ... 99, 100] and how can I change limit to display [1, 2, 3, ... 98, 99, 100] ? I have custom paginator class, but I can't find this limit to override in my new class.
By checking the classes I found that you have to override the presenter used by the Paginator.
Its done by calling render($presenter) your presenter must extend BootstrapThreePresenter If you wish to use bootstrap links and you just have to override the constructor and pass number of links you want on each side $this->window = UrlWindow::make($numberOfLinksEachSide)
These are just instructions you'll have to look by yourself, I'm sorry for not being able to provide complete code, I'm on phone.
Please let me know if this worked.
This is my solution to the same problems... In LengthAwarePaginator updated function links:
public function links($view = null, $data = [], $onEachSide = 3)
{
if(!$data){
$data = [];
}
$this->onEachSide = $onEachSide;
return $this->render($view, $data);
}
And in URLWindow function make:
public static function make(PaginatorContract $paginator)
{
return (new static($paginator))->get($paginator->onEachSide);
}
This removes the parameter $onEachSide from function make - which is never passed in anywhere - and allows it to be passed to function links as a parameter.
To use this you need to call this links method like this:
{{ $collection->links('view-to-use'|null, $dataArray|null, 2)}}
Where 2 is the number on each side.
You can do this easily by changing some core fields (although not recommended to change core files).
Find- vendor/laravel/framework/src/Illuminate/Pagination and go to UrlWindow. On this page find some parameters like- $onEachSide, $window. Change and play with these.

Google scatter chart for two arrays

Hello People here is my Google scattered chart code what I am using:
require '/lib/GoogleChart.php';
require '/lib/markers/GoogleChartShapeMarker.php';
require '/lib/markers/GoogleChartTextMarker.php';
$Variance=array();
$Emp_RecFactor=array();
$Emp_Id=array();
//$Emp_FirstName=array();
$EquityGraph=new EquityGraph();
$EquityGraph->Graph();
$DrawGraph=$EquityGraph->DrawGraph;
foreach($DrawGraph as $key=>$value)
{
$Variance[]=$value["Variance"];//for multiple values ,array
$Emp_RecFactor[]=$value["Emp_RecFactor"];//single value
$Emp_Id[]=$value["Emp_Id"];//single value
}
$_GET['Variance']=$Variance;
$_GET['Emp_RecFactor']=$Emp_RecFactor;
print_r($Emp_RecFactor);
$chart = new GoogleChart('lc', 500, 200);
// manually forcing the scale to [0,100]
$chart->setScale(0,100);
// add one line
$data = new GoogleChartData($Variance);
$chart->addData($data);
// customize y axis
$y_axis = new GoogleChartAxis('y');
$y_axis->setDrawTickMarks(false)->setLabels(array(-5,0,5));
$chart->addAxis($y_axis);
// customize x axis
$x_axis = new GoogleChartAxis('x');
$x_axis->setTickMarks(5);
$chart->addAxis($x_axis);
// add a shape marker with a border
$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
$shape_marker->setSize(6);
$shape_marker->setBorder(2);
$shape_marker->setData($data);
$chart->addMarker($shape_marker);
// add a value marker
$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
$value_marker->setData($data);
$chart->addMarker($value_marker);
//~ header('Content-Type: image/png');
echo $chart->toHtml();
As you can see in the code I have used $Variance array passing to $data now I need to use one more array $Emp_RecFactor and I need to draw a graph between those two...
I also want to add mouse over feature to this so that if someone hovers over the selected point it should display different things for different selected points -how do I do that?
To draw a Google scattered chart between two arrays you have to use code as below
var data = google.visualization.arrayToDataTable([
['Age', 'Array1', 'Array2'],
[8, 12, 15],
[4, 5.5, 0],
[11, 0, 14],
[4, 9, 5],
[3, 3.5, 9],
[6.5, 7, 13]
]);
And it has a default tooltip to show the data while hovering the selected point. We can also customize Tooltip content by using html tags.
To view a working sample for this go to the site jqfaq.com(Sample) and a customization of Tooltip content go to the site jqfaq.com(customizing Tooltip)

Categories