Quantcast
Channel: All Discussions - mPDF Forum
Viewing all 108 articles
Browse latest View live

Regarding to unable create more then 2500 pdf pages using mpdf library php

$
0
0
Hello,
          I am working with Mpdf php library , this library unable to ganerate more then 2500 pdf pages.
         how to reduce execution time i mean how to execution increase and create more then 2500 pdf pages using mpdf library
         is there any process for increase execution fast for Mpdf library.


Thanks

Set column height

$
0
0
I am still working with my page with columns. Is there a way to set the height of each column? Like say column 1 should be 7 inches tall, column 2 should be 8 inches. Then have the content of the column stretched or shrunk to fit in that measurement?

Why so hard setting mpdf

Not working on byethost

$
0
0
Hello everybody,

I´m student of web development so i´m beginner programmer. I have written a web application with silex framework as homework. The app is working flawesly on localhost using XAMPP. I uploaded it to byethost but it´s not working it shows blank page without errors. I checked mPDf documentation and i activated debug with no luck. Is there any special config or requirement in php server to make mPdf work?. If someone used byethost before and had this problem please tell me.

mPDF issue tracker on GitHub?

$
0
0
Hi Ian,

May I suggest that the community use https://github.com/mpdf/mpdf/issues for filing bugs in future? This would enable community members to propose fixes and send pull requests which could be cross-referenced with the original bug report.

Cheers!

Daniel

mPDF6: Page-Break-Inside causes duplication and render errors with interior floating divs.

$
0
0
I stumbled across a peculiar error while attempting to use page-break-inside:avoid to keep together a few pieces of side-by-side data on a report: If you set a float on a div inside of a div marked page-break-inside:avoid, it causes the content of the floated div to be duplicated and re-displayed at the top of whatever page you're currently printing on (drawing straight over the header and any other text that has already been written).

You can replicate the bug with the following code:

//require_once 'lib/mpdf5/mpdf.php';
require_once 'lib/mpdf6/mpdf.php';

// Initialize PDF.
$pdf = new mPDF('c','LETTER',0,'',12,12,12,12);

$title = 'Test Report';

$date = date('n/d/Y');
$headerText = "$date|$title|{PAGENO}";

$pdf->SetHeader($headerText);

// Set report top information
$titleText .= '<h1> . $title . '</h1>';
$pdf->WriteHTML($titleText,2);

$body = '';

$body .= '<div style="page-break-inside:avoid;">';
$body .= '<div style="margin-top: .25in; float: left;">';
$body .= '<p>Test 1</p>';
$body .= '<p>Test 2</p>';
$body .= '<p>Test 3</p>';
$body .= '</div>';
$body .= '</div>';

$pdf->WriteHTML($body,2);

$fileName = 'Test-Report.pdf';
$pdf->Output($fileName, 'I');


Unfortunately, since floats are currently the only effective method for laying out flexible content side-by-side in mPDF (given that columns can't be assigned varying widths, unless I'm missing something in the documentation), I can't find a method for keeping this content from breaking over a page. Does anyone have a solution (or even a functional workaround) for this issue?

mPDF error: Unable to find object (5, 0) at expected location

$
0
0
Hi,
I try to import existing pdf into my pdf. It works with pdf 1.7 but not with pdf 1.3 format. can anyone help me ?
code :
$mpdf -> WriteHTML($html);
foreach ($arrPdf as $key => $value) {
  $pagecount = $mpdf->SetSourceFile(str_ireplace("http://".$_SERVER["SERVER_NAME"]."/","",$value));
  for ($i=1; $i<=$pagecount; $i++) {
    $tplIdx = $mpdf->ImportPage($i);
    $pgw = $mpdf->tpls[$tplIdx]['w'];
    $pgh = $mpdf->tpls[$tplIdx]['h'];
    if ($pgw > $pgh) { $or = 'L'; $x = $pgw; $pgw = $pgh; $pgh = $x; }
    else { $or = 'P'; }
    $mpdf->SetPageTemplate($tplIdx);
    $mpdf->AddPageByArray(array(
                            'orientation' => $or,
                            'sheet-size' => array($pgw,$pgh)
                        ));
    $mpdf->UseTemplate($tplIdx);
  }              
}

