Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Running pdflatex with PHP on OSX

Running pdflatex with PHP on OSX
Thread Tools
Forum Regular
Join Date: Oct 1999
Location: London
Status: Offline
Reply With Quote
Nov 3, 2000, 07:36 PM
 
Wow ... I'm learning all sorts of new skills with OSX (and my brain is beginning to hurt)!

My currently problem is a PHP script that I can't quite get to work properly and wonder if anyone out there can point the way. Here's the code snippet:

# Run PDF maker --------------------------------------------------------------------->

system("pdflatex -interaction=nonstopmode >/dev/null $filename.tex", $pdfgen);
if($pdfgen == 1){
$msg = "Due to an attack of Ebola, we were unable to generate a PDF.";

echo msg($msg);

exit;
}# end if


I'm trying to use the command "pdflatex" with some properties and then insert the path to the file as a variable. Actually, I can't even get the silly "pdflatex" command to run (I can run simple things like "ls -la", though) via PHP. Does ANYBODY have a clue?

Thanks!

;-)
     
Grizzled Veteran
Join Date: Sep 1999
Location: Boston, MA USA
Status: Offline
Reply With Quote
Nov 5, 2000, 10:13 AM
 
Originally posted by QuatermassX:
Wow ... I'm learning all sorts of new skills with OSX (and my brain is beginning to hurt)!

My currently problem is a PHP script that I can't quite get to work properly and wonder if anyone out there can point the way. Here's the code snippet:

# Run PDF maker
Hmmm. It looks to me like you're trying to generate a pdf from a web page - is that right?

Since pdflatex won't run even from the command line, I'd say that's your problem. Either it's not installed properly or it's not in your your path directories. Try doing a search for it, either with Sherlock or using the find command in terminal.app (eg: "find / -name 'pdflatex*'") and see what you come up with.

BTW - php has the ability to create PDFs, assuming you install PDFlib. You may want to check out a PHP book.
     
Forum Regular
Join Date: Oct 1999
Location: London
Status: Offline
Reply With Quote
Nov 5, 2000, 05:05 PM
 
Sorry, actually "pdflatex" DOES run just fine from the command line ... attributes and all ... and that's the maddening part of this ...

Works from the command line, but not PHP ...

And other commands work just fine using nearly identical syntax in PHP ...

So, I'm wondering if there's something extra in the script that I've botched or some special problem with "pdflatex" ... its been hard finding documentation at all!

(there are no man pages for it! argh)

Thanks for the tips, though ...
     
Forum Regular
Join Date: Oct 1999
Location: London
Status: Offline
Reply With Quote
Nov 8, 2000, 08:55 PM
 
Ah HA!

I had to insert the full path to "pdflatex" in my script ... weird ...

but the thing runs beautifully now!

Oh, the full app is for online creation of custom PDF's from LaTeX source :-)
     
Fresh-Faced Recruit
Join Date: Oct 2000
Status: Offline
Reply With Quote
Nov 8, 2000, 10:06 PM
 
any chance of writing a "how-to"? I would love to be able to create pdfs from php.

thanks

     
Forum Regular
Join Date: Oct 1999
Location: London
Status: Offline
Reply With Quote
Nov 9, 2000, 08:37 AM
 
Hmm, well, this is a project for work, so I'm not free to post all the code. HOWEVER ;-)

There's nothing all that fancy going on with the project. I have a bunch of books written in LaTeX. I need to slice and dice them and generate PDF's from the customized content via a web-browser-based interface.

So.

Here are the ingrediants:

1. Install mySQL, PHP on OSX
2. Install a LaTeX package -- here's a REALLY neat project http://darkwing.uoregon.edu/~koch/texshop/texshop.html Professor Koch is doing a fabulous job. In the readme for TeXShop are instructions for installing "teTeX".

After everything's been installed, slap your data into the mySQL database, create a simple web interface, and "pull the strings" with PHP ;-)

system("pdflatex -interaction=nonstopmode >/dev/null $filename.tex", $pdfgen);

That line runs the "pdflatex" command without returning error messages and generates a PDF. From the command line, its as SIMPLE as typing "pdflatex myfile.tex". As you see, I'm not really generating the PDF from PHP, merely running a system command.

If you need more code, let me know and I'll try to post a generic version here.

Good luck!
     
Grizzled Veteran
Join Date: Sep 1999
Location: Boston, MA USA
Status: Offline
Reply With Quote
Nov 10, 2000, 08:14 AM
 
Originally posted by QuatermassX:
I need to slice and dice them and generate PDF's from the customized content via a web-browser-based interface.
Wait - does this actually take PHP input and create a customized PDF from it? I'd love to be able to create a PDF from scratch (or a template) to deliver, say, a receipt for a web order.

But it sounds like your system just takes a static tex file and converts it to a PDF, right? I do know that PHP can create pdfs from scratch directly via pdflib, but I've never had any success compiling this under FreeBSD, and certainly none under MOSX.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:40 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2