Re: helppppppppppp in pdf generation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



to be honest,, there are no simple script. specially pdf format is
page oriented and web is flat(single page). that's why when flat data
divided into pages there are a huge possibilities of some contents
break horizontally and be in two subsequent pdf pages.

so far i remember dompdf and fpdf are two pdf generator from php. and
fpdf is better then dom.

i am sure you will get both examples using google search easily. here
is my working example what might help you:

		define("FPDF_FONTPATH", "../fpdf/font/");

		$pdf=new FPDF("P","mm","custom");

		// [CONFIGURATION VARIABLES]
		$per_page = 8;	//number of results per page
		$columns = 2;
		$row_per_cell = 5; //currently we have only label_text
		$column_space = 5;	//Space between columns
		$cell_width = 101.6; //Original 66.7+1.55; cell width(for all cell)
		$single_cell_height = 34;		//Original 5.08; cell height(for all cell)
		$top_margin = 22.35; //top margin default: 1,27cm / 12.7 22.35=0.88 inc
		$left_margin = 15.25;	//Left margin (for all) default:4.8
		
		//TOTAL FROM SQL
		$tot = count($Labels);		////$tot = 60;
		$counter=0;
		
		//CALCULATES HOW MANY PAGES WILL BE NECESSARY
		$pages = ceil($tot/$per_page);
		$lines = ceil($per_page/$columns);
		
		
		//START VARS
		$actual_line = 0;
		$beginning = 0;
		$cell_complete =0;	//Added by Sumon
		
		for($x=1; $x<=$pages; $x++) 	//PAGES
		{
			//VERIFY
			$beginning = $actual_line;
			$end = $actual_line + $per_page;
			if($end > $tot) $end = $tot;
			
			//CONFIG VARIABLES
			$y = $top_margin; //top margin default: 1,27cm / 12.7 22.35=0.88 inc
			$x_cor = $left_margin; //Left margin (for all) default:4.8
			$cell_height = $single_cell_height/$row_per_cell; //As though later
$row_per_cell multiplied.
			
			$pdf->AddPage();
			$pdf->SetFont('Times','',10);
			
			for($l=0;$l<$lines;$l++) //makes 7 lines
			{

				$x_pos = $x_cor;
				for($k=1;$k<=$columns;$k++)	//make $columns columns
				{
					if($counter>=$tot) break;
					$LabelInfo=$Labels[$counter++];
					$pdf->SetXY($x_pos,$y);
					$pdf->MultiCell($cell_width, $cell_height ,
$LabelInfo['details']."\n".$LabelInfo['appartment']."\n".$LabelInfo['city']."\n".$LabelInfo['province']."\n".$LabelInfo['zip_code'],
1,'C');
					$x_pos = $x_pos+$cell_width+$column_space;
				}
				
				$y=$y+$cell_height*$row_per_cell; //adds label actual position.
				$pdf->SetAutoPageBreak('on','12.7');
			}
			$actual_line++;
			
		}//CLOSES FOR(PAGES - x)
		$pdf->Output("pdf_files/output.pdf","F");

On 9/20/09, Uzair <uzair05csmehran@xxxxxxxxxxx> wrote:
> I want to create the pdf of current opened page using button .
> Means whenever user click on button it create its pdf version .any simple
> script kindly share.
>
>


-- 
Md. Aminul Islam
http://www.shopno-dinga.com
Mob: 8801671670797

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux