R
R
rudaki29rus2018-01-29 14:31:31
PHP
rudaki29rus, 2018-01-29 14:31:31

How to generate a document from form fields on the site?

Hello. The site has a form with various fields. Task: after filling in all the fields, the user presses the button and he is asked to save the completed document in Word / PDF. In which direction to move I have no idea. Maybe there are some ready-made solutions?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
tyzberd, 2018-01-29
@tyzberd

https://ourcodeworld.com/articles/read/226/top-5-b...
+ php

S
Stalker_RED, 2018-01-29
@Stalker_RED

PDF generator on php https://github.com/mpdf/mpdf
On js https://github.com/marcbachmann/node-html-pdf
You can also use Word, it's easy to google https://github.com/PHPOffice/PHPWord
And mentally prepare for the fact that the appearance will have to be corrected with a file.

N
NosovK, 2018-01-30
@NosovK

There are two ways. Simple:
Make a page with a printable version and call window.print(). Chrome, ie etc offer to print to PDF. The main thing is that the print version should be neat. This is the easy way.
Complex: draw PDF with js.
https://github.com/MrRio/jsPDF
The logic is very similar to the logic of working with canvas. Therefore, you can draw something that is already complex, but time-consuming. We somehow made reports in PDF - it took a lot of time to draw the plates in this way.

K
Kirill Gorelov, 2018-03-21
@Kirill-Gorelov

I know for sure that through www.fpdf.org you can do the same and not too difficult.
I can’t say anything about other libraries, I haven’t used them.
In order to substitute your values ​​into the document, you pass them via ajax or via get/post parameters and you're done.
You will get something like this. Taken from the documentation.
The easiest way to generate pdf files.

<?php
require('fpdf.php');

$pdf = new FPDF();
$one_param = $_GET['one_param'];
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,$one_param);
$pdf->Output();
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question