How to add approved stamp in Cover Page in ColdFusion

155 Views Asked by At

I need some help on ColdFusion I am trying to create a Cover Page and then add Approved Stamp next to the Reviewer. However, I can able to add the stamp on the page but not next to the Reviewer. Here is the ColdFusion code.

<cfset sourcefile = "E:\http\docs\psdr\sample.pdf">
<cfset destinationfile = "E:\http\docs\psdr\sample_output.pdf">

<cfset cur_event_date  =  DateFormat(now(), "mm/dd/yyyy")> 
<cfset cur_event_time =  TimeFormat(now(), "hh:mm tt")> 
<cfset reviewList = "Electrical Engineering Review, Mechanical Engineering Review
, Management Approval">

<cfdocument format="PDF" name="coverPage"> 
    <html> 
        <body> 
            <h1>Reviewers Approval</h1> 
            <table class="table" border="0" cellspacing="2" cellpadding="2">
                <thead>
                    <tr>
                        <th scope="col">Step</th>
                        <th scope="col">Action</th>
                        <th scope="col">Name</th>
                        <th scope="col">Date</th>
                        <th scope="col">Time</th>
                        <th scope="col">Comments</th>
                    </tr>
                </thead>
                <tbody>
                    <cfloop list="#reviewList#" index="reviewers">
                        <cfoutput>
                            <tr>
                                <td>#reviewers#</td>
                                <td></td>
                                <td></td>
                                <td>#cur_event_date#</td>
                                <td>#cur_event_time#</td>
                                <td></td>
                            </tr>
                        </cfoutput>
                        <br>
                    </cfloop>
                </tbody>
            </table>
        </body> 
    </html> 
</cfdocument>

<cfpdf action="addStamp" source="coverPage" overwrite="yes">
    <cfpdfparam pages="1" coordinates="397,532,519,564" iconname="Approved"/> 
</cfpdf>

<cfpdf action="addStamp" source="#sourcefile#" destination="#destinationfile#" overwrite="yes" >
    <cfpdfparam pages="1" coordinates="397,532,519,564" iconname="Approved" 
                note="on #dateTimeFormat(now(), 'yyyy/mm/dd HH:nn')#"/> 
</cfpdf>

<cfpdf action="merge" destination="#destinationfile#" overwrite="yes">
    <cfpdfparam source="coverPage"> 

    <cfpdfparam source="#destinationfile#"/> 
</cfpdf>

<h1>Add Stamp</h1> 

Right now there is no guidelines/requirement to use any particular HTML but since this being a Cover Page all I need to do is create a list and add stamp next to the reviewer. We can use the grid, table any format is fine, and anyway is fine like deleting pages from existing PDF and then creating using cfdocument.

1

There are 1 best solutions below

0
On

Thanks for your suggestions. I implemented it by using img in the td element. Here goes the code.

<cfset sourcefile = "E:\http\docs\psdr\sample.pdf">
<cfset destinationfile = "E:\http\docs\psdr\sample_output.pdf">

<cfset cur_event_date  =  DateFormat(now(), "mm/dd/yyyy")> 
<cfset cur_event_time =  TimeFormat(now(), "hh:mm tt")> 
<cfset reviewList = "Electrical Engineering Review, Mechanical Engineering Review
, Management Approval">

<link rel="stylesheet" type="text/css" href="../util/reportdisplay.css"></link>

<cfdocument format="PDF" name="coverPage" localUrl = "yes"> 
    <html> 
        <body> 
            <h1>Reviewers Approval</h1> 
            <table class="table" border="0" cellspacing="2" cellpadding="2">
                <thead>
                    <tr>
                        <th scope="col">Step</th>
                        <th scope="col">Action</th>
                        <th scope="col">Name</th>
                        <th scope="col">Date</th>
                        <th scope="col">Time</th>
                        <th scope="col">Comments</th>
                    </tr>
                </thead>
                <tbody>
                    <cfloop list="#reviewList#" index="reviewers">
                        <cfoutput>
                            <tr>
                                <td>#reviewers#</td>
                                <td><img src="https://mesdev.intranet.cnb/e/images/approved_stamp.JPG" width="120" height="38"></td>
                                <td>Reviewed</td>
                                <td>#cur_event_date#</td>
                                <td>#cur_event_time#</td>
                                <td></td>
                            </tr>
                        </cfoutput>
                        <br>
                    </cfloop>
                </tbody>
            </table>
        </body> 
    </html> 
</cfdocument>


<cfpdf action="addStamp" source="#sourcefile#" destination="#destinationfile#" overwrite="yes" >
    <cfpdfparam pages="1" coordinates="397,532,519,564" iconname="Approved" 
                note="on #dateTimeFormat(now(), 'yyyy/mm/dd HH:nn')#"/> 
</cfpdf>

<cfpdf action="merge" destination="#destinationfile#" overwrite="yes">
    <cfpdfparam source="coverPage"> 

    <cfpdfparam source="#destinationfile#"/> 
</cfpdf>