G
G
GrimJack2017-05-30 12:25:30
JavaScript
GrimJack, 2017-05-30 12:25:30

How to add information to a pdf document?

Hello everyone, this is the first time I have encountered such a problem and I ask for your advice.
There is some platform on which, by pressing the corresponding key, a pdf document should be generated. More precisely:

  1. A link to a pdf form is taken (from the database)
  2. Elements are formed in a cycle (they have a font, color, size and coordinates "x" and "y") (also taken from the database)
  3. All this is glued together and the finished pdf is displayed.

It is desirable that the proposed solution could form elements not through html. Tried to deal with the barryvdh/laravel-dompdf library . But it did not work out, maybe someone used it and can tell you normally.
The platform is written in angular and laravel (5.1).
If possible, with an example

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kamol, 2017-05-31
@H_Kamol

The barryvdh/laravel-dompdf package is quite handy to use. What exactly did you not understand?
Below is the code using the package:

$text="Текст";
//создаем инстанс класса от DOMDPF
 $pdf = App::make('dompdf.wrapper');
//генерируем название файла
$filename =  \Carbon\Carbon::now() . ".pdf";
//загружаем наш view шаблон и в шаблон передаем текст 
$pdf->loadView('template.print_fields', compact('text'));
//выводим шаблон в формате pdf на странице.
return $pdf->stream($filename);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question