1

Hi.
First of all, many Thanks to Spipu for this awesome class.
The version of the script is 3.26 (sorry, i did'nt write it in the subject)
Please, How can i change the HTML in page_header? I tried with a variable within the file containing the header , and the HTML output is always the first value taked by this variable.
i already read the wiki, but i found no answer.

Thanks!!

2

you mean that you want to have specific headers on each page ?

Ancien pseudo : lolo

3

Yes. It's almost the same, only changes one word.
Can i control the output of the header when an automatic page break it's triggered?

I know i can control the output on each page break with <thead>, but i have to generate the HTML code according with the designer's model. And the text of the section is out of the data table.
Sorry about my poor english.

4

you can use a tag like [[PARAM_PAGE]]. and after juste remplace it by the value that you want, in each page :

foreach($html2pdf->pdf->pages as &$page)
{
  $page = str_replace('[[PARAM_PAGE]]', ..., $page)
}
Ancien pseudo : lolo

5

Ok, thanks. Seems good, but there's a problem.

I don't know what value goes in each page, because the lenght of the data tables it's not always the same. So, the only way i can imagine is create an array (page_number, value) while creating tables, and after create $html2pdf, do the foreach to changes the values.

But, how can i know wich page is current, if $html2pdf it's not created yet? i'm confused.

Thank you so much for your patience.

6

ibute : <span save_value="value to save">your texte</span>1 : put your value in a span with a specific atttr
2 : modify the o_SPAN method by adding what folows :
if (isset($param['save_value']) && !$this->sub_part && !$this->isSubPart) 
{ 
  global $SAVE_VALUES;
  $SAVE_VALUE[$this->pdf->page][] = $param['save_value'];
}


then, you can use the array $SAVE_VALUES ...
Ancien pseudo : lolo

7

1. put the tag [[MAIN_TITLE]] in your page_header. don't use the real title.
2. in your html, when you want to save the next title, do this :
<span next_title="my title here">your texte</span>
3. in the o_SPAN method, add the follows :
if (isset($param['next_title']) && !$this->sub_part && !$this->isSubPart)  
{  
  global $PAGE_TITLE; 
  $p = $this->pdf->page;
  if (!isset($PAGE_TITLE[0])) $PAGE_TITLE[0] = $param['next_title']; // because we need at least the first title as main title
  $PAGE_TITLE[$p+1] = $param['next_title']; 
}

4. after converted the html in pdf with writeHTML, add this :
$title = $PAGE_TITLE[0];
foreach($html2pdf->pdf->pages as $k => &$page) 
{
  if (isset($PAGE_TITLE[$k])) $title = $PAGE_TITLE[$k];
  $page = str_replace('[[MAIN_TITLE]]', $title, $page)
}
Ancien pseudo : lolo

8

and thx a lot for your donation smile
Ancien pseudo : lolo

9

Thanks! i have an error (Cannot access empty property in line foreach($html2pdf->pdf->pages as $k -> $page)
here´s the code:
<?	$content = ob_get_clean();
//echo $content;
	require_once('html2pdf/html2pdf.class.php');
	$html2pdf = new HTML2PDF('P','A4', 'es', array(mL, mT, mR, mB));
	$html2pdf->pdf->SetDisplayMode('fullpage');
	$html2pdf->WriteHTML($content);
	$title = $PAGE_TITLE[0]; 
	foreach($html2pdf->pdf->pages as $k -> $page)  
	{ 
	  if (isset($PAGE_TITLE[$k])) $title = $PAGE_TITLE[$k]; 
	  $page = str_replace('[[MAIN_TITLE]]', $title, $page); 
	}
	$html2pdf->Output('carta.pdf');
?>

Your patience it's something supernatural. Thanks a lot!!

10

the good line is :

foreach($html2pdf->pdf->pages as $k => &$page)
Ancien pseudo : lolo

11

P-E-R-F-E-C-T!!!!!
too many hours in front of the same code do things like this: you can't see the evidence. :-P

Thank you sooo much.

12

Thank you for this post. I believe it is what I am looking for (My main goal is to edit headers after the first page without knowing how many pages are needed beforehand.) except I get an error on the foreach line when I try to run code similar to the code in post 8:
$html2pdf = new HTML2PDF('P','A4','en');
$html2pdf->WriteHTML($content);

foreach($html2pdf->pdf->pages as $k => &$page)
{
}

Cannot access protected property MyPDF::$pages in ...


There is something wrong with getting the values from the class... My PDFs are printing fine before I tried adding this. If I edit my html2pdf.class.php file I see that "page" variable is "protected." If I change this to "public" it runs, but I'm not sure if this is the correct solution. Is this a bug in HTML2PDF or something in my php configuration? What do you recommend? Or is there a completely better way to get the header to only show on the first page? (I can make a new topic) Thanks.

13

*bump*

Anyone? What should I do to get the header only show on the first page when there are automatic page breaks?

14

Bonjour!

J'ai un problème similaire et la solution proposée me semblait parfaite !
.. mais la dernière version (html2pdf_v4.03_php5) ne semble plus fonctionner comment avant et donc la solution proposée ne fonctionne plus !!

Moi je dois générer un petit dictionnaire
et, sur chaque page, je dois ajouter avant la liste des mots : la plage de 3 premières lettres des mots affichés :
.. par exemple : "AGN - ATT", si ma page affiche des mots de "agneau" à "attraction"

Mon souci c'est que pour connaitre cette "plage de 3 premières lettres des mots affichés",
.. on doit attendre de savoir quand le saut de page intervient !
.. et alors changer ce texte (qui est donc déjà traité)
.. donc je ne vois pas d'autre solution que de passer par une copie de l'objet "MyPDF", mais ça commence à dépasser mes compétences de programmation !!

Avez-vous des idées ?

Merci d'avance,
Yann
Yann

15

Ah si ça marche ! (même avec la dernière version)
C'était dû à un petit oubli de ma part ! (de mettre le [[MAIN_TITLE]] dans la page : je l'avais mis en commentaire HTML)

Bref je vais essayé de trouver une solution à ma problématique avec cela !

Pourquoi je poste quand même sur ce forum :
.. car je pense qu'entre nous développeur on peut s'y aider
.. même si le développeur du module n'y est plus !

Yann
Yann

16

Une dernière chose...

Bon, j'ai réussi à récupérer/calculer cette "plage des 3 premières lettres des mots affichés" pour chaque page,
puis à les remplacer dans l’entête du PDF avec la méthode donnée ici (voir le post : 21:42 par Spipu - Posted : 07-12-2009).

Mais reste un gros souci : le remplacement ne se fait que si c'est du "texte pur" que je remplace !!
.. il ne s'effectue pas lorsque j'ai un style appliqué à mon texte : par exemple avec : <div class="letter_range">[[letter_range]]</div>
.. je ne comprend pas pourquoi : des idées ?

Merci d'avance,
Yann
Yann