PNG image does not loaded into pdf

$
0
0
I am trying to load an image of png format and it is not loaded to the pdf.
If I am trying to load the jpg image it works fine.
How can I load the png?

Warning: unpack() [function.unpack]: Type n: not enough input, need 2, have 0 ...

$
0
0
I used MPDF library literally for years and had no problems until very recently, when my site moved to another hosting, where I get this notorious error message: Warning: unpack() [function.unpack]: Type n: not enough input, need 2, have 0 in .../MPDF60/classes/ttfontsuni.php on line 3616. This error happens when I use cyrillic letters. The minimized example, which results in this error looks like this:

<?php

$html = '
<style>
body { font-family: sans; text-align: justify; }
p { font-family: sans; }
div { font-family: sans; }
</style>
<h4>Russian</h4>
<p>&#x412; &#x447;&#x430;&#x449;&#x430;&#x445; &#x44e;&#x433;&#x430; &#x436;&#x438;&#x43b; &#x431;&#x44b; &#x446;&#x438;&#x442;&#x440;&#x443;&#x441;? &#x414;&#x430;, &#x43d;&#x43e; &#x444;&#x430;&#x43b;&#x44c;&#x448;&#x438;&#x432;&#x44b;&#x439; &#x44d;&#x43a;&#x437;&#x435;&#x43c;&#x43f;&#x43b;&#x44f;&#x440;! </p>';


include("../mpdf.php");
$mpdf=new mPDF();
$mpdf->autoScriptToLang = true;
$mpdf->baseScript = 1;
$mpdf->autoVietnamese = true;
$mpdf->autoArabic = true;
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;


?>


Footer Pagination Doesn't show

$
0
0
Hi all,

I'm trying to set up the footer pagination but it doesn't show and I don't know why.
I've tryied with setHTMLFooter --> Shows nothing
 and with WriteCell (with the aliases) --> Shows {PAGENO} literaly

Thank you.
Here's my code:

<?php

// Include the main TCPDF library (search for installation path).
if (file_exists('/var/www/html/smarttraveldoc/mpdf60/mpdf.php')){
    //require_once('/var/www/html/smarttraveldoc/tcpdf/config/lang/eng.php');
    require_once('/var/www/html/smarttraveldoc/mpdf60/mpdf.php');
}

// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends mPDF {
    public function Header($content = '') {
        
        $this->SetHTMLHeader('
            <p style="text-align: right;
            font-size: 11px; 
            font-family:Helvetica; 
            margin-right:3px; 
            border:none !important;">
                Page {PAGENO}/{nb}
            </p>
            ','BLANK',true);
    }

    // Page footer
    public function Footer() {
        
        $this->SetHTMLFooter('
            <p style="text-align: right;
            font-size: 50px; 
            position:absolute;
            bottom:10px;
            font-family:Arial; 
            margin-right:3px; 
            border:none !important;">
                Page {PAGENO}/{nb}
            </p>
            ','BLANK');

        // Reseller data
        $this->SetY(-13);
        $this->SetFont('Helvetica', 'N', 8);
        $this->WriteCell(0, 10, $resName.' - '.$resAddress.' - Tel: '.$resPhone, 0, false, 'C', 0, '', 0, false, 'T', 'M');

        $this->SetY(-10);
        $this->SetFont('Helvetica', 'N', 8);
        $this->WriteCell(0, 10, 'Fax: '.$resFax.' CIF '.$resCIF.' - G.C. 279MD'.$resWeb, 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
    
    
}

// create new PDF document
$pdf = new MYPDF('UTF-8', 'A4', 0, 'Helvetica',10,10,16,20,9,9,'P');
//set auto page breaks
$pdf->autoPageBreak = true;
$pdf->AliasNbPages();
$pdf->AliasNbPageGroups();
$pdf->use_kwt = true; 

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 051');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');


$pdf->AddPage();
$pdf->AddPage();
$pdf->AddPage();


//Close and output PDF document
$pdf->Output('example_051.pdf', 'I');

//============================================================+
// END OF FILE
//============================================================+
?>

Using mPDF as renderer for PHPExcel

$
0
0

I am having an issue using mPDF as the renderer for PHPExcel.  I have already succeeded in using tcpdf as the renderer for PHPExcel out of the box without issue.  The issue seems to be some kind of compatibility problem. 

The problem manifests when the PDF file is created, it cannot be opened by Adobe reader due to damage/corruption.  I looked into the specific errors and thought it may have been caused by not having read/write permission, but that does not solve the problem.

I have also tried putting error_reporting(E_ALL ^ E_NOTICE) directly at the top of mpdf.php as well as the top of the php script being used.

Any help is appreciated.  The error is below.

When I open the file in an editor it shows the following:

<br />
<b>Warning</b>:  file_put_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GSUBGPOStables.dat) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in <b>C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\ttfontsuni.php</b> on line <b>1145</b><br />
<br />
<b>Warning</b>:  file_put_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GDEFdata.php) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in <b>C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\ttfontsuni.php</b> on line <b>1163</b><br />
<br />
<b>Warning</b>:  file_put_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GSUBdata.php) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in <b>C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\ttfontsuni.php</b> on line <b>1395</b><br />
<br />
<b>Warning</b>:  file_put_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GSUB.arab.DFLT.php) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in <b>C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\ttfontsuni.php</b> on line <b>2195</b><br />
<br />

...............removed....................


PHP Warning:  file_put_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GSUB.arab.URD .php) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\ttfontsuni.php on line 2195
PHP Warning:  file_put_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GSUB.nko .DFLT.php) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\ttfontsuni.php on line 2195
PHP Warning:  file_put_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GPOSdata.php) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: Permission denied in C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\ttfontsuni.php on line 3256
PHP Warning:  include(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GDEFdata.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\otl.php on line 72
PHP Warning:  include() [<a href='function.include'>function.include</a>]: Failed opening 'C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GDEFdata.php' for inclusion (include_path='.;C:\php\pear;../body/pdf/mpdf60') in C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\otl.php on line 72
PHP Warning:  file_get_contents(C:/inetpub/wwwroot/mysite/pdf/mpdf60/ttfontdata/dejavusanscondensed.GSUBGPOStables.dat) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\ssp_development\sss\body\pdf\mpdf60\classes\otl.php on line 235


 

 

Undefined variable: list_item_marker

$
0
0
It seems to be a bug.
Undefined variable: list_item_marker.
Variable $list_item_marker seems to be uninitialized.
(mpdf.php v6.0 Line: 19446)

Chinese font rendering in v6 looking bitmapped

$
0
0
Using MPDF v6 fresh install
I'll be outputting documents in English plus one other language (the other lang could be any of CJK / Arabic/ Thai / Russian etc)

As a test to get things running I have a chunk of mixed text (all in a single html <p> tag) with the name of the language in English followed by the name in its script.
Arabic and Hebrew look nice and smooth in the PDF but CJK samples are bitmapped with bad kerning so characters run into each other.

Is this just because I'm using autoScriptToLang=1 and autoLangToFont=1 and giving it a messy mixed input ?
I also have autoArabic =true

Do you think if I change to css definitions and clean chunks of one language it should render better?
Just looking for some pointers here.

EDIT:
OK that was viewing the PDF in the web browser.. but if I view it in my PDF reader all the bitmapped stuff is now boxes, Arabic and Hebrew are still good though, so I know I can't be loading the CJK fonts into the PDF. But I thought config-fonts was set to do that if auto lang is true?

Many thanks

How to put a bottom border line at the first table of continuous / more than 1 page table

$
0
0
How to put a bottom border line at the first table of continuous / more than 1 page table.
I have a large table consist of more than 100 rows. The library will make a PDF file more than one A4 page. On the table of the first page, or second page, or other continuous page, how to make the bottom border line at the end of the row of the table ?

Debugging mpdf

$
0
0
Hi, I'm running mpdf on a OSX Apache/MySQL stack, and installed mpdf from composer. I have tried both dev-master and 5.7.4

$mpdf = new mPDF('c');
$mpdf->debug = true;
$mpdf->writeHTML($renderedForm); //HTML string input
$mpdf->output($pdffile); //String



In my debugger, I hit writeHTML and execution stops. I cannot find any error messages in apache error_log or in my browser?
How do I go about debugging this? The same code worked before on a LAMP stack.
 

GPL Licensing Clarification

$
0
0
Hi Ian,

There's a discussion over on GitHub discussing a potential license incompatibility between mPDF and the FPDI software integrated into it. This is due to mPDFs GPLv2 license and FPDI's Apache License 2.0, which are incompatible with each other.

The solution would be to update to GPLv3. However, as you are aware, this could be tricky in that you'd also need to look at the licenses of the work you have derived mPDF from and ensure they have a license compatible with GPLv3. I'm not an expert in licensing, but I believe the only major blocker here is work that is only licensed as "GPL" or "GPLv2". However if they are licensed as "GPL or higher" or "GPLv2 or higher" there is no compatibility issues with GPLv3.

I'd also like to ask whether you would consider releasing the mPDF documentation under GPLv3. As you've previously mentioned mPDF v6.0 was going to be the last major version you had planned to work on (I remember reading it in the forums but cannot find a link now). With that in mind, the maintenance of mPDF and its future will begin falling to the community that relies on your great software. And great software is never "great" without quality documentation which the community can access, update and maintain. By making the documentation open source we could host the documentation on GitHub and allow the community to contribute to it. I, and other community members, would love to hear your thoughts on the matter.

Barcodes invalid when starting with a [space]

$
0
0
Hey there,

Today I've discovered that any barcode starting (or ending) with a [space] will result in a different barcode because of trimming, after debugging from end to 'start' I've found that all inline tags are trimmed by default. Since allot of barcodes like C39 (used in my case) can be valid with a [space] at the beginning and end this had to be fixed in our case. Adding a simple if filter based on the tag name fixed this for us and below code could be applied to 5.7.4 (and maybe 6 but we have yet to start using it):

Line 13597:

if (!empty($contents)) {
foreach($contents[0] as $v) {
// Changed to allow style="background: url('bg.jpg')"
  if(preg_match('/^([^=]*)=["]?([^"]*)["]?$/',$v,$a3) || preg_match('/^([^=]*)=[\']?([^\']*)[\']?$/',$v,$a3)) {
  if (strtoupper($a3[1])=='ID' || strtoupper($a3[1])=='CLASS') { // 4.2.013 Omits STYLE
    $attr[strtoupper($a3[1])]=trim(strtoupper($a3[2]));
}
// includes header-style-right etc. used for <pageheader>
  else if (preg_match('/^(HEADER|FOOTER)-STYLE/i',$a3[1])) {
    $attr[strtoupper($a3[1])]=trim(strtoupper($a3[2]));
}
else if( strtoupper($a3[1]) == 'CODE' ){
    $attr[strtoupper($a3[1])]= $a3[2];
}else{
$attr[strtoupper($a3[1])]=trim($a3[2]);
}
      }
  }
}

custom size booklet and skewed font

$
0
0
I am developing what I think is a 7 inch booklet (356mmx356mm) using the booklet example as a base.  May I ask if anyone has done something similar?  Here is the line that generates the first set of pages, before the outputted file:
$mpdf=new mPDF('utf-8',array(250,320),'','',32,25,27,25,16,13);
I am having a time trying to make the font look normal on the default pages (from the example in mpdf60)

Thanks!

new font does not get used (apparently)

$
0
0
Hello,I am trying to use the following:
  "comfortaa" => array(
      'R'=>"Comfortaa-Regular.ttf",
    ),
in the fontdata array
and calling with <p style="font-family:Comfortaa;">
with no luck

please assist?
Thanks!

New lines when copy text from generated PDF to clipboard and paste

$
0
0
Hi everyone! First of all I would like to say thank you to creators of mPDF. I've integrated it in 2 minutes and it works like a charm!

The question I would like to ask concerns text formatting. In PDF it looks just perfect, everything perfectly corresponds to the HTML template I'm using. But when I select a text from generated PDF, copy it to clipboard and then paste it for example in MS Word I get a text with hard line breaks. For example:

in PDF I have sentence (sorry for lorem ipsum):

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.

in copy/pasted text from this PDF I get:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.

So the line breaks are actually the same as they are in PDF, but with other line width it appears to be incorrect. I hope I've explained it correctly. This happens in both variants: when I open generated PDF in Firefox or Adobe acrobat.

So is it bug or feature? :)
 
Viewing all 108 articles
Browse latest View live