Generate Wallet with TCPDF PHP Class

Asked

Viewed 110 times

0

I’m trying to generate small cards using PHP’s TCPDF library, according to a list.

The front page is perfect.

However, when I try to create more than 1 page, it gets lost on the second page.

// add a page
$pdf->AddPage();

// set JPEG quality
$pdf->setJPEGQuality(150);

//Alinhamento Imagem de fundo
$x = 30;
$y = 35;

$hori_nome = 41; // vai para os lados
$vert_nome =53.6; // vai para baixo ou cima
$hori_nasci = 49; // vai para os lados
$vert_nasci =63.7; // vai para baixo ou cima
$hori_turno = 60; // vai para os lados
$vert_turno =76.3; // vai para baixo ou cima
$hori_mat = 45; // vai para os lados
$vert_mat =82.3; // vai para baixo ou cima

$fotox = 91.5;
$fotoy = 37;
$fotow = 40;
$fotoh = 30;
$guarda=0;

for ($i = 1; $i <= 7; ++$i) {
    $pdf->Image('images/image_demo.jpg', $x, $y, $w, $h, 'JPG', '', '', false, 300, '', false, false, 0, 0, false, false);
    $pdf->Text($hori_nome, $vert_nome, 'Maicon Eduardo');
    $pdf->Text($hori_nasci, $vert_nasci, '06/05/1993');
    $pdf->Text($hori_turno, $vert_turno, 'Tarde');
    $pdf->Text($hori_mat, $vert_mat, '123456');
    $pdf->Image('foto_3x4.jpg', $fotox, $fotoy, $fotow, $fotoh, 'JPG', '', '', false, 300, '', false, false, 0, 0, false, false);

    $y += 60; // new row

    $guarda += 60;
    $vert_nome += 60;
    $vert_nasci += 60;
    $vert_turno += 60;
    $vert_mat += 60;
    $fotoy += 60;
}

On each page fit 4 small desks.

  • Have you tried using the $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); performing a for to create all at once, rather than creating page by page?

  • I tried and it still didn’t work.

  • $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 009', PDF_HEADER_STRING);&#xA;&#xA;$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));&#xA;$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));&#xA;&#xA;$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);&#xA;&#xA;&#xA;$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);&#xA;$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);&#xA;$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);&#xA;&#xA;&#xA;$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

  • You could not make a counter for these little desktops and when you get in 4 it gives a $pdf->Addpage() ?

  • By the time he gets to four, he’s already created the page himself. The problem is that it loses all formatting and creates multiple pages with randomly scattered texts. I will take a print to show.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.