mpdf

PHP - How to use mPDF to merge PDFs

♀尐吖头ヾ 提交于 2019-12-18 16:46:17
问题 I will start out by saying that I can generate PDFs just fine with mPDF, but for the life of me, I can't get it to merge an existing PDF with the PDF it just generated. What I need to figure out is how to append/add the existing PDF to the newly generated PDF. I've tried using the mPDF methods for importing pages, but all I can get is an error like: mPDF error: Cannot open '/downloads/test.pdf'. The above message is ambiguous and unclear as to WHY it can't open the file... Here's the code I'm

adding font to mPDF

早过忘川 提交于 2019-12-17 22:42:27
问题 I'm getting the following error when I try and generate a PDF using the mPDF class: TTF file "C:/wamp/www/inc/mpdf/ttfonts/verdana.ttf": invalid checksum 20f65173c11 table: DSIG (expected 65173c11) I've uploaded the font files to my ttfonts directory and defined the font in config_fonts.php like this: "verdana" => array( 'R' => "verdana.ttf", 'B' => "verdanab.ttf", 'I' => "verdanai.ttf", 'BI' => "verdanaz.ttf", ), I only see the error when I turn on font error reporting in the config settings

how to add css file in mpdf

与世无争的帅哥 提交于 2019-12-17 11:28:44
问题 I am trying to convert html into pdf using mpdf. Problem is that i am unable to apply css to pdf file.. Here is my code of php: <?php $html = $divPrint; $mpdf=new mPDF(); $stylesheet = file_get_contents('pdf.css'); $mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($html,2); $mpdf->Output(); exit; ?> What it is doing is taking html through ajax on my this php page. But the output it gives doesn't come with css which i've written for it.. Please tell me that to do now? 回答1: <?php $html =

PHPExcel及Mpdf导出

纵饮孤独 提交于 2019-12-17 09:43:09
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> PHPExcel常用操作 #导入类库 require_once 'PHPExcel/Classes/PHPExcel.php'; require_once 'PHPExcel/Classes/PHPExcel/Writer/Excel5.php'; //Office 03格式写类 require_once 'PHPExcel/Classes/PHPExcel/Writer/Excel2007.php'; //Office 07格式写类 #基础操作 $objPHPExcel = \PHPExcel_IOFactory::load('a.xls'); //读入指定excel文件 $objPHPExcel->setActiveSheetIndex(0); //指定活动工作表 $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('宋体'); $objPHPExcel->getProperties()->setTitle('xxx'); #单元格写入 $objPHPExcel->getActiveSheet()->setCellValue('A3', 'xxx'); //设定A3单元格值为xxx #单元格合并 $objPHPExcel

Yii2: how to add model and model id in mPDF

北城以北 提交于 2019-12-13 19:02:14
问题 I need to generate pdf from my view, Im using kartik mPDF, Controller : public function actionInvoicesPrint() { $pdf = new Pdf([ 'mode' => Pdf::MODE_CORE, // leaner size using standard fonts 'content' => $this->renderPartial('view', ['model' => $model, 'mode' => Pdf::MODE_CORE, 'format'=> Pdf::FORMAT_A4, 'orientation'=> Pdf::ORIENT_POTRAIT, 'destination'=> Pdf::DEST_BROWSER]), ]); return $pdf->render(); } Getting error Undefined variable: model . I tried as shown above but getting same error.

How to generate PDF using mPDF and add custom Google font to it?

六眼飞鱼酱① 提交于 2019-12-13 16:14:47
问题 I am generating PDF using mPDF PHP library. I am able to successfully generate it using the default font configuration. However, I want to render a Google font in my PDF. I tried using the steps mentioned in this link, but it did not work. Below is the code I use. $mPDFO = new mPDF('utf-8', 'A4', 0, '', 10, 10, 10, 0, 0, 0, 'L'); Can anyone help me using Google Font in mPDF ? 回答1: As mentioned in mPDF's documentation, it's not possible to use remote fonts directly by referencing them in the

Upgrade to PHP7.1 and MPDF show error - A non-numeric value encountered at line 30648

谁都会走 提交于 2019-12-13 12:05:21
问题 I'm using PHP 5.x and mPDF 6.x for long time. This week I decide to upgrade system to PHP7.1 but still using mPDF6. I face some problem after upgrading. PROBLEM 1:: Console show error message: constructer with the same name as class name is deprecate. I go through each php files and find classes, then replace constructer function with __construct(...) PROBLEM 2:: Console show error message:: Can not assign property ID to $attr I go to file mPDF.php in function MergeCSS(...). I add new line of

Page number for dynamically generated pages in mPDF

感情迁移 提交于 2019-12-13 08:56:10
问题 I am using mPDF with Codeigniter for creating PDF files. I have a problem when adding page number. I have some result sets that are generated via database queries and I pass them to my html file to display that data. According to the number of results it creates and converts to pdf format with number of pages. Problem is I cannot add page numbers when it generates more than one page. I am using the basic examples for this operation. Please help me on this! My controller code $result_1 = $this

mpdf: cannot find TTF TrueType font file

不打扰是莪最后的温柔 提交于 2019-12-13 03:39:06
问题 I'm trying to implement mpdf in CodeIgniter according to this article: http://codeigniter.com/wiki/mPDF_with_Codeigniter I did it exactly the same way that is described there, but I got an error: mPDF Error - cannot find TTF TrueType font file - mpdf/ttfonts/DejaVuSansCondensed.ttf But the file is there. I tested this both on a webserver and on localhost. I changed chmod, neither did that have an effect. What can I do about it? 回答1: I found out what was wrong. As recommended in the

Merge two PDF files into single one using MPDF

情到浓时终转凉″ 提交于 2019-12-13 03:33:43
问题 I am using MPDF library to generate pdf files .I have created two PDF files in my root directory as follows : $invoice_nos = ['0'=>'ISE-00000014Y18','1'=>'ISE-00000005Y18']; foreach ($invoice_nos as $key => $invoice_no) { $html = 'Invoice No - '.$invoice_no; $pdf_file_name = $invoice_no.'.pdf'; $pdf_file_path = ROOT . '/app/webroot/Service_Invoices/'. DS .$pdf_file_name ; ob_start(); $mpdf = new \mPDF('utf-8', 'A4' ,'','',5,5,36,10,5,4); $mpdf->WriteHTML($html,2); ob_clean(); $mpdf->Output(