Modification PDF ModuleBuilder

Suite du sujet ModuleBuilder-Generer un PDF depuis l object :

Slt a tous
Je voudrais inserer du texte avec des variables ds mon PDF
mais je galere un peu

pdf_standard_odm.modules.php (59,5 Ko)
Merci de votre aide

O maitres Jedis du PDF
Pourriez vous aider un jeune padawan ds son apprentissage de la force du TCPDF ?
Merci a vous
@Philazerty @Sylvain.Legrand @grandoc

Salut @pm17

Tu peux nous expliquer ce que tu veux faire, ce que tu obtiens et ce qui bloque ?

Merci.

Slt

Je voudrais inserer un texte long avec des variables objects a l interieur
Je sousigné $compagny certifie que $nomclient…

rien ne s affiche

bonne question :wink:

ça veut dire quoi ? page complètement blanche ? erreur 500 ? copie d’écran ?

La variable $object est bien initialisé dans le module ?

Le PDF est bien généré mais mon texte ne s affiche pas

Copie d’écran ou pdf ?

Je vois pas comment ça peut marcher :

	/**
	 * Prints a cell (rectangular area) with optional borders, background color and html text string.
	 * The upper-left corner of the cell corresponds to the current position. After the call, the current position moves to the right or to the next line.<br />
	 * If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.
	 * IMPORTANT: The HTML must be well formatted - try to clean-up it using an application like HTML-Tidy before submitting.
	 * Supported tags are: a, b, blockquote, br, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, img, li, ol, p, pre, small, span, strong, sub, sup, table, tcpdf, td, th, thead, tr, tt, u, ul
	 * NOTE: all the HTML attributes must be enclosed in double-quote.
	 * @param $w (float) Cell width. If 0, the cell extends up to the right margin.
	 * @param $h (float) Cell minimum height. The cell extends automatically if needed.
	 * @param $x (float) upper-left corner X coordinate
	 * @param $y (float) upper-left corner Y coordinate
	 * @param $html (string) html text to print. Default value: empty string.
	 * @param $border (mixed) Indicates if borders must be drawn around the cell. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul> or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
	 * @param $ln (int) Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right (or left for RTL language)</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>
Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.
	 * @param $fill (boolean) Indicates if the cell background must be painted (true) or transparent (false).
	 * @param $reseth (boolean) if true reset the last cell height (default true).
	 * @param $align (string) Allows to center or align the text. Possible values are:<ul><li>L : left align</li><li>C : center</li><li>R : right align</li><li>'' : empty string : left for LTR or right for RTL</li></ul>
	 * @param $autopadding (boolean) if true, uses internal padding and automatically adjust it to account for line width.
	 * @see Multicell(), writeHTML()
	 * @public
	 */
	public function writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true) {

et toi tu l’uitlise :

$pdf->writeHTMLCell(400, 3, 10, 125, $this->text_odm, $tab_top, dol_htmlentitiesbr('BLABLA2'), 0, 1);

Donc

  1. $w (float) Cell width = 400 => C’est en dehors du cadre.
  2. h (float) Cell minimum height => Ok
  3. $x (float) upper-left corner X coordinate = 10 => Donc tout à gauche
  4. $y (float) upper-left corner Y coordinate = 125 => Donc à 125 du haut
  5. $html (string) html text to print. = $this->text_odm => OK
  6. $border (mixed) Indicates if borders must be drawn around the cell = $tab_top => ???
  7. $ln (int) Indicates where the current position should go = dol_htmlentitiesbr(‹ BLABLA2 ›) => ???

ca devrait etre du genre
‹  ›’
$pdf->writeHTMLCell(100, 3, 10, 125, $this->textodm, $border=0, $ln=0, $fill=false, $reseth=true, $align=‹  ›, $autopadding=true);
‹  ›’
ou meme simplement
‹  ›’
$pdf->writeHTMLCell(100, 3, 10, 125, $this->textodm);
‹  ›’
?
mais tjrs rien ds mon pdf :cry:

Salut
Es tu sûr de texodm ?
Si tu essayes avec du texte ça écrit ton texte ?
@+

Effectivement, textodm doit etre définit dans la classe et pas en dehors de la classe.

$this->text_odm = "Objet : ordre de mission

ça doit être aprés ça :

class pdf_standard_odm extends ModelePDFODM

D’ailleurs tu es sur de ça ModelePDFODM ?

Slt et merci a vous deux :grinning:

J ai reussi a faire quelque chose qui s imprime avec des variables de mon object00

Mais j aurais encore besoin d un coup de main(qd on est nul…)
J ai lié avec integer des champs de mon object00 a object01
et je voudrais mettre ces champs sur le pdf generé pour object00

Merci de votre aide

Heu ? Vous pouvez répéter depuis le début ?

Blague a part je ne comprends pas ce que tu veux faire. Afficher les extra de l’autre objet ?
@+

J ai cree un object00
J ai un champ ds mon object00 pour selectionner object01
Je voudrais imprimer sur la fiche pdf de object00 les infos de object01
En esperant etre plus clair

Hola pm17! Como te va? Me gustaria saber como hiciste para imprimir las variables en el PDF, me serviria mucho para realizar lo que estoy haciendo.
Gracias!