1

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

Muhammad Ilyas
  • 45
  • 1
  • 10

3 Answers3

1

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]);
Nicolas Cami
  • 458
  • 1
  • 4
  • 13
1

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

Ruben Pauwels
  • 350
  • 3
  • 13
0

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();
....
  • sir i try this but not working. it will create pages against height parameter – Muhammad Ilyas Apr 23 '18 at 11:45
  • Hi Did you change your question in the meantime? I think it was only the question for the size in the beginning. The problem now should be that you set a really big top margin which is outside of your page ... – Bernd Schuhmacher Apr 24 '18 at 04:57