Thursday, May 21, 2009

Default on bit column in sql.

alter table tablename
add constraint DF_tablename_columnname default ((0)) for columnname

Monday, May 18, 2009

Merging cfdocuments into pdf without creating a file

So I was working with a dms and wanted to try not writing and reading pdf files but instead using the cf and db to display the data. I struggled with invoking cfpdfparam source attribute on cfpdf action="merge" because it doesn't take straight up binary, which is what cfdocument is returning. So I created a pointer variable and passed that in and it accepted. Kinda wierd it wouldn't accept it but oh well. Check it out.


<!--- get the pages --->
<cfset pages = beans.docService.getPagesByVersionID(versionID=versionID)/>

<!--- create array to hold cfdocuments --->
<cfset documents = []/>

<!--- loop pages and create cfdocuments --->
<cfloop query="pages">

<cfdocument name="pdf_name" format="pdf" pageheight="#pages.height#" pagewidth="#pages.width#" pagetype="#pages.doc_page_type_Name#" orientation="pages.document_orientation_type_name#">

<!--- get the page layout --->
<cfset layout[id] = beans.docService.getLayoutByID(pages.layout_id) />

<!--- get xmltransform--->
<cfsilent>
<cfset html[id] = xmltransform(xml,layout[id].xslt) />
</cfsilent>

<!--- set margins --->
<cfdocumentsection
marginbottom="#pages.bottom_margin#"
marginleft="#pages.left_margin#"
marginright="#pages.right_margin#"
margintop="#pages.top_margin#">

<!--- output data --->
<cfoutput>#html[id]#</cfoutput>

</cfdocumentsection>

</cfdocument>

<!--- add binary cfdocument to the --->
<cfset arrayappend(documents,pdf_name) />

</cfloop>


<!--- merge cfdocuments into 1 pdf. this will return some binary --->
<cfpdf action="merge" name="final">

<cfloop from="1" to="#arraylen(documents)#" index="i">

<!--- set pointer for cfpdfparam source, this part took me forever to figure out because the source attribute is looking for a pointer variable. you can't just pass in the binary --->
<cfset pointer = documents[i]/>

<cfpdfparam source="pointer">

</cfloop>

</cfpdf>

<!--- output the pdf --->
<cfcontent type="application/pdf" variable="#tobinary(final)#" reset="No" >

Wednesday, May 13, 2009

The litte things

As I logged into my bank accounts online I realized how much of the little things are missing from a page. Details such as label tags on radio and checkboxes, titles on links, and directions steps in a wizard are just to name a few. When working with presentation, people remember every little detail. So remember to think of the little things.