This topic is locked

Using DOMPDF in PHPRunner 10.3

2/18/2020 5:34:37 AM
PHPRunner General questions
mbintex author

Hi at all,
I found a way to incorporate the latest DOMPDF version from



https://github.com/dompdf/dompdf/releases/download/v0.8.4/dompdf_0-8-4.zip


in PHPRunner 10.3. Just unzip the folder and copy it to your sources and/or output folder.
Add these two lines in the beginning of buttonhandler.php



use Dompdf\Dompdf;

use Dompdf\Options;

require_once 'dompdf/autoload.inc.php';


Now you can write a HTML based PDF from a button like this:

$data =$button->getCurrentRecord();

$datei="files/visitenkarte".$data["ID"].".pdf";
$anschrift=str_replace("\n","
",$data["Anschrift"]);
$value="<table cellspacing=10><tr>

<td valign='top'><span style='font-weight:600; font-size:18pt;'>".$data["Vorname"]." ".$data["Nachname"]."</span>
".

$data["Firma"]."</td><td width=50px>&nbsp;</td><td>".

$anschrift."

".

"<table><tr><td>".

"Tel.: &nbsp;</td><td>".$data["Telefon"]."</td></tr>".

"<tr><td>Mobil: &nbsp;</td><td>".$data["Handy"]."</td></tr>".

"<tr><td>Mail: &nbsp;</td><td>".$data["Email"]."</td></tr></table>".

"</td></tr></table>";
$result["text"]=$value;
// instance dompdf

$dompdf = new Dompdf();

$dompdf->setPaper('A6', 'landscape');
// tell the user-agent to expect a PDF

header('Content-type: application/pdf');
//convert to pdf output
$dompdf->load_html($value);

$dompdf->render();
//$dompdf->stream('exposee.pdf');

$output = $dompdf->output();

file_put_contents($datei, $output);
$result["datei"]=$datei;


And why did I do that? Well, because only DOMPDF can
a) convert nearly all HTML to PDF while the newly built in pdfmake.js can´t,

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=27127&image=1&table=forumtopics' class='bbc_emoticon' alt='B)' /> I can create PDFs with no pages in PHPrunner as source and

c) I can offer my customers the option to "layout" with CKEditor, insert variables like #NAME# for data fields and I mix it for a serial letter and format the whole stuff, because the HTML is converted to PDF and not lost.

d) I can define headers and footers for all pages in the resulting PDF.
If anything of this could be realized with pdfmake.js I would be happy to learn how. Currently I don´t see a possibility to generate for example a business letter or label with Designer and pdfmake.
If not, I would like to know if there is any possibility to print the 'print' and 'report' pages to DOMPDF in 10.3. I tried to fetch the previews of these pages with something like

file_get_contents


with no success. Any help would be appreciated.

woodey2002 2/18/2020

Hi, Have a look here
https://aymkdn.github.io/html-to-pdfmake/index.html.
https://github.com/Aymkdn/html-to-pdfmake
If you manage to get this working somehow I would love to know how you did it.
Best wishes,

J

mbintex author 2/19/2020



https://github.com/Aymkdn/html-to-pdfmake


Already mailed this (with that link) as a feature wish to Sergey.

Admin 2/19/2020

We have seen https://github.com/Aymkdn/html-to-pdfmake. Unfortunately, it is quite terrible the way it is and won't convert much beyond their sample HTML. So we are re-working it and adding it to the main PHPRunner distribution. There will be an update soon that will include this feature.
It will be applied while converting to PDF objects like code snippets, 'View as' Custom and 'View as' HTML including HTML produced by Rich Text Editors.

mbintex author 2/19/2020



We have seen https://github.com/Aymkdn/html-to-pdfmake. Unfortunately, it is quite terrible the way it is and won't convert much beyond their sample HTML. So we are re-working it and adding it to the main PHPRunner distribution. There will be an update soon that will include this feature.
It will be applied while converting to PDF objects like code snippets, 'View as' Custom and 'View as' HTML including HTML produced by Rich Text Editors.


When this comes true, it´ll be the news of the year for me. Thanks in advance.

woodey2002 2/20/2020

Wow Amazing
Many thanks to Sergey and team for releasing v34513 which now includes this excellent functionality.
Cheers,

James