Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create PDF documents from image files, using PHP

Tags:

php

pdf

tcpdf

With PHP application, I have to generate single PDF documents, from set of images.

Which is best way to achieve this? Can I use TCPDF library, and can you give me some example?

like image 980
user198003 Avatar asked Jul 28 '11 21:07

user198003


People also ask

How do I create a PDF from images?

Drag and drop an image file (JPG, PNG, BMP, and more) to use our PDF converter. Select an image file (JPG, PNG, BMP, and more) to use our PDF converter. Drag and drop an image file (JPG, PNG, BMP, and more) to use our PDF converter. Your file will be securely uploaded to Adobe cloud storage.

How create PDF in PHP explain with example?

php require('./fpdf. php'); $pdf=new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World! '); $pdf->Output(); ?> Upon execution, the PHP script will generate a PDF file in your browser.

How do you create a PDF from multiple images?

To combine your images into a PDF, first select all images in File Explorer or on your Desktop. Next, right-click on one of the selected images and click Print. The Print Pictures window will appear. From the Printer drop-down menu in the upper-left, select Microsoft Print to PDF.

How can create HTML PDF in PHP?

Dompdf is also one of the best PHP library to convert any HTML page to a PDF file in a simple and easy way. This library also allows modification while converting our HTML page to PDF document using the PHP code. I'll show you how you can implement it and convert your HTML with CSS styling into a PDF document.


2 Answers

you can use dompdf.You can find a copy of the original documentation at this link

like image 91
jay Avatar answered Oct 29 '22 02:10

jay


The easiest way is to use TCPDF (http://www.tcpdf.org) and set the images as full background as on the example n. 51.

For example:

// disable auto-page-break
$pdf->SetAutoPageBreak(false, 0);

// set image 1
$pdf->AddPage();
$this->Image('image_demo1.jpg', 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
$this->setPageMark();

// set image 2
$pdf->AddPage();
$this->Image('image_demo2.jpg', 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
$this->setPageMark();

// ...
like image 10
Nicola Asuni Avatar answered Oct 29 '22 04:10

Nicola Asuni