Answer the question
In order to leave comments, you need to log in
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
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.
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.
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 questionAsk a Question
731 491 924 answers to any question