Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dompdf remote image is not displaying in pdf

Tags:

On my server pdf generated via dompdf was not displaying images. Because they are remote url images.(local images are working fine) then I come to know that it needs some settings to render remote images.

allow_url_fopen = true => i can not as server control is not in my hand.(and no one will suggest to do this due to security reasons) read/write access to the DOMPDF_TEMP_DIR (already have this) DOMPDF_ENABLE_REMOTE = true (already have this) 

So to sure the issue of allow_url_fopen, I set false in my localhost which is now giving the same output as server.

So, now the issue is now I want to display remote images in PDF with allow_url_fopen = false

  • I tried almost 5-10 unique ways to do this.
  • I tried to display image in php file (via setting headers) and then displaying the php link in pdf
  • I tried to display image via absolute path to php too but nothing worked.
  • I tried via getting image via curl in a function and then displaying it in a php file ...but no luck.

Is there anyone can suggest me how can I display image in pdf please. The error I am always getting is ...

Image not found http://localhost/dompdf/image.php 

and

Image not found http://localhost/dompdf/image.jpg 
like image 703
TechCare99 Avatar asked Mar 01 '13 08:03

TechCare99


People also ask

How do I display a PDF image in Dompdf?

The best solution I found for displaying images is to convert the image into Base64 and display them as base64 when the PDF is generated. The below code will explain about how to do it.. $dompdf = new Dompdf( $options ); $dompdf ->loadHTML( $HTML );

How do I change the page size of a PDF in Dompdf?

By default it's going to render on 'US Letter', you can change this by using: $dompdf->set_paper(DEFAULT_PDF_PAPER_SIZE, 'portrait'); You can use 'letter', 'legal', 'A4', etc.. With dompdf 0.6 you can also use the CSS @page rule to set your page size/orientation.

What is Dompdf library?

Dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements.

What is Dompdf codeigniter?

Here in this post we have disccuss how to convert HTML content to PDF format file or generate PDF file in codeigniter by using Dompdf. Dompdf library provides us to simplest way to generate PDF from HTML in Codeigniter. Here this example will show you how to configure Dompdf library in Codeigniter.


1 Answers

Try

$options = new Options(); $options->set('isRemoteEnabled', true); $dompdf = new Dompdf($options); 
like image 67
theTypan Avatar answered Oct 07 '22 18:10

theTypan