I have created a web application which used PHP in combination with MySQL. Now I would like to add a function which creates a PDF document from a LaTeX code. The LaTeX code has a created template with some placeholder. The data for the placeholder are stored in a MySQL database.
Now I would like to load the data from the MySQL database, add it to the LaTeX template (to generate a .tex file) and compile it to a PDF file.
Is this possible with PHP or would you recommend another programming language for this? I have full access to the server. It is important, that the server security is not decreased (e.g. by enabling additional permissions). I have read that I probably would need to disable PHP safe_mode. What would be the recommended way to generate a PDF file from LaTeX on a webserver?
Related
I need to add watermark to a PDF file using PHP without executing external commands like GhostScript.
It must work with PDF 1.7 containing dynamic content (links, forms) so FPDI doesn't work even with its paid version due to the limitations described here https://manuals.setasign.com/fpdi-manual/v2/limitations/ (4.3).
The content is confidential and mustn't be sent to any external API so the watermarking PHP code must be purely on my server.
Any advice?
According to this advisory, .pht files can be used to execute PHP code:https://www.portcullis-security.com/security-research-and-downloads/security-advisories/cve-2015-5074/
However, I am unable to find much information on this file format. I am also unable to get an Apache server running PHP to execute this file.
Does anyone have more information regarding this file format?
It's not used much. This is a quote from file-extensions.org
The PHT file stores HTML page that includes a PHP script, dynamically generates HTML, often by accessing database information.
PHT seems to be very little used format.
These days, you're more likely to see .phtml files. Where there is a mix of PHP and HTML in the file, it still needs to be parsed by the PHP processor to create the right output.
I am not aware of a web server that handles PHT files with the PHP handler by default. Given their nature it's much more likely that they would be templates, included from another PHP file.
In this use case, the included file can have any extension the developer desires and there could be no official association.
Here is my problem: My organization wants to upload word documents from users to the server. On the server side, the word document (enforced with styles) needs to be converted to XML format files. Next, I need to use php to parse the open xml formats files and put the content into the database. Does anyone know how to convert word to XML on server side automatically?Is there any API or sample codes for php to parse Open XML Formats? Your suggestions are appreciated.
Have you looked at using VBA?
I have had to do similar work and I've used VBA within a WSF or VBS file. If you're server is a Windows environment it will run right from the OS. You can execute this from PHP (not recommended) or drop the Docx file into a hot folder outside of the web server environment. I recommend the latter since the web server env. can introduce security issues.
Another note, if you want to separate content from styling, you're going to need to perform some post-processing on the output markup. Word is a "word" processor so styling is what it is designed to do. If this is a requirement, I would suggest moving to a structured, XML-based authoring tool instead.
Hope this helps!
What I'd like to do
I'd like to allow a user to download a dynamically generated pdf file (certificate). I was thinking of creating a pdf template and just write the user's name on it with PHP, that's the only thing that will be dynamic about this.
How I'd like to do it
Since the application is for a client and I have no idea on what server will he use it I'd like to know if there are ways of achieving this without any extra extensions or whatsoever to be installed on the server. I can assume he has PHP > 5.
Basically read the template pdf and write a string to it then save it to be able to offer for download, all this with PHP?
doing this with pure php on your own will get very messy, so i recommend using FPDF in combination with FPDI (to open your templates). both can easily be added to your projects sources, so you don't need to install any extensions (unless you want to compress your PDFs - in that case you'll need zlib installed).
Is it possible to convert a PDF document to HTML or text and then edit some text of the html/text file and recreate the PDF, all in a PHP script?
Have a look at http://www.pdflib.com/download/
I have never seen or attempted todo this.
I find it better/cheaper to do the following:
Write the component that will do image intensive processing op a platform like .Net or Java. The application has be be console based and return/print the relevant info (if there was an error in processing etc).
Call the command from you php web application.
Php is a web language and used best for that purpose.