PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,177 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,573 people online right now. Registration is fast and FREE... Join Now!




How to convert Coldfusion Source Code into PHP

 

How to convert Coldfusion Source Code into PHP

siva_mutyam

14 Oct, 2007 - 04:15 AM
Post #1

New D.I.C Head
*

Joined: 14 Oct, 2007
Posts: 2


My Contributions
CODE
<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! mad.gif

This post has been edited by snoj: 14 Oct, 2007 - 10:28 AM

User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 2)

PsychoCoder

RE: How To Convert Coldfusion Source Code Into PHP

14 Oct, 2007 - 07:57 AM
Post #2

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 14,939



Thanked: 519 times
Dream Kudos: 11575
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
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.
User is offlineProfile CardPM
+Quote Post

snoj

RE: How To Convert Coldfusion Source Code Into PHP

14 Oct, 2007 - 10:30 AM
Post #3

Now with 10% more nom!
Group Icon

Joined: 31 Mar, 2003
Posts: 3,388



Thanked: 31 times
Dream Kudos: 775
My Contributions
And posting code is not a question.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 07:33PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month