sdglhm / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

Page header #341

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Adding headers and footer in standard way
2. Check, if page 1 then dont print header and footer.
3.

What is the expected output? What do you see instead?
Should print on all pages, except for first page

What version of the product are you using? On what operating system?
0.5

Please provide any additional information below.

  $pgno = "{PAGE_NUM}";
  //$pgno = $pgno++;

    if ($pgno=="1")
    {
      $pdf->page_text(12, 100, $pgno." Annex for GGN <?=$lic_rs['ProjectGGN_VC']?>", $font, 8, array(0,0,0));
    }
    else
    {
        $pdf->page_text(12, 100, "else pg: "."{PAGE_NUM}"." ".(int)($pgno)."<?=$rs['ProjectGGN_VC']?>", $font, 12, array(0,0,0));
    }

It always hits else section.

Original issue reported on code.google.com by patil.sh...@gmail.com on 18 Aug 2011 at 11:46

GoogleCodeExporter commented 9 years ago
The {PAGE_NUM} placeholder isn't available for use in general scripting. The 
only time it comes into play is after the document has been rendered as part of 
the $pdf->page_text() method.

What you would want to use to determine the current page is 
$pdf->get_page_number(). But this doesn't work as expected in 0.5.1 so you'll 
need to update to 0.6.0 to use it.

Original comment by eclecticgeek on 18 Aug 2011 at 5:47

GoogleCodeExporter commented 9 years ago
I update dompdf to v0.6.0. Still the same
$pdf->get_page_number() always returns Page 1
so, again i cannot do the comparison as stated above.

Thanks

Original comment by patil.sh...@gmail.com on 19 Aug 2011 at 7:22

GoogleCodeExporter commented 9 years ago
$dompdf->page_text() is rendered after the document is complete and applied to 
all pages in the document. The text supplied to this method is additive, i.e. 
if you call the method a second time both text strings will be added to the 
document. So what you are probably seeing is the result of the second text 
overlaying the first. They would both be there and if you zoom in close enough 
you may be able to tell.

If you just want to apply text the the current page use $pdf->text(). If you 
want to apply text to the current page and all following page you should create 
an object, add your text to the object, and then add the object to the 
document. There a sample of this in the wiki FAQ:
http://code.google.com/p/dompdf/wiki/FAQ

Here is a sample render showing that it does work as expected in 0.6.0 beta 2:
http://eclecticgeek.com/dompdf/debug.php?identifier=1c231d2e4588ee24dcb3a433ec65
3519

Original comment by eclecticgeek on 19 Aug 2011 at 6:52

GoogleCodeExporter commented 9 years ago
Hi Friend
thanks for all your help.
It work the way you suggested.
I dont know, how many pages are gonna span my report.
So, ideally adding it on all blocks is not possible for me.
You understood my requirement correctly. But unfortunately this do not work for 
me.
I have attached the file i modified on your sample.
If you look at test2.pdf, you find, there is no change in page number.
how can i get real page number and do some formatting task.

Again thanks for your help.

Original comment by patil.sh...@gmail.com on 20 Aug 2011 at 6:49

Attachments:

GoogleCodeExporter commented 9 years ago
What you're trying to do might be difficult right now. The only way to have the 
page number be accurate for the current page is to use the page_text() method. 
I neglected to note that the text() method does not update, so whatever text 
you pass to it will be used on all pages.

I've gotten around the issue in the past by placing a white rectangle over text 
on the first page. This seems to work well enough, though it certainly is not 
ideal.

Do you have a sample of what you want to achieve in your document. You can do 
all sorts of formatting using inline script, but it may be easier to use 
fixed-position HTML elements. It is possible to get the page number using CSS. 
See here:
http://eclecticgeek.com/dompdf/debug.php?identifier=0a7d41de94ff9f9c551bab5b22d3
ee69

Original comment by eclecticgeek on 22 Aug 2011 at 5:23

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 30 May 2013 at 5:16