Jump to content

Ty44ler

Members
  • Posts

    133
  • Joined

  • Last visited

Everything posted by Ty44ler

  1. Got it: Basically I was using: http://refrigerantcompliance/RefrigerantComplianceService/Service1.WSDL When I should have been using: http://refrigerantcompliance/RefrigerantComplianceService/Service1.asmx?wsdl Final code: $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.asmx?wsdl"); $result = $client->__soapCall('GetJobs', array()); $array = $result->GetJobsResult->JobDAO;
  2. Well, with a little help I've got it to connect. $aOptions = array( 'location' => 'http://refrigerantcompliance/RefrigerantComplianceService/Service1.asmx', 'uri' => 'http://tempuri.org/' ); $client = new SOAPClient(null, $aOptions); $result = $client->__soapCall('GetJobs', array(), array('soapaction' => 'http://tempuri.org/GetJobs')); Now that it connects, how do I go about displaying a list of data? like the 'RequestNo' data?
  3. Well, I've updated my code a little bit, figured out that I should be using non-wsdl mode... Here's my code now: $aOptions = array( 'location' => 'http://refrigerantcompliance/RefrigerantComplianceService/Service1.asmx', 'uri' => 'http://tempuri.org/' ); $client = new SOAPClient(null, $aOptions); $result = $client->__soapCall('GetJobs', array()); //line 51 and the error I receive... Getting there... any help would still be appreciated...
  4. Ok, I'm going to try and take a step back here. If I were to simply say I wanted to list all the RequestNo's would that be possible? Just forgetting all the stuff except for this line: $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl", array("trace" => 1, "exceptions" => 0)); Would it be possible to just list all the data in RequestNo's?
  5. Yeah, I'm starting to get that feeling now too. I appreciate your help. I thought this would be a little easier... Well anyway, here's the functions from the wsdl: Also, I don't know if this helps anything, but GetJobs() has no parameters, which is kind of throwing me for a loop as well.
  6. You may be on to something... I was told when given the web service, that GetJobs() was a function that I needed to call which would give an xml file. I may be on a tangent though as I'm pretty confused now... Here's the output that I got (no errors!)
  7. Here's the error formatted better: Still not sure what to do...
  8. If anyone would like to help, it would be much appreciated... From what I've been reading and looking at a few examples I've gotten this so far, but it still throws errors: $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl"); $result = $client->GetJobs(array('GetJobs')); //Error occurs on this line // Note that $array contains the result of the traversed object structure $array = $result->GetJobsResult->JobDAO; print "Service Description:<select><option>Please Select One</option>"; foreach($array as $k=>$v){ print "<option>".($k+1).$v->RequestNo."</option>".$v->Description."</td></tr>"; } print "</select>"; Error:
  9. I have been given this web service, which I have been told will create an XML file once it is called through code, but I don't know how to get the XML from the web service in PHP. The web service is only on our network and not public so I've posted the WSDL file below: <?xml version="1.0" encoding="utf-8" ?> - <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> - <wsdl:types> - <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> + <s:element name="HelloWorld"> <s:complexType /> </s:element> + <s:element name="HelloWorldResponse"> - <s:complexType> + <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" /> </s:sequence> </s:complexType> </s:element> - <s:element name="GetJobs"> <s:complexType /> </s:element> - <s:element name="GetJobsResponse"> - <s:complexType> - <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="GetJobsResult" type="tns:ArrayOfJobDAO" /> </s:sequence> </s:complexType> </s:element> - <s:complexType name="ArrayOfJobDAO"> - <s:sequence> <s:element minOccurs="0" maxOccurs="unbounded" name="JobDAO" nillable="true" type="tns:JobDAO" /> </s:sequence> </s:complexType> - <s:complexType name="JobDAO"> - <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="StatusCode" type="s:string" /> <s:element minOccurs="1" maxOccurs="1" name="SRPWOHRID" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="CompanyNumber" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="DivisionNumber" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="CustomerNumber" type="s:int" /> <s:element minOccurs="1" maxOccurs="1" name="RequestNo" type="s:int" /> <s:element minOccurs="0" maxOccurs="1" name="RequestorName" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="AreaCode" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="PhoneNo" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="Address1" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="StateCode" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="RequestType" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="CustomerPONumber" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string" /> </s:sequence> </s:complexType> </s:schema> </wsdl:types> + <wsdl:message name="HelloWorldSoapIn"> <wsdl:part name="parameters" element="tns:HelloWorld" /> </wsdl:message> + <wsdl:message name="HelloWorldSoapOut"> <wsdl:part name="parameters" element="tns:HelloWorldResponse" /> </wsdl:message> - <wsdl:message name="GetJobsSoapIn"> <wsdl:part name="parameters" element="tns:GetJobs" /> </wsdl:message> - <wsdl:message name="GetJobsSoapOut"> <wsdl:part name="parameters" element="tns:GetJobsResponse" /> </wsdl:message> - <wsdl:portType name="Service1Soap"> - <wsdl:operation name="HelloWorld"> <wsdl:input message="tns:HelloWorldSoapIn" /> <wsdl:output message="tns:HelloWorldSoapOut" /> </wsdl:operation> - <wsdl:operation name="GetJobs"> <wsdl:input message="tns:GetJobsSoapIn" /> <wsdl:output message="tns:GetJobsSoapOut" /> </wsdl:operation> </wsdl:portType> - <wsdl:binding name="Service1Soap" type="tns:Service1Soap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="HelloWorld"> <soap:operation soapAction="http://tempuri.org/HelloWorld" style="document" /> - <wsdl:input> <soap:body use="literal" /> </wsdl:input> - <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> - <wsdl:operation name="GetJobs"> <soap:operation soapAction="http://tempuri.org/GetJobs" style="document" /> - <wsdl:input> <soap:body use="literal" /> </wsdl:input> - <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> - <wsdl:binding name="Service1Soap12" type="tns:Service1Soap"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="HelloWorld"> <soap12:operation soapAction="http://tempuri.org/HelloWorld" style="document" /> - <wsdl:input> <soap12:body use="literal" /> </wsdl:input> - <wsdl:output> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> - <wsdl:operation name="GetJobs"> <soap12:operation soapAction="http://tempuri.org/GetJobs" style="document" /> - <wsdl:input> <soap12:body use="literal" /> </wsdl:input> - <wsdl:output> <soap12:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> - <wsdl:service name="Service1"> - <wsdl:port name="Service1Soap" binding="tns:Service1Soap"> <soap:address location="http://sqlsvr1/RefrigerantComplianceService/Service1.asmx" /> </wsdl:port> - <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12"> <soap12:address location="http://sqlsvr1/RefrigerantComplianceService/Service1.asmx" /> </wsdl:port> </wsdl:service> </wsdl:definitions> This is what I have so far, but the second line returns an error and I don't think it's at all right... $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl"); $result = $client->GetJobs(array()); My goal is to make a dynamic dropdown list that connects to another one of our servers using a web service. How do I get this to return an XML file with the data that I can use to add to the drop down box?
  10. Ahhh... that actually helps! I made a big oversight and didn't even realize that our web server is not on the same network as the sql server with the data, so that makes sense I'm able to connect to it since I'm on the network, but not everyone else! I'll fix this and post back shortly.
  11. I have a web service that a co worker of mine wrote. I'm trying to connect to it and use the data from it to display selections in a selection box. It doesn't connect to the service though. The WSDL file has been created and can be displayed in the browser: http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL Here's my code: $client = new SoapClient("http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL"); $result = $client->GetJobs(); It brings up all kinds of errors: What is going on here? I tried connecting to other public web services like amazon and it works without error. Also have PHP5 and SOAP installed.
  12. I think I have a fairly simple question. I'm trying to set the values of Radio buttons, check boxes and drop down lists so my users can go back and edit the form for a certain amount of time. So far it only saves text box values I tried to implement the radio buttons in there but it doesn't work. What do I need to do so that radio buttons, check boxes and drop down list values are all saved? Javascript: <script> /** * Set a cookie * @param string cookie name * @param string cookie value * @param string cookie expiration counter in days * @param string cookie path * @param string cookie domain * @param bool secure?*/ function setCookie( name, value, expires, path, domain, secure ) { var today = new Date(); today.setTime( today.getTime() ); if ( expires ) { expires = expires * 5 * 60; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name+"="+escape( value ) + ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } /* * Get a cookie value * @param string cookie name*/ function getCookie( name ) { var start = document.cookie.indexOf( name + "=" ); var len = start + name.length + 1; if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { return null; } if ( start == -1 ) return null; var end = document.cookie.indexOf( ";", len ); if ( end == -1 ) end = document.cookie.length; return unescape( document.cookie.substring( len, end ) ); } /** * Remebers form inputs after you fill them in * @param string a prefix to prepend to all cookie names. (prevent naming conflicts)*/ function rememberFormInputs(form_id, prefix) { // get a reference to the form element with id 'form_test' var form = document.getElementById(form_id); // get all child input elements of the form var els = document.getElementsByTagName('input'); // iterate through all form child input elements for (var i = 0; i < els.length; i++) { // this is the element with index of i var el = els.item(i); // make sure this is a text input field if (el.type == 'text') { // event handler to catch onblur events // it sets the cookie values each time you move out of an input field el.onblur = function() { // this is the name of the input field var name = this.name; // this is the value of the input field var value = this.value; // set the cookie setCookie( prefix + name, value); alert('setCookie: '+name + ' = '+value); }; // this inserts all the remembered cookie values into the input fields var old_value = getCookie(prefix + el.name); if (old_value && old_value != '') { alert('old value remembered: '+old_value); el.value = old_value; } } // make sure this is a text input field if (el.type == 'radio') { // event handler to catch onblur events // it sets the cookie values each time you move out of an input field el.onblur = function() { // this is the name of the input field var name = this.name; // this is the value of the input field var value = this.value; // set the cookie setCookie( prefix + name, value); alert('setCookie: '+name + ' = '+value); }; // this inserts all the remembered cookie values into the input fields var old_value = getCookie(prefix + el.name); if (old_value && old_value != '') { alert('old value remembered: '+old_value); el.value = old_value; } } } } // function will be run after window/document loads window.onload = function() { rememberFormInputs('form_test', 'input-'); } // overload alert function alert(str) { var el = document.getElementById('alert'); if (el) { el.value += str+"\r\n"; } } </script> HTML: <select name="Refrigerant_Type" > <option value="">Please Select Refrigerant Type</option> <option value="R-22">R-22</option> <option value="R-410 A">R-410 A</option> <option value="R-134 A">R-134 A</option> <option value="R-409 A">R-409 A</option> <option value="R-418 A">R-418 A</option> <option value="R-404 A">R-404 A</option> </select> <br /> <input type="text" name="Lubricant" /> <br /> <input type="radio" value="Comfort" name="Duty" class="radio" /> Comfort <input type="radio" value="Commercial" name="Duty" class="radio" /> Commercial <input type="radio" value="Under" name="Duty" class="radio" /> Under 50lbs <input type="radio" value="Other" name="Duty" class="radio" /> Other <br /> <input type="checkbox" name="New1" value="Yes" /> New<br /> <input type="checkbox" name="RecoveredNew1" value="Yes" /> Recovered<br />
  13. wow, that was a lot simpler than what I previously had. Thanks a bunch! I may have a few more questions once I begin pulling from an actual xml web service, but this is great!
  14. Just learning so bear with me.... I want to create a drop down box with values that are pulled from an xml file. I can get the drop down box and the names to be placed within the box right, but I can't get the name of the option to be the value within the drop down box, so instead of NUM it would be the color that the <option> tag surrounds.... For example: <select><option>Please Select</option><option [color=red]value='COLORS'[/color]> <option value='NUM'>red</option> <option value='NUM'>blue</option> <option value='NUM'>yellow</option> <option value='NUM'>green</option> <option value='NUM'>purple</option> <option value='NUM'>orange</option> <option value='NUM'>banana</option> </option></select> Here's my xml: <?xml version="1.0"?> <colors> <num>red</num> <num>blue</num> <num>yellow</num> <num>green</num> <num>purple</num> <num>orange</num> <num>banana</num> </colors> Here's my php file: <?php // The XML file that you wish to be parsed $file = "xml_beginner.xml"; // This function tells the parser what to do with the data once it reaches the contents // that appear between tags. echo "<select><option>Please Select</option>"; function contents($parser, $data){ echo $data; } // This function tells the parser to place a <b> where it finds a start tag. function startTag($parser, $data){ echo "<option value='$data'>"; } // And this function tells the parser to replace the end tags with "<b><br />" function endTag($parser, $data){ echo "</option>"; } // These lines create the parser and then set the functions for the parser to use when // reading the document. $xml_parser = xml_parser_create(); // Sets the functions for start and end tags xml_set_element_handler($xml_parser, "startTag", "endTag"); // Sets the function for the contents/data xml_set_character_data_handler($xml_parser, "contents"); // Opens the file for reading $fp = fopen($file, "r"); // Read the file and save its contents as the variable "data" $data = fread($fp, 80000); // This if statement does two things. 1) it parses the document according to our // functions created above. 2) If the parse fails for some reason it returns an // error message and also tells us which line the error occured at. if(!(xml_parse($xml_parser, $data, feof($fp)))){ die("Error on line " . xml_get_current_line_number($xml_parser)); } // Free the memory used to create the parser xml_parser_free($xml_parser); // Close the file when you're done reading it fclose($fp); echo "</select>"; ?>
  15. $receiver = "myemail@myhost.com, myemail2@myhost.com";
  16. Well, I've figured it out. I appreciate your help. If it weren't for your posts I never would have got on the right track... // write the file out 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); } fclose($fp); exec('pdftk Refrigerant_Information_Compliance_Form.pdf fill_form '.$fdf_file.' output '.$pdf_file.' flatten'); echo $fdf_file; } else{ echo 'You did not submit a form.'; } I was overcomplicating it with the other code, it's not even needed. Since my first code had already created the .fdf file all you have to do is run the fdf name as a variable and place it in the exec() statement and pdftk takes care of the rest. I did the same with the pdf name as I didn't want two pdf's of the same name. Thank you for your help again!
  17. I've tried running it from the command line and it does work. It outputs the file into the same folder.. I ran it from the command line using some dummy files and it worked... pdftk testform.pdf fill_form testfdf.fdf output itworked.pdf flatten How can I get it so that php will take the fdf file that it created and stick it in there so that it outputs my pdf? ahh, this is so frustrating I feel like it's so close, but still so far....
  18. I tried switching the slashes, but then it throws a parse error on the line that the slash is in... here's what I tried and neither work... pdf_fdf::FDF2PDF($fdf_dir.'\'.$fdf_file); pdf_fdf::FDF2PDF($fdf_dir.\.$fdf_file); $FilePDF_Ref is the location of the pdf file that has the text fields laid on top of it for formatting. $FilePDF_Ref = Refrigerant Information Compliance Form.pdf
  19. Bump for help. I think I'm getting close, but still need a push...
  20. Well I don't get any errors anymore , but there is only the fdf file that I was getting before I ran it through the converter.... I echoed out the variables to see their values and it looks like the path is messed up... but maybe I'm wrong... part of submissiontest.php: //Laod FDF $FilePDF_In=self::Load($FileFDF,TRUE); //Prepare the name of the PDF $FilePDF_Ref=basename($FileFDF); //Find the name of the output file if (!$FilePDF_Out) {$FilePDF_Out=str_replace(".fdf",".pdf",$FileFDF);} //Retrieve the PDF if ($FilePDF_Ref AND !file_exists($FilePDF_Ref)) {copy($FileFDF,$FilePDF_Ref);} //Empty the old version of PDF if it exists if ($FilePDF_Out AND file_exists($FilePDF_Out)) {unlink($FilePDF_Out);} //Converted exec("pdftk $FilePDF_Ref fill_form $FileFDF output $FilePDF_Out"); //This is where the variables are echoed out to see the values.... echo ("<br />$FilePDF_Out <br /> $FileFDF <br />$FilePDF_Ref"); return $FilePDF_Out; } displays this: here's my submit_form.php code if you need to see that as well... require_once 'submissiontest.php'; // write the file out if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')){ fwrite($fp,$fdf_data,strlen($fdf_data)); //pdf_fdf::FDF2PDF($fdf_dir.'/'.$fdf_file); //pdf_fdf::FDF2PDF('fileName.fdf'); echo $fdf_file,' written successfully.'; }else{ die('Unable to create file: '.$fdf_dir.'/'.$fdf_file); } fclose($fp); pdf_fdf::FDF2PDF($fdf_dir.'/'.$fdf_file); } else{ echo 'You did not submit a form.'; }
  21. yep, you were right about that one... Let me just say again how much I really do appreciate you helping me out like this. It's getting there, but now it receives this error on line 161: Warning: copy(Array) [function.copy]: failed to open stream: No such file or directory in C:\******\submissiontest.php on line 163 successfullaura.fdf written successfully.successful Here's the line of code: //Retrieve the PDF if ($FilePDF_Ref AND !file_exists($FilePDF_Ref)) {copy($FilePDF_In,$FilePDF_Ref);}
  22. Well it runs, but there is an error... Warning: basename() expects parameter 1 to be string, array given in "C:\****\submissiontest.php" on line 155 successfullaura.fdf written successfully.successful This is line 155: //Prepare the name of the PDF $FilePDF_Ref=basename($FilePDF_In); I thought it was only passing the serviced by and date string?
  23. I tried to contact the creator of the class, but the email address is no longer valid... Thanks for helping me even though you may not know much about it... Where would I put this at? pdf_fdf::FDF2PDF('fileName.fdf'); Here's what runs after the user submits the form.... <?php // check that a form was submitted if(isset($_POST) && is_array($_POST) && count($_POST)){ // we will use this array to pass to the createFDF function $data=array(); // This displays all the data that was submitted. You can // remove this without effecting how the FDF data is generated. echo'<pre>POST '; print_r($_POST);echo '</pre>'; // if(isset($_POST['Serviced_By'])){ // the name field was submitted $pat='`[^a-z0-9\s]+$`i'; // if(empty($_POST['Serviced_By']) || preg_match($pat,$_POST['Serviced_By'])){ // no value was submitted or something other than a // number, letter or space was included // die('Invalid input for Serviced_By field.'); //}else{ // if this passed our tests, this is safe $data['Serviced_By']=$_POST['Serviced_By']; $data['VoltsPHHZ']=$_POST['VoltsPHHZ']; $data['Charge_lbs']=$_POST['Charge_lbs']; $data['Charge_Oz']=$_POST['Charge_Oz']; $data['Method_Used']=$_POST['Method_Used']; $data['Refrigerant_Type']=$_POST['Refrigerant_Type']; // I wanted to add the date to the submissions $data['Date']=date('m-d-Y'); // if we got here, the data should be valid, // time to create our FDF file contents // need the function definition require_once 'createFDF.php'; // some variables to use // file name will be <the current timestamp>.fdf $fdf_file=$_POST['Serviced_By'].'-'.date('d-m-Y').'.fdf'; // the directory to write the result in $fdf_dir=dirname(__FILE__).'/results'; // location of pdf to write to... $pdf_doc='../Refrigerant Information Compliance Form.pdf'; // generate the file content $fdf_data=createFDF($pdf_doc,$data); // this is where you'd do any custom handling of the data // if you wanted to put it in a database, email the // FDF data, push it back to the user with a header() call, etc. // write the file out 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); } fclose($fp); } else{ echo 'You did not submit a form.'; } ?>
  24. 1. Here's the whole class. I just don't know how to implement it into my code... class pdf_fdf { /** * make a file FDF * * @param string $FichierIn Name PDF file reference * @param array $Data1 List of variables to include * @param array $Data2 List of variables to include unprotected * @return FDF */ public static function Make($FichierIn,$Data1,$Data2="") { $Out = "%FDF-1.2\n%????\n"; $Out .= "1 0 obj \n<< /FDF << /Fields [\n"; if ($Data1) { foreach ($Data1 as $DataKey=>$DataVal) { $DataVal=str_replace("\r\n","\n",$DataVal); $DataVal=str_replace("\r" ,"\n",$DataVal); $Out.= "<< /T (".addcslashes($DataKey,"\n\r\t\\()").") /V (".addcslashes($DataVal,"\n\r\t\\()").") >> \n"; } } if (is_array($Data2)) { foreach ($Data2 as $DataKey=>$DataVal) { $DataVal=str_replace("\r\n","\n",$DataVal); $DataVal=str_replace("\r" ,"\n",$DataVal); $Out.="<< /T (".addcslashes($DataKey,"\n\r\t\\()").") /V /".$DataVal." >> \n"; } } $Out.= "]\n/F ($FichierIn) >>"; $Out.= ">>\nendobj\ntrailer\n<<\n"; $Out.= "/Root 1 0 R \n\n>>\n"; $Out.= "%%EOF"; return $Out; } /** * Save a file FDF * * @param string $FichierIn Name PDF file reference * @param array $Data Fields * @param string $FichierOut Name File final * @return bool */ public static function Save($FichierIn,$Data,$FichierOut) { if ($FId=fopenw($FichierOut,'w')) { $Data=self::Make($FichierIn,$Data); fwrite($FId,$Data,strlen($Data)); $Out=TRUE; } else {$Out=FALSE;} return $Out; } /** * Load a file FDF * * @param string $Fichier File to analyse * @param bool $PDF Type of file (PDF | FDF) * @return string */ public static function Load($Fichier,$PDF=FALSE) { $Out=array(); if ((file_exists($Fichier))and($Fichier>'')) { $Data=File($Fichier); if ($PDF) { $Nb=count($Data); for ($i=4;$i<$Nb;$i++) { $DataOut=array(); if(eregi("/F \(([^)]*)\)",$Data[$i],$DataOut)) { $Out=$DataOut[1]; break; } } } else { $Nb=count($Data)-9; for ($i=4;$i<$Nb;$i++) { $DataOut=array(); $In=$Data[$i]; $In=str_replace('\)','§PF§',$In); $In=str_replace('\r\n',EOL,$In); $In=str_replace('\n',EOL,$In); $In=str_replace('\r',EOL,$In); $In=stripslashes($In); eregi("/T \(([^)]*)\) /V \(([^)]*)\)",$In,$DataOut); $Out[$DataOut[1]]=str_replace("§PF§",")",$DataOut[2]); } } } return $Out; } /** * Transform an FDF PDF * * @param string $FileFDF Filename a PDF transfrmer * @param string $FilePDF_Out Filename of output * @return string */ public static function FDF2PDF($FileFDF,$FilePDF_Out='') { //Laod FDF $FilePDF_In=self::Load($FileFDF,TRUE); //Prepare the name of the PDF $FilePDF_Ref=basename($FilePDF_In); //Find the name of the output file if (!$FilePDF_Out) {$FilePDF_Out=str_replace(".fdf",".pdf",$FileFDF);} //Retrieve the PDF if ($FilePDF_Ref AND !file_exists($FilePDF_Ref)) {copy($FilePDF_In,$FilePDF_Ref);} //Empty the old version of PDF if it exists if ($FilePDF_Out AND file_exists($FilePDF_Out)) {unlink($FilePDF_Out);} //Converted exec("pdftk $FilePDF_Ref fill_form $FileFDF output $FilePDF_Out"); echo ("successful"); return $FilePDF_Out; } /** * HTML header for FDF * */ public static function Header() { header('Content-type: application/vnd.fdf'); //header( "Content-type: application/vnd.adobe.xfdf"); } } 2. I also have the pdftk.exe saved to my c:/ on my server. 3. Could you please explain how to pass the filename through here? I appreciate it so much, this would be a huge help to me.
  25. Here is my code that creates the fdf data... // write the file out 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); } fclose($fp); Now how would I take the variable that contains the fdf data ($fdf_data) and convert it into a pdf? I found this piece of code that will convert it, but don't know how to implement it: function FDF2PDF($FileFDF,$FilePDF_Out='') { //Laod FDF //$FilePDF_In=self::Load($FileFDF,TRUE); //Prepare the name of the PDF $FilePDF_Ref=basename($FilePDF_In); //Find the name of the output file if (!$FilePDF_Out) {$FilePDF_Out=str_replace(".fdf",".pdf",$FileFDF);} //Retrieve the PDF if ($FilePDF_Ref AND !file_exists($FilePDF_Ref)) {copy($FilePDF_In,$FilePDF_Ref);} //Empty the old version of PDF if it exists if ($FilePDF_Out AND file_exists($FilePDF_Out)) {unlink($FilePDF_Out);} //Converted exec("pdftk $FilePDF_Ref fill_form $FileFDF output $FilePDF_Out"); return $FilePDF_Out; }
×
×
  • 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.