pdf_begin_page

(PHP 3 >= 3.0.6, PHP 4, PECL)

pdf_begin_page -- Starts new page

Description

bool pdf_begin_page ( resource pdfdoc, float width, float height )

Add a new page to the document. 如果成功则返回 TRUE,失败则返回 FALSE。 The width and height are specified in points, which are 1/72 of an inch.

表格 1. Common Page Sizes in Points

namesize
A023803368
A116842380
A211901684
A38421190
A4595842
A5421595
A6297421
B5501709
letter (8.5"11")612792
legal (8.5"14")6121008
ledger (17"11")1224792
11"17"7921224

See also pdf_end_page().


add a note add a note User Contributed Notes
rz at daimi dot au dot dk
20-Aug-2005 07:53
The problem is that A4 is *NOT* exactly 210mm*297mm.
(Further more, the 2.835016835017 is incorrect. You convert from mm to pps by dividing by 25.4 and multiplying by 72. Hence the ratio is 2.83464566929133858267).
The code that I posted in may produces correct sizes.
(Except for the "m65" format, sorry. "m65" is the same as "dl", and should return the same values).
d dot schneider at 24you dot de
07-Jul-2005 12:47
Try this...

<?

function mm2pt($val){
   return
floatval($val * 2.835016835017);
   }

$xpdf = pdf_new();
pdf_open_file($xpdf);
pdf_begin_page($xpdf, mm2pt(210), mm2pt(297));

// ...

?>
rz at daimi dot au dot dk
29-May-2005 04:47
The DIN paper sizes below are rounded.
Theese functions returns exact paper sizes:

<?php
function paperheight($papername) {
 
$name=strtolower($papername);
  switch(
$name) {
  case
"dl": return 11/2.54*72;
  case
"m65": return paperheight("c6");
  case
"ledger": case "tabloid": return  17*72;
  case
"legal": return paperwidth("ledger");
  case
"letter": return 11*72;
  default: return
paperwidth($name)*sqrt(2);
  }
}
function
paperwidth($papername) {
 
$name=strtolower($papername);
  switch(
$name) {
  case
"dl": return 22/2.54*72;
  case
"m65": return paperwidth("c5");
  case
"ledger": case "tabloid": return  14*72;
  case
"legal": case "letter": return paperheight("ledger")>>1;
  default:
  
$i=strpos("ebca",$name{0});
  
$j=substr($name,1);
   if(
$i!=false && ($j>0 || $j==="0"))
     return
100/(pow(2,($i+$j*4-1)/8))/2.54*72;
   else
     die(
"Unkown paper format: $papername");
  }
}

$paper = "A4";
$w = paperwidth($paper);
$h = paperheight($paper);
echo
"$paper: $w ppt * $h ppt";
?>
ceo at l-i-e dot com
31-Mar-2005 05:12
I spent a lot of hours tweaking numbers in my PDF source, trying to nudge things the right way, and, invariably, really messing up big-time...

Then one day I realized that all these numbers were supposed to be (INCHES * 72).

Now my PDF code looks more like:
<?php
.
.
.
 
pdf_begin_page($pdf, 8.5 * 72, 11 * 72);
.
/* set up $helvetica as font */
.
 
pdf_set_font($pdf, $helvetica, 9);
 
$leading = pdf_get_value($pdf, 'leading');
 
pdf_show_boxed($pdf, 0.5 * 72, 0.5 * 72, 4.0 * 72, $leading, 'left', '');
?>

0.0, 0.0 is at the bottom left.
8.5 * 72, 11 * 72 is at the top right.
Everything in between is in x.xx * 72 where x.xx is INCHES.

Suddenly, I can visualize the PDF while I'm typing.

Might work for you too.

Sample linked from:
http://l-i-e.com/resume.htm
psychosos at gmx dot at
13-Apr-2003 08:36
Points for CD covers (approximate values)

Front cover          (119x119mm)  => 337.33x337.33 points
Inlay including sides (150x117mm)  => 425.21x331.66 points
Inlay excluding sides (137.4x117mm) => 389.49x331.66 points
ronald at upperground dot nl
20-Feb-2003 12:55
When you use the mentioned size of an a4 pdf file it will make a pdf file in the this size: 209.9 x 297 mm. If you want to create a real a4 sized pdf you can use the following:

PDF_begin_page($pdf, 595.3, 842);

Its a small step i know... but its just the last mm.
f dot enzenhofer at apa dot at
15-Jan-2003 12:36
format  width    height
A0        2380      3368
A1        1684        2380
A2        1190      1684
A3          842      1190
A4          595      842
A5          421      595
A6          297        421

B5          501      709

letter        612      792
legal        612    1008
ledger      1224      792

11x17        792    1224