New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Margin Right #388

jecorrales3 opened this Issue Oct 4, 2018 · 1 comment


None yet
2 participants

jecorrales3 commented Oct 4, 2018

Hi, i've used the command to install the library:
composer require spipu/html2pdf

And, i'm using the version ^5.2 for spipu/html2pdf and this was the answer from composer:

./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing tecnickcom/tcpdf (6.2.25): Downloading (100%)
  - Installing spipu/html2pdf (v5.2.0): Downloading (100%)
spipu/html2pdf suggests installing fagundes/zff-html2pdf (if you need to integrate Html2Pdf with Zend Framework 2 (zf2))
Writing lock file
Generating autoload files

And this it's my implement code from the library:


  require_once dirname(__FILE__).'/vendor/autoload.php';
  use Spipu\Html2Pdf\Html2Pdf;
  use Spipu\Html2Pdf\Exception\Html2PdfException;
  use Spipu\Html2Pdf\Exception\ExceptionFormatter;
  $name = 'RTM996';
      include dirname(__FILE__).'/Template/template-letter.php';
      $template = ob_get_clean();
      $html2pdf = new Html2Pdf('P', 'A4', 'es', true, 'UTF-8', array(20, 20, 20, 20));
      $html2pdf->output(strtoupper($name) . '.pdf');
  } catch (Html2PdfException $exception)
      $formatter = new ExceptionFormatter($exception);
      echo $formatter->getHtmlMessage();


The issue it's happening when I'm trying to use the margin right with the array in my example:
array(20, 20, 20, 20), but all the margin works fine, but the margin right doesn't work correctly or just like I'm looking for.

And I've found on the documentation this, and I have an error from this variables on the array:

$pdf = new \Spipu\Html2Pdf\Html2Pdf('P','A4','en', false, 'UTF-8', array(mL, mT, mR, mB));

Getting this warning with every element of array:

Warning: Use of undefined constant mL - assumed 'mL' (this will throw an Error in a future version of PHP) in C:\Users\

And this error:

Fatal error: Uncaught Exception: TCPDF ERROR: Some data has already been output, can't send PDF file in C:\Users\Johan Corrales\Documents\GitHub\angular\api\Class\PDF\vendor\tecnickcom\tcpdf\tcpdf.php:2926 Stack trace: #0 C:\Users\Johan Corrales\Documents\GitHub\angular\api\Class\PDF\vendor\tecnickcom\tcpdf\tcpdf.php(7621): TCPDF->Error('Some data has a...') #1 C:\Users\Johan Corrales\Documents\GitHub\angular\api\Class\PDF\vendor\spipu\html2pdf\src\Html2Pdf.php(575): TCPDF->Output('RTM996.pdf', 'I') #2 C:\Users\Johan Corrales\Documents\GitHub\angular\api\Class\PDF\prueba.php(16): Spipu\Html2Pdf\Html2Pdf->output('RTM996.pdf') #3 {main} thrown in C:\Users\Johan Corrales\Documents\GitHub\angular\api\Class\PDF\vendor\tecnickcom\tcpdf\tcpdf.php on line 2926


This comment has been minimized.


spipu commented Oct 26, 2018

have you specify the width of each element of your table ?
and also, you use a very very long word "COMPANYCOMPAGNY...." that can not fit on a page...

for your last pb, you did not replace mL, mT, ... by real values, it will never work...

@spipu spipu added the help wanted label Oct 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment