mPDF not generating PDF in firefox - php

I am using mPDF library for creating PDF using html data.it works fine in google chrome,but in firefox it displays nothing.No files downloaded and no errors in console.
Here is my code :
require_once( $destination_path."/mpdf/mpdf.php");
$target_path = $destination_path . '/uploads/reports/';
$htmlData='<span>Sample Html Content</span>';
try {
$pdf= new mPDF();
$pdf->debug = true;
$pdf->SetFooter("MyApp" . '|{PAGENO}|' . date(DATE_RFC822));
$pdf->WriteHTML($htmlData);
$pdf->Output($fileOutputPath, 'F');
}catch (Exception $e) {
echo 'Caught exception: ', $e, "\n";
}
i am tried ob_clean() and headers for solve the issue,but it remains same .
Anyone knows how to solve this issue?

Related

phpexcel not reading sheet correctly

I am using phpexcel 1.8 to read a .xlsx file with 92 rows. But I am getting only one row as the result. Then I opened the file & made some edits using libre office & then I tried to save the file & an option came up "Use Microsoft Excel 2007/2010/2013 XML Format" & I clicked on it & saved the file.
Then onwards I am getting correct results from reading the file using phpexcel. What could be wrong ? Any help would be appreciated.
Code I used is:
$inputFileName = 'test.xlsx';
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch (Exception $e) {
die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
}
$highRow = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
$highColumn = $objPHPExcel->setActiveSheetIndex(0)->getHighestColumn();
Thanks in advance!

DOMPDF outputs bad html on Linux

UPDATE1:
Works pretty well on Ubuntu but not on CentOS.
I have a issue with the DOMPDF on CentOS Linux VPS,
I output an HTML with css on my WAMPP and works pretty well:
But when i upload the same code, the same html it shows as this:
I tried everything like check encoding, inline css, enabling remote but still no way to get this running, here is my code:
require_once(APP . 'vendors' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
spl_autoload_register('DOMPDF_autoload');
$dompdf = new Dompdf();
def("DOMPDF_ENABLE_REMOTE", true);
$_GET['print'] = 1;
$dompdf->set_paper("A4", "portrait");
$this->output = '';
$this->layout = 'none';
$old_output = $this->output;
$this->render('innobra_pdf');
$new_output = $this->output;
$dompdf->load_html($new_output);
// $dompdf->load_html( utf8_decode($new_output), Configure::read('App.encoding') );
$dompdf->render();
$output = $dompdf->output();
header('Content-type: application/pdf');
echo $output; die();
What i'm doing wrong ?
Thanks
If you have copied to another server, try deleting the file
dompdf/lib/fonts/dompdf_font_family_cache.php

HTML2PDF and api.qrserver.com ERROR number 6

I'm trying to output a pdf with a qrCode image in it.
I'm using api.qrserver.com to create the image and HTML2PDF to create the pdf.
This is my PHP code :
$pre_path = 'http://m.website.fr/';
$path = $pre_path . drupal_lookup_path('alias', "node/" . $_GET['nid']);
require(drupal_get_path('module', 'pdfcreator') . '/libs/html2pdf_v4.03/html2pdf.class.php');
ob_clean();
ob_start();
require(drupal_get_path('module', 'qrcode') . '/templates/pdf.tpl.php');
$content = ob_get_clean();
try {
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
// $html2pdf->setTestIsImage(false);
$html2pdf->WriteHTML($content);
$html2pdf->Output($fields['ref'] . date('ymd') . '.pdf', 'D');
} catch (HTML2PDF_exception $e) {
echo $e;
exit;
}
my template pdf.tpl.php contains
<table>
<tr>
<td><img src="https://api.qrserver.com/v1/create-qr-code/?format=gif&data=<?php echo urlencode($path) ?>"/></td>
</tr>
</table>
Without using html2pdf the image is generating just fine. But when I use HTML2PDF I received
Error 6 : unable to load image https://api.qrserver.com/v1/create-qr-code/?format=gif&data=http%3A%2F%2Fm.website.fr%2Ffoo%2Fstuff
What can be wrong ?
The problem was the "s" in https://

HTML to PDF Creation in Cakephp

Path : Vendor/dompdf
I am getting Fatal error: Class 'DOMPDF' not found in C:\wamp\www\sms_app\app\Controller\SentMessagesController.php on line 313.
Why i am getting error? This is my code:
function example()
{
//App::import('Vendor','dompdf',array('file'=>'dompdf'.DS.'dompdf_config.inc.php'));
require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
$html =
'<html><body>'.
'<p>Put your html here, or generate it with your favourite '.
'templating system.</p>'.
'</body></html>';
try{
$this->dompdf = new DOMPDF();
}
catch (Exception $e)
{
echo $e;
}
$papersize = "legal";
$orientation = 'landscape';
$this->dompdf->load_html($html);
$this->dompdf->set_paper($papersize, $orientation);
$this->dompdf->render();
$output = $this->dompdf->output();
file_put_contents('Brochure.pdf', $output);
}
The error message pretty clearly tells you what is wrong. Check the file(s) you include if the class exists in that file, I doubt it is there. If not figure out in which file the class is and load that file. Check how Dompdf is loading its files.
This error clear says you missing a class so please check how actually importing class in your code.

MPDF - fseek error

I am trying to merge files together into one pdf. The files could be pdf, png or jpg files. Images work fine, its only when I try to export the pdf files that I get an error. The error is show below.
Message: fseek(): stream does not support seeking
I thought I found a solution from various forums relating to the path of the file. However, if I change the path it shows this error
mPDF error: Cannot open http://192.168.2.35/marine/certificate_files/a025ad3d40b22ac760ba7af7b6bb259d.pdf
My controller code is below
include('mpdf/mpdf.php');
$mpdf=new mPDF();
$mpdf->SetImportUse();
$mpdf->SetFooter($personnel_data->firstname . ' ' . $personnel_data->lastname . '|{PAGENO}|' . $personnel_data->ID_number );
foreach($certificate_data as $certificates)
{
$certificate_extension['type'] = explode('.',$certificates->certificate_name);
if($certificate_extension['type'][1]==='pdf')
{
$pagecount = #$mpdf->SetSourceFile('http://192.168.2.35/marine/certificate_files/' . $certificates->certificate_name);
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->UseTemplate($tplId);
$mpdf->WriteHTML('<pagebreak>');
}
if($certificate_extension['type'][1]!=='pdf')
{
$mpdf->WriteHTML('<p><img src="' . $this->config->base_url('assets/images/header-logo.png') . ' "></p>');
$mpdf->WriteHTML('<style>body {font-family: arial;}</style>');
$mpdf->WriteHTML('<p> ' . $certificates->certificate . ' - ' . $certificates->expiry_dates . '</p>');
$mpdf->WriteHTML('<p><img src="' . $this->config->base_url('certificate_files/' . $certificates->certificate_name) . ' "></p>');
$mpdf->WriteHTML('<pagebreak>');
}
else
{
$mpdf->WriteHTML('');
}
}
$mpdf->Output();
exit;
If any help or guidance could slide my way form anyone I would be forever grateful! Thanks!
as far as i know mpdf is based on fpdf (fpdi)... from the FPDI website: http://www.setasign.de/products/pdf-php-solutions/fpdi-pdf-parser/
By default FPDI can "only" handle PDF documents up to PDF version 1.4.
Beginning with PDF version 1.5 there were new compression features
introduced which involve internal structure changes how a PDF document
can be created.
Please try it with an PDF Version <= 1.4 for testing...
in my case it was the reason and I bought a developer license for the commercial pfdi pdf parser for 100€

Categories