toddmusicman Posted November 17, 2010 Share Posted November 17, 2010 Were you able to resolve this? This is driving me crazy. I think I'm at the same point you were when you were seeking help. Thanks for any help. Which part are you stuck on? I can generate the fdf no problem. Everything seems to work fine there. But I can't generate the PDF from there. Ty44ler adds additional code to the original which I thought would resolve the problem. I enter that and get syntax error at ?> Not sure why though. Thanx for any help though. Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135482 Share on other sites More sharing options...
hadoob024 Posted November 17, 2010 Share Posted November 17, 2010 Here's all I do: $fdf_file="CMS".$focus->caseid.".fdf"; $pdf_file="CMS".$focus->caseid.".pdf"; $fdf_dir=".\\pdfFiles\\"; exec('pdftk cms1500.pdf fill_form '.$fdf_dir.$fdf_file.' output '.$fdf_dir.$pdf_file.' flatten'); exec('del '.$fdf_dir.$fdf_file); I then make sure that my PDF form file, pdftk.exe and libiconv2.dll are in the same directory as the file calling these commands (which in my case is index.php in the root directory) and this works like a charm. Where do you have your files located? Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135519 Share on other sites More sharing options...
toddmusicman Posted November 17, 2010 Share Posted November 17, 2010 Here's all I do: $fdf_file="CMS".$focus->caseid.".fdf"; $pdf_file="CMS".$focus->caseid.".pdf"; $fdf_dir=".\\pdfFiles\\"; exec('pdftk cms1500.pdf fill_form '.$fdf_dir.$fdf_file.' output '.$fdf_dir.$pdf_file.' flatten'); exec('del '.$fdf_dir.$fdf_file); I then make sure that my PDF form file, pdftk.exe and libiconv2.dll are in the same directory as the file calling these commands (which in my case is index.php in the root directory) and this works like a charm. Where do you have your files located? Okay, I've got everything in the same directory with the exception of the results directory. I'm missing the pdftk.exe and libiconv2.dll. That's probably what's wrong. I have time this afternoon to work on this, so I'm going to give it a shot. Thanks so much... Hope it works! Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135639 Share on other sites More sharing options...
hadoob024 Posted November 17, 2010 Share Posted November 17, 2010 Yup. That's probably it. Here's the link: http://www.pdflabs.com/docs/install-pdftk/ Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135678 Share on other sites More sharing options...
toddmusicman Posted November 17, 2010 Share Posted November 17, 2010 Yup. That's probably it. Here's the link: http://www.pdflabs.com/docs/install-pdftk/ Still having some issues. It may be related to my directories. I'm not in the root. I'm running everything from a directory called PDF. Maybe I should just go to the root? This is what it looks like: if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')){ fwrite($fp,$fdf_data,strlen($fdf_data)); echo $fdf_file,' written successfully.'; }else{ die('Unable to create file: '.$fdf_dir.'/'.$fdf_file); } $fdf_file="CMS".$focus->caseid.".fdf"; $pdf_file="CMS".$focus->caseid.".pdf"; $fdf_dir=".\\pdf\results\\"; exec('pdftk test.pdf fill_form '.$fdf_dir.$fdf_file.' output '.$fdf_dir.$pdf_file.' flatten'); exec('del '.$fdf_dir.$fdf_file); fclose($fp); } }else{ echo 'You did not submit a form.'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135679 Share on other sites More sharing options...
toddmusicman Posted November 17, 2010 Share Posted November 17, 2010 What's your "CMS" referencing? Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135682 Share on other sites More sharing options...
hadoob024 Posted November 17, 2010 Share Posted November 17, 2010 That's what I would recommend. I tried doing something similar to what you have (pdf in one directory, pdftk.exe in another directory, file executing in another directory), and I kept getting errors. Then I just dumped them all in the root, and it just worked. But from your example, do you have the exe and dll files in the same directory as the file that's calling the exec() function, because that's how it looks pathed out? Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135683 Share on other sites More sharing options...
toddmusicman Posted November 17, 2010 Share Posted November 17, 2010 The exe and dll along with all of the php files are in the PDF directory. The FDF output files are routing to a directory (results) like this \pdf\results The FDF files are writing fine. I just can't get the PDF to generate. I'm going to try your suggestion. Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135687 Share on other sites More sharing options...
toddmusicman Posted November 17, 2010 Share Posted November 17, 2010 Moved everything. I even tried to write the FDF to the same directory. The FDF shows up and I get an Array post on the page, but no pdf generated. I don't know what I'm doing wrong. I'm sure it something stupid. Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135703 Share on other sites More sharing options...
hadoob024 Posted November 17, 2010 Share Posted November 17, 2010 Hmmm... I wonder if it's a permissions issue??? Maybe that pdftk utility doesn't have the appropriate permissions to write a PDF file to that directory? Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135714 Share on other sites More sharing options...
toddmusicman Posted November 17, 2010 Share Posted November 17, 2010 No sure. But the FDF is writing and I have the permission set to write and execute. Did you have to change anything in the createFDF.php file? function createFDF($file,$info){ $data="%FDF-1.2\n%âãÏÓ\n1 0 obj\n<< \n/FDF << /Fields [ "; foreach($info as $field => $val){ if(is_array($val)){ $data.=<</T('.$field.')/V['; foreach($val as $opt) $data.='('.trim($opt).')'; $data.=]>>'; }else{ $data.='<</T('.$field.')/V('.trim($val).')>>'; } } $data.="] \n/F (".$file.") /ID [ <".md5(time()).">\n] >>". " \n>> \nendobj\ntrailer\n". "<<\n/Root 1 0 R \n\n>>\n%%EOF\n"; return $data; } Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135722 Share on other sites More sharing options...
hadoob024 Posted November 17, 2010 Share Posted November 17, 2010 Nope. Didn't change anything. Although this is what my $date looks like in my file: $data="%FDF-1.2\n%����\n1 0 obj\n<< \n/FDF << /Fields [ "; Hmmm.. I dunno. If all your PHP, EXE, DLL and PDF form files are in the same directory and it's still not generating a PDF, then permissions is the only thing I can think of. Hell, I even gave the "Everyone" group full permissions. What web server are you using? Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1135729 Share on other sites More sharing options...
toddmusicman Posted January 13, 2011 Share Posted January 13, 2011 Finally got back to this. I think I know why this doesn't work for me. The web server I'm using won't allow for execution of .exe files. This seems to explain the problem, for me at least. Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1158947 Share on other sites More sharing options...
hadoob024 Posted January 13, 2011 Share Posted January 13, 2011 That's what I was thinking. If everything is in the appropriate location, then the only explanation that I see is that your web server can't execute exe files or that the permissions aren't set to allow the execution of exe file. You should be able to control that, right? Do you have access to the server? Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1159010 Share on other sites More sharing options...
toddmusicman Posted January 13, 2011 Share Posted January 13, 2011 I talked to the web host and they don't allow it. I'm having to look at other options. I just wanted to update the post just in case anyone using this script runs into this again. Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1159017 Share on other sites More sharing options...
hadoob024 Posted January 13, 2011 Share Posted January 13, 2011 Got it. It must be a shared hosting environment, right? Is it that they don't allow the execution of any executables? Yeah. Sorry man. I'm outta ideas. Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1159019 Share on other sites More sharing options...
bvivekd Posted July 8, 2011 Share Posted July 8, 2011 Hello I have run into the exact same problem as you . Have you figured out any solution to the exe being in the server? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/181922-convert-fdf-to-pdf/page/2/#findComment-1240181 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.