3 Replies - 8289 Views - Last Post: 09 April 2010 - 12:55 AM Rate Topic: -----

#1 siva_mutyam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-October 07

How to convert Coldfusion Source Code into PHP

Posted 14 October 2007 - 05:15 AM

<cfif NOT isdefined("form.submit")>

   <cfform enctype="multipart/form-data">
	  <strong>PDF*:</strong><cfinput type="file" name="pdfFile" required="yes"><br />
	  <strong>JPG*:</strong><cfinput type="file" name="jpgFile" required="yes"><br />
	  New file name:<cfinput type="text" name="newFile"><br />
	  X:<cfinput type="text" name="x" size="2" validate="integer">/Y:<cfinput type="text" name="y" size="2" validate="integer"><br />
	  <cfinput type="submit" name="submit" value="submit">
   </cfform>

<cfelse>

   <!--- Set defualt position --->
   <cfif not isnumeric(form.x)>
	  <cfset form.x = 0>
   </cfif>
   <cfif not isnumeric(form.y)>
	  <cfset form.y = 0>
   </cfif>


   <!--- Upload PDF file --->
   <cffile action="upload" destination="#expandpath('.')#" filefield="pdfFile" nameconflict="makeunique">
   <cfset pdfFileName = file.ServerFile>
   <cfif not len(trim(form.newFile))>
	  <cfset form.newFile = "#listfirst(pdfFileName,'.')#_signed.pdf">
   </cfif>

   <!--- Upload JPG file --->
   <cffile action="upload" destination="#expandpath('.')#" filefield="jpgFile" nameconflict="makeunique">
   <cfset jpgFileName = file.ServerFile>

   <CFSCRIPT>
   ///////////////////////////////////////////////////////////////	// This function applies a jpg watermark to an existing PDF	// pdfFile - Relative path to pdf file	// jpgFile - Relative path to jpg file	// newFile - name of new PDF file	// x - horizontal position from bottom left of pdf	// y - vertical position from bottom left of pdf	//
   // Author: Shlomy Gantz	//
		 
   watermarkPDF(pdfFileName,jpgFileName,form.newFile,form.x,form.y);	  
			   
   function watermarkPDF(pdfFile,jpgFile,newFile,x,y) {
			   
			   // get original document				reader = CreateObject("java", "com.lowagie.text.pdf.PdfReader").init(expandpath(arguments.pdfFile));
			   // create new document				fileIO = CreateObject("java", "java.io.FileOutputStream").init(expandpath(arguments.newFile));
			   // initiliza stamper				stamper= CreateObject("java", "com.lowagie.text.pdf.PdfStamper").init(reader,FileIO);
			   // create watermark images				
			   Image		  = CreateObject("java", "com.lowagie.text.Image");
			   jpg		  = Image.getInstance(expandpath(arguments.jpgFile));
			   jpg.setAbsolutePosition(arguments.x, arguments.y);
				  
			   // stamp all pages with watermark				i = 0;
			   n = reader.getNumberOfPages();
			   
			   while (i lt n) {
						i=i+1;

						b = stamper.getUnderContent(javacast("Int",i)); 
						b.addImage(jpg);
					 }
		 
			   stamper.close();

			   }
   
   

   </CFSCRIPT>
   
   <cfoutput>
   <a href="#form.newFile#">Click here to download the signed PDF</a>
   </cfoutput>

</cfif>


[cod edit] Use Code tags! :angry:

This post has been edited by snoj: 14 October 2007 - 11:28 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to convert Coldfusion Source Code into PHP

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to convert Coldfusion Source Code into PHP

Posted 14 October 2007 - 08:57 AM

First and foremost, always use code tags, you highlight your code and press the button with the # on it in the above toolbar. Second, the only way to convert ColdFusion code to PHP is to rewrite it, theres no ColdFusion to PHP Converter out there.
Was This Post Helpful? 0
  • +
  • -

#3 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: How to convert Coldfusion Source Code into PHP

Posted 14 October 2007 - 11:30 AM

And posting code is not a question.
Was This Post Helpful? 0
  • +
  • -

#4 m.sharma  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-April 10

Re: How to convert Coldfusion Source Code into PHP

Posted 09 April 2010 - 12:55 AM

How to convert coldfusion code to php
<cfset emailRecipient = "XXXX">
<cfset requestUrl = "http://XXXXXX/newusr.pl">
<cfparam name="requestIp" default="#cgi.remote_addr#">
<cfparam name="requestUser" default="NewUserInfo">

<cftry>
	<cfhttp url="#requestUrl#" method="post">
		<cfhttpparam name="ip" type="url" value="#requestIp#">
		<cfhttpparam name="user" type="url" value="#requestUser#">
	</cfhttp>
	<!----<cfoutput>#CFHTTP.FileContent#</cfoutput>--->
	
	<cfcatch type="ANY">
		<cfif isdefined("CFHTTP.ErrorDetail")>
			<cfset moreErrorDetails="#CFHTTP.ErrorDetail#">
		<cfelse>
			<cfset moreErrorDetails="">
		</cfif>
		
		<!---Free Account was not created auto on Filter side. Create it now manually--->
		
		<cfmail from="XXXXX" to="XXXX" subject="Error with filter.">
URL: #requestUrl#
URL.ip: #requestIp#
URL.user: #requestUser#

<cfif moreErrorDetails neq "">
Error Details: #moreErrorDetails#
</cfif>
		</cfmail>
		
		
	</cfcatch>	
</cftry>

This post has been edited by JackOfAllTrades: 09 April 2010 - 05:19 AM
Reason for edit:: Added code tags.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1