PDA

View Full Version : convert document uploads to pdf


Tom Jones
4-23-05, 09:38 AM
So, here's my next site trick in this big dog show. I want to convert user txt, doc, rtf, etc resume uploads to pdf files that will then reside in a special folder (more on this a little later).

My first challenge is using php to convert. I have been researching and, it seems like there are several methods to convert to pdf, some free some not. Have any of you wise coders here ever used these modules? Any recommendations on what will work on pow's servers (seems most of these are add-on, non-native php functions so, I would really appreciate any shoves in the right direction).

The next is more routine. Once these pdfs have been uploaded and assigned a new name, I want these files to be individually password protected. I already have users supplying a resume password that is stored in their mysql record. I would like potential viewers to have to supply the correct password to view the record. Never done this one, either.

Any advice would be appreciated. Iinks to tutorials or guides would be enough, I know the above would be a mouthful to explain. Thanks!

YvetteKuhns
4-23-05, 10:20 AM
http://www.hotscripts.com/PHP/Scripts_and_Programs/File_Manipulation/PDF/

FPDF is freeware. Try that and let us know how you like it.

Tom Jones
4-23-05, 10:37 AM
At first glance, it appears to convert the browser window data to a pdf ala a user input form. I'll go through the manual and forum but, I'm looking for something that converts an attached file to pdf.

You know how work resumes are created and modified; we use Word or something and do periodic updates to the existing info in that app. In my (could be fantasy) perfect world, all they would need to do is then upload the updated files. I think having them fill out a form each time will turn them off real quick.

Thanks for the link, Yvette. I'll give it a deeper lookover now.

Tom Jones
4-23-05, 11:04 AM
As the coffee kicks-in, I realize that I'm probably asking for the equivalent of the acrobat distiller (which isn't realistic). Converting the file upload into a pdf is probably too much to ask of any function or module. Maybe I use a tool like FPDF to allow my poorer users who can't afford Acrobat to create a pdf resume using a form on my site. Then, they can upload the pdf via my form.

So, I guess the two big bears in my sites is now the second smaller "uploading the pdf resume" bear (for now). Anybody know any tutos for this?

YvetteKuhns
4-23-05, 11:40 AM
After much searching, I did not find any quick, easy or free way to resolve your issue. Someone on another forum had a similar idea to yours but he was on a Windows server. He never did get his to work.

All I know is you need to convert Word to a PostScript file, then convert that file to PDF. Ghostscript (http://sourceforge.net/projects/espgs/) is free and converts .ps to .pdf files.

Most people convert their own Word documents to PDF format. If they don't, you can direct them to a link to do it, then let them upload the files to your server.

Tom Jones
4-23-05, 12:06 PM
Yep, exactly what I was thinking. I found a few free apps that do that (much to Adobe's displeasure, I'm sure).

The second issue of uploading the file is the looming question now for me.

Thanks!

RTH10260
4-23-05, 12:55 PM
So, here's my next site trick in this big dog show. I want to convert user txt, doc, rtf, etc resume uploads to pdf files
TXT - text files you should be able to directly feed to the PDF creation module (extension) in PHP.

RTF, DOC and others are Windows platform specific and possibly proprietary formats. Likely impossible to find filters that run out of the box on a Unix platform. Linux users may know about some hacks, but would need recompilation for FreeBSD use. You may have to look into Sun's Open Office (http://www.openoffice.org/) and it's *ix ports for filters that take these pc formats.

The converters I have seen for the Windows operating system link themselves in as a printer driver and convert that common format to PDF.

For mass creation one could write a script using the Windows Scripting Host that picks a directory full of files and runs it thru the correct application producing the print going to a pdf converter. Depending on the time invested into the script, down-/upload from/to the Powweb website could likely be automated too. Next hook the script into the Windows scheduler and keep your workstation running.

My choice of PDF converter in Windows: pdfFactoryPro at http://www.fineprint.com/

Tom Jones
4-23-05, 03:40 PM
You have a much better handle on what it would take and, it doesn't sound very easy. It would probably be manageable on my own server like you describe with lots of extra work put in. Not gonna happen.

I'm going for the linking to free pdf utilities that my users can download and convert their pdfs on their own.

Thanks for the detailed explaination on how it could be done!

YvetteKuhns
4-23-05, 03:48 PM
Thanks for the detailed explaination on how it could be done!

I was too lazy to type it. ;)

I'm going for the linking to free pdf utilities that my users can download and convert their pdfs on their own.

This saves your server load and bandwidth usage. Let them convert, then upload. :D

esc
4-23-05, 03:52 PM
You could always have the users install a PS laser printer driver and configure it to print to a file. That would genereate a PostScript file which could then be uploaded and converted.

It's very similar to the pdfFactoryPro suggestion which would have been mine if someone hadn't beat me to it! ;)

Here's a bunch of PDF links:
http://www.primopdf.com/
http://www.pstill.com/
http://www.fpdf.org/
http://www.cutepdf.com/
http://cgm.cs.mcgill.ca/~luc/PSpdf.html
http://www.doc2pdf.net/
http://www.fastpdf.com/
http://www.rustyparts.com/pdf.php
http://directory.fsf.org/search/fsd-search.py?q=pdf
http://www.sanface.com/
http://www.propertytrek.com/pdfpost/index.php?linkpage=link2.html

Tom Jones
4-23-05, 05:25 PM
Thanks for the links!

Any suggestions on how I should go about creating an upload for these resumes that would also make them password protected based on the user 'resume password' they store with their profile? Making it more complicated, how they could automatically replace old stored resumes with newly uploaded resumes automatically? I'm familiar with the general php forms and mysql storgae but, this involves several additional skills I'm lacking.

Thanks for all the input on pdfs, I wasn't aware of how much non-Adobe stuff was out there.

stuffradio
4-23-05, 06:21 PM
Thanks for the links!

Any suggestions on how I should go about creating an upload for these resumes that would also make them password protected based on the user 'resume password' they store with their profile? Making it more complicated, how they could automatically replace old stored resumes with newly uploaded resumes automatically? I'm familiar with the general php forms and mysql storgae but, this involves several additional skills I'm lacking.

Thanks for all the input on pdfs, I wasn't aware of how much non-Adobe stuff was out there.

Ok here is my suggestion, you need to store these into a database, I'm assuming you already have one, I use mysql. When they submit the file they need to be submitting them and telling the form to upload a text to the database. Below I'll post the upload form, then I'll tell you later how you can make it so they can update it. Name this file submit.php

<?php
include("config.php") //this is the file that has your database information that you use to connect to it
echo "<form enctype= multipart/form-data action=submit1.php method= post>";
echo "<input type=hidden name=max_file_size value=30000 />";
echo "Send this file: <input type=userfile type=file />";
echo "</form>";
?>

Name this file submit1.php
You'll be validating what type of files and where the file will go in here.
<?php
$uploaddir = '/folder/';
$uploadfile = $uploaddir

echo '<pre>';
$_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";

?>

The rest <b>IS</b> basic MySQL. Just search on Google how to add information to database, there should be plenty of tutorials for your heart to feast on :)

enjoy

esc
5-1-05, 04:13 AM
I'll add this link to my list above:
http://www.ros.co.nz/pdf/

YvetteKuhns
5-1-05, 04:32 PM
esc, neat link and cute avatar. ;)

rodneyphillips
7-14-05, 10:49 AM
I have a 100% static real estate site (agency used to send listing information to webmaster and he would create static .html pages for each new listing) that I am converting to be a very dynamic site. There is now a content management portion of the site where the real estate agents can add/update listing information (text data, pictures, pdf files, etc.)

The former webmaster, as part of creating static .html pages, would create a pdf 'Property Listing Package' in which he would put a large amount of the listing information (rooms, descriptions, property highlights, pictures, etc.).

As part of making the site dynamic, the agents wanted the Listing Package to be created dynamically. I have been working with FPDF for a few days now with this goal in mind. So far - seems like a match. FPDF is free! It provides functionality for fonts, colors, margins, rectangles (filled or unfilled), circles, etc. One of the Listing Package pages is quite intensive. I am retrieving data out of MySQL and using FPDF to create this page and it is all coming together nicely.

FPDF comes as a class. I have seen other people sub-class this creating their own for nice clean code. FPDF appars to have been around for a few years. On their site there is code which people written to enhance/extend its capability - I am using a couple of these.

So far - a thumbs up! And, again, it is free!

RTH10260
7-14-05, 02:38 PM
Thanks for the report !
One of the Listing Package pages is quite intensive. I am retrieving data out of MySQL and using FPDF to create this page Take care that you don't hit the 30 seconds cpu / 1 minute lapse time barriers. Better plan ahead to create sections at a time and string them together in a last step. You will have to test the limits.