PDF_begin_page

(PHP 4, PECL pdflib >= 1.0.0)

PDF_begin_pageStart new page [deprecated]

Description

bool PDF_begin_page ( resource $pdfdoc , float $width , float $height )

Adds a new page to the document. Returns TRUE on success or FALSE on failure.

This function is deprecated since PDFlib version 6, use PDF_begin_page_ext() instead.

Коментарии

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($pdf8.5 7211 72);
.
/* set up $helvetica as font */
.
 
pdf_set_font($pdf$helvetica9);
 
$leading pdf_get_value($pdf'leading');
 
pdf_show_boxed($pdf0.5 720.5 724.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
2005-03-30 16:12:50
http://php5.kiev.ua/manual/ru/function.pdf-begin-page.html
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>|| $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";
?>
2005-05-28 16:47:53
http://php5.kiev.ua/manual/ru/function.pdf-begin-page.html
Try this...

<?

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

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

// ...

?>
2005-07-07 00:47:41
http://php5.kiev.ua/manual/ru/function.pdf-begin-page.html
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).
2005-08-19 19:53:38
http://php5.kiev.ua/manual/ru/function.pdf-begin-page.html

    Поддержать сайт на родительском проекте КГБ