Jump to content

LaTeX compilation through PHP


mitty

Recommended Posts

Hello all,

 

I read that some people have used FPDI and FPDF to generate .pdf documents written in LaTeX. 

 

I would like to do something similar... But I'm having a problem getting started.  I'm used to just clicking the 'compile' button and bam, there's my sweet LaTeX pdf... How can I accomplish the same results with PHP?

 

Ultimately, my goal is to be able to import any LaTeX package I need, the PHP script to generate the charts and graphs in LaTeX code, then the PHP script to compile the LaTeX and display it on the user's screen in PDF format.

 

Thanks for the help..

-Mitt

Link to comment
Share on other sites

I'm still searching for a solution to this one.  I searched more in-depth for solutions using FPDI and FPDF, but this doesn't look like the route I want to go because I see nothing that says I can use LaTeX.

 

Thanks for any help.

-Mitt

Link to comment
Share on other sites

I'm pretty sure you'll need to call latex from php, using exec or similar.  The exact implementation depends a lot on the situation you need this conversion for.  Is it running on a server or a desktop, and is the system running windows or linux?

 

I don't think FPDF is going to help, as it does not appear to have any integration with latex.

Link to comment
Share on other sites

Thanks!  I'm fairly new to web development.. I didn't know PHP had a function like this.

 

I can use exec to generate the PDF (server-side).  Then the only problem that I'll have is displaying the PDF on the user's computer.  I might just be able to point them to the newly created file on the server, which will pull up the browser's download box.. Then they just open the PDF from there.  Although I might want the PDF to be displayed in the browser's window...  Hmm, I'm just thinking out loud now.  I should be able to figure this part out.

 

Appreciate the help!

 

-Mitt

Link to comment
Share on other sites

You're welcome!

 

Either of those file delivery methods can work, each requires a slightly different approach.  If you point them to the created file then you need Apache to set the mime type.  The big limitation here is access control is trickier if you do your authentication in PHP.

 

If you serve the file from PHP then you need to set the mime type and headers from PHP, but you can also do access control in PHP, which can be simpler.  I can provide you some code for this if you're interested, as we typically use this method.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.