FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg

I am working with fpdf to convert html to pdf . I have the following html in new.html .

<title></title>
<p><img alt="" height="364" src="http://10.11.201.93:81/webdocc/uploaded/tes3.jpg" width="496" /><img alt="" height="470" src="http://10.11.201.93:81/webdocc/uploaded/tes4.jpg" width="641" /></p>

The code to convert html to pdf is as following :

<?php
require('html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();
$fp = fopen("new.html","r");
$strContent = fread($fp, filesize("new.html"));
fclose($fp);
$pdf->WriteHTML($strContent);
$pdf->Output("new.pdf");
echo "PDF file is generated successfully!";
?>

But when I run this code , I am getting the following error .

FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg

On the following html code , I am getting error "Alpha channel not supported" .

<h1 id="sample_title"><img alt="" src="http://10.11.201.84/document-editor/uploaded/applet.PNG" style="width: 514px; height: 204px;" /></h1>

How can I remove this errors ? Please help me .

I also faced the same problem much time then I started to read all code of FPDF. I got my solution by changing some line fpdf.php. FPDF.php is core file in FPDF Library. So keep backup of this file before any change.

In this file I just searched

Not a JPEG file

then i comment out this line and set a default value

//$this->Error('Not a JPEG file: '.$file);

$colspace ="DeviceRGB";

After this, my PDF going generate. Note that in my case Image path was valid and i was upload image on S3 using base64 Decode also Croping too. so that maybe my image going working wrong. but it was being open on the browser. So after two change on fpdf.php. I got my solution.

Another thing you have to check is the image path is valid or not. in pdf file i am using

$pdf->Image($file,12,12,30,30);

php: FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc , I am working with fpdf to convert html to pdf . I have the FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg. FPDF error: Some data has already been output, can't send PDF. I am using the fpdf library for my project, and I'm using this to extend one of the drupal module

For "Not a JPEG file": Your best bet here is to re-export the image file. Just open it up in Gimp, Photo Shop, etc and re-export as a jpeg. Every time I've had that come up, I've just re-exported with Gimp and it fixed whatever FPDF thought was the non-jpeg part of the image.

For "Alpha channel not supported": This is because FPDF does NOT support the Alpha channel. I believe it does support Index transparency so you can re-save the image (again Gimp, Photo Shop, etc) with the alpha channel off and Index transparency on.

You may also want to checkout DomPDF it is a HTML TO PDF converter that does support the alpha channel. If it is a large PDF you're generating (many pages, images, etc) you may need to increase the execution time.

One more thing you can check out too, is a fan made support for Alpha in FPDF Alpha Channels / Masks

TCPDF don't display image with writeHTML, FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg On the following html code , I am getting error "Alpha channel not supported" . < h1  The reason for this error is that you are trying to render a character in your PDF that is outside the code range of latin-1 encoding. FPDF uses latin-1 as default encoding for all its build-in fonts. So as a workaround you can just remove all characters from your text that do not fit into latin-1 encoding.

Have found that constructing slideshows with Paintbrush on a MacBook Pro for years have sometimes been saving what "file jpeg_filename.jpg" determines is a PNG, as a JPEG, which is not the end of the world as far as the browsers go rendering this. Within FPDF's fpdf.php I fixed my own shortcomings that were resulting in "FPDF Error: Not a JPEG file" via the kludgy "if($a[2]==3) { return $this->_parsepng($file); }" additional codeline below ...

function _parsejpg($file)
{
  // Extract info from a JPEG file
  $a = getimagesize($file);
  if(!$a)
    $this->Error('Missing or incorrect image file: '.$file);
  if($a[2]==3) { return $this->_parsepng($file); }
  if($a[2]!=2)
    $this->Error('Not a JPEG file: '.' '.$a[2].' '.$file);
  if(!isset($a['channels']) || $a['channels']==3)
    $colspace = 'DeviceRGB';
  elseif($a['channels']==4)
    $colspace = 'DeviceCMYK';
  else
    $colspace = 'DeviceGray';
  $bpc = isset($a['bits']) ? $a['bits'] : 8;
  $data = file_get_contents($file);
  return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
}

Error FPDF: no es un archivo JPEG: http://10.11.201.93:81/webdocc , FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg. En el siguiente código html, aparece el error "No se admite el canal alfa". The first “integration cab” off the rank for yesterday’s PDF Slideshow and Form Creation Helper Primer Tutorial underlying usefulness is with our Inhouse Slideshow arrangements last talked about at Inhouse Slideshow Design Exif Order Tutorial.

Erro FPDF: Não é um arquivo JPEG: http://10.11.201.93:81/webdocc , FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg. No código html a seguir, estou recebendo o erro "Canal alfa não suportado". I'm using pyfpdf in python to generate pdf files. I have a Base64 which I want to insert into a pdf file without having to save it as an image in my file system. But the pyfpdf image function only

Ошибка FPDF: не файл JPEG: http://10.11.201.93:81/webdocc , Я работаю с fpdf для преобразования html в pdf. У меня FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg. 1 Laravel 5.2 not reading env file Aug 3 '19 1 Is this possible to user two id in single column for make model relation in laravel Oct 30 '19 1 how to extract all #Tags and User tag from string in laravel?

php, FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg Для «Не файл JPEG»: Лучше всего здесь реэкспортировать файл изображения. у меня это возникало, я только что экспортировал его с помощью Gimp, и он исправил то, что считало FPDF неотъемлемой частью изображения. Our recent work involving the great Fpdf creator of PDF files when we presented Ajax FormData Object No Body PHP PDF Tutorial has got us starting on a new PDF (PHP) web application we are starting out thinking will help with …

Comments
  • nice solution .working for me.