Math equations are not displayed in exported pdf? - php

I'm using yii2 mpdf extension for print page, and using "mathjax" plugin for write mathematical equations. Equations are displayed correctly in web page but not displayed in printed pdf.

Related

I want to generate PDF using page

I want to generate PDFs in PHP. How can I do this?
I tried generating page PDF using MPDF but it can't generate the whole thing on page like extra images on pages and details etc..

Display equations using wiris in Div in Moodle

I am using wiris plugin for tinyMCE editor in Moodle. Using the wiris editor I type some equations.
But these equations are inserted in database as
<p>«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«msup»«mi»x«/mi»«mn»4«/mn»«/msup»«/math»</p>
this format. And while display these in browser it display as same
<p>«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«msup»«mi»x«/mi»«mn»4«/mn»«/msup»«/math»</p>
But I have to display as:
How can I do this? Please help me..
EDIT
My problem is the equation generated using WIRIS is displaying in tinyMCE editor as desired, but while displaying in div/span/table etc it display as
<p>«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«msup»«mi»x«/mi»«mn»4«/mn»«/msup»«/math»</p>
Please refer the image for more details.
Once enabled, our filter automatically converts safeXML to formula images in Moodle contexts without any additional logic.
If you try creating a regular native Moodle question including a WIRIS formula and then preview it, using Moodle's default preview, the formula will show as an image.
If you are trying to display the formulas in a custom module you are building from scratch, the scenario is different.
Are you filtering the content before displaying it? You need to use format_text() so that the filter parses the text you are displaying.
Please check the code of /<moodle>/blocks/html/block_html.php and how format_text() is used. We also recommend that you check the Moodle filter documentation at https://docs.moodle.org/dev/Filters#A_note_about_performance
Please note that if you are using WIRIS in Moodle our formula images are stored in your database as what we call safeXML, which is a slight modification of MathML replacing five characters (http://wiris.com/plugins/docs/resources/encoding-attributes).
However, you don't need any additional configuration for formulas to be displayed as images in Moodle. WIRIS filter automatically converts safeXML into formula images.
Please check that you have enabled WIRIS filter as detailed on step 3 at http://www.wiris.com/plugins/docs/moodle

MathJax html render to pdf

I am trying to make an online quiz application where the user will be presented with a quiz that contains text, images and math equations. I also want the user to be able to print that quiz. I am using MathJax to display the equations.
If the quiz contains just text and images but no math equations, I can use DomPdf to convert the quiz HTML to a PDF and have the user print it.
However, how can I go about creating a PDF that has both the content from the HTML tags in the quiz and the math equations from the quiz rendered by MathJax?
According to this post: http://sourceforge.net/projects/mathjax/forums/forum/948700/topic/3819537
wkhtmltopdf can convert the mathjax if you force a delay on the javascript rendering. I just got finished talking to a guy here:
Printing the current page to pdf using wkhtmltopdf
about how to get a page saved to pdf using wkhtmltopdf from php. If you put those two things together, I think you can get what you want.

PHP page to PDF with object oriented websites

I'm trying to get my shopping cart items to a pdf to create an invoice
I have url which shows the invoice in html/css like this:
index.php?module=checkout&view=topdf
If I want to get the content of that page to use in mPDF or other pdf libraries using file_get_contents or cURL it doesn't give any content because the url is not an actual file on the server
How can I fix this? I work with templates and don't know how can I export the current php page to a html page
I used TCPDF for something similar. Getting the formatting right is a bit of a pain but once you've got that it's a really good bit of work.
http://www.tcpdf.org/examples.php

How to save a page as pdf in php

Does anyone know how I can save a page as pdf in php?
Example:
I have a page that is able to catch the users signature. Now I would like to create a button on the page that will convert the page into pdf so that the file can be saved to a folder.
Below you can see what the signature page looks like:
There are a number of PHP PDF API and tools which convert or wrap up html content including drawings, links and images etc.
A very good thread from StackOverflow :
Convert HTML to PDF using PHP
TCPDF can output PDF's from html: http://www.tcpdf.org/
If you need to use more advanced html you can use WKHTMLTOPDF: http://wkhtmltopdf.org/

Categories