SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Mar 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CFDocument - How to make html formatting table etc appear in pdfs???

    Hi,
    I have some code with nice formatting i.e table with stylesheets applied and data is stored in a variable.

    This var is shown to user on the page as the var contains table with nice formatting (is this a good approach i.e. storing it in var?) and If user wants pdf, then he can view the data in pdf format. The problem is the table styles are lost in pdf and it just shows plain text in white background.

    1)Is there a way I could have the pdf display the table with all the styles I have applied to it????

    2)How can I have the Image shown on every page on the top. Right now with my code, the img is shown on the first page only...

    Here is the code :

    Code:
    <cfsavecontent variable="Report_StateRegs">
       <cfoutput query="StateRegs" group="Reg_Name">		
           <table class="tableStRegs" align="center">
           ......
           </table>
       </cfoutput>
    </cfsavecontent>
    
    
    <cfif URL.view eq "Reports_State">
    <cfdocument marginbottom="0.75" marginleft="0.75" marginright="0.75"
    margintop="0.75" format="pdf" unit="in" backgroundvisible="yes">
      <img src="/images/A_Watermark.gif"  width="120" height="49"
     align="absmiddle"/>
    
    <cfoutput> #Report_StateRegs#</cfoutput>
    
    </cfdocument>
    
    <cfelse>
        <cfoutput>#Report_StateRegs#</cfoutput>
    </cfif>
    Any suggestions are welcome.

    Thanks in advance

  2. #2
    SitePoint Addict
    Join Date
    Mar 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its amazing how you can get to solution sometimes. Its just 10 mins since My first post and I already have a solution. Here you go :

    <cfdocument marginbottom="0.75" marginleft="0.75" marginright="0.75"
    margintop="0.75" format="pdf" unit="in" backgroundvisible="yes">

    <style type="text/css">
    @import url(/css/custom.css);
    @import url(/css/default.css);
    </style>

    <cfdocumentitem type="header">
    <img src="/images/A_Watermark.gif" width="120" height="49" align="right">
    </cfdocumentitem>

    <!---Use a footer with current page of totalpages format --->
    <cfdocumentItem type= "footer">
    <cfoutput>
    <em style="text-align:center">#cfdocument.currentpagenumber# of #cfdocument.totalpagecount#
    </em>
    </cfoutput>
    </cfdocumentItem>
    <cfoutput> #Report_StateRegs#</cfoutput>
    </cfdocument>

    <cfelse>
    <cfoutput>#Report_StateRegs#</cfoutput>
    </cfif>

    Now only thing remaining is
    1) center the img in pdf( iam able to align right only and when I say absmiddle or middle, it doesnt work)
    2)align page footer to center. I am trying text-align:center but it didnt work.

    I am so happy I have it working ...woohoo...

    Thanks,


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •