A
A
Alexey Bulba2015-11-18 11:58:28
PHP
Alexey Bulba, 2015-11-18 11:58:28

How to generate PDF from php?

How to generate PDF from data stored in MySQL. Using PHP class mysqli.
Tried with the old mysql class, lots of examples. Not one helped.
Libraries that were tried: FPDF and mPDF.
Now I rummage in TCPDF the positive result is absent.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Regretful, 2015-11-18
@regretful

php.net/manual/ru/book.pdf.php
or write specific code where it doesn't work.

S
Sergey, 2016-09-14
@starosta

If there are difficulties with libraries for PDF conversion, use services with API, for example pdf4b.ru
Code example:

$apikey = 'ВАШ_КЛЮЧ_API'; //получить можно тут: http://www.pdf4b.ru/register
$value = '<title>Тест генерации PDF </title>Какой-то текст'; //может быть HTML или URL, начинающийся с http://...

//Преобразование HTML в PDF с использованием параметров через GET (но лучше использовать POST).
$result = file_get_contents("http://api.pdf4b.ru/pdf?apikey=" . urlencode($apikey) . "&value=" . urlencode($value));

//Сохраняем полученный файл на диск
file_put_contents('mypdf.pdf', $result);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question