Skip to main content
Inspiring
August 7, 2009
Question

CFDOCUMENT: Creating a div that is 8.5 x 11 inches.

  • August 7, 2009
  • 2 replies
  • 3420 views

I am trying to get a layout to work with cfdocument. I created a very simply HTML page with a div that is set to 8.5 x 11 inches. So why when I try to create a PDF out of it does it not span the page? I don't get it at all. My Code is below, and attached is a screen shot of the output. This should be so simple.... What am I missing? Adobe?


<cfsavecontent variable="page">
<cfoutput>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css">
            body
               {
                    margin:0in;
                    padding:0in;
               }
              
              
               .mypage
            {
                background: white;
                    border:1px solid ##dbdbdb;
                   height: 11in;
                width: 8.5in;

            }
              
               .header
               {
                    font-family:arial;
                    color:white;
                    font-size:.18in;
                    padding:.2in;
               }
        </style>
    </head>
    <body>

          <div class="mypage">
              
               <div style="background:green;width:100%;">
                    <span class="header">
                    I am a header inside a div that should span the page!
                    </span>
               </div>
              
          </div>
   </body>
</html>
</cfoutput>
</cfsavecontent>

<cfoutput>
     <cfdocument
          fontembed           = "yes"
          marginbottom              = "0"
          marginleft           = "0"
          marginright              = "0"
          margintop           = "0"
          pagetype          = "letter"
          unit               = "in"
          format               = "pdf">

          <cfdocumentsection>
             #page#
          </cfdocumentsection>
     </cfdocument>
</cfoutput>

I know I could set the div to 100%, but I need a specific width when creating the layout.... So I should be able to set it to 8.5 no??

cfdocument.jpg

    This topic has been closed for replies.

    2 replies

    brookdAuthor
    Inspiring
    August 7, 2009

    I tried your code and no dice. I tried on a CF8 licensed server instead of the developer version and no dice. I did notice that your version number is different, I'm using '8,0,0,176276'. I have downloaded and am installing the latest updater available to see if that makes any difference...

    brookdAuthor
    Inspiring
    August 7, 2009

    Hallelujah! Running the latest updater, now at '                                     8,0,1,195765' actually fixed the problem! Its pretty hard to believe that up until the latest updater that an 8.5 inch div was not really an 8.5 inch div. I mean, wouldn't / shouldn't this have been pretty close to a test case for cfdocument.

    Anyways, alls well that ends well. I'll just write off the 3+ hours I spent messing with this...

    Inspiring
    August 7, 2009

    brookd wrote:

    I mean, wouldn't / shouldn't this have been pretty close to a test case for cfdocument;-)

    To my way of thinking, parsing and interpreting html, css, malformed tags, in line styles, etcetera, then converting it all to pdf terms is a monumental task.  I am amazed it works as well as it does. But yes, it would be nice if it worked perfectly all the time  ;-)

    Anyway, I am glad everything is working now.

    Inspiring
    August 7, 2009

    Both your example here and on HOF work fine for me with 8,0,1,195765.  Granted I did move replace the in-line styles with class names for consistency.  If that makes any difference ..

    <cfsavecontent variable="page">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
         <title></title>
        <style type="text/css">
        body
        {
             margin:0in;
            padding:0in;
         }
        .mypage
        {
             background: white;
            border:1px solid ##dbdbdb;
            height: 11in;
            width: 8.5in;
            position:absolute;
            overflow:hidden;
              border:1px solid black;
         }
         .header
         {
              font-family:arial;
              color:white;
              font-size:.18in;
         }
         .headerBox
         {
              background:green;
              width:100%;
              padding:.2in;    
         }
    </style>

    </head>
    <body>
          <div id="page1" class="mypage">  
                <div class="headerBox">
                      <span class="header">
                      This is a test Page
                      </span>
                </div>          
          </div>
       </body>
    </html>
    </cfsavecontent>

    Inspiring
    August 7, 2009

    Drat. The code was mangled. Let us try this again

    <cfsavecontent variable="page">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css">
        body
        {
            margin:0in;
            padding:0in;
        }
        .mypage
        {
            background: white;
            border:1px solid ##dbdbdb;
            height: 11in;
            width: 8.5in;
            position:absolute;
            overflow:hidden;
            border:1px solid black;
        }
        .header
        {
            font-family:arial;
            color:white;
            font-size:.18in;
        }
        .headerBox
        {
            background:green;
            width:100%;
            padding:.2in;   
        }
    </style>

    </head>
    <body>
          <div id="page1" class="mypage">  
                <div class="headerBox">
                      <span class="header">
                      This is a test Page
                      </span>
                </div>          
          </div>
       </body>
    </html>
    </cfsavecontent>

    <cfoutput>
    <cfdocument
                fontembed         = "yes"
                marginbottom      = "0"
                marginleft        = "0"
                marginright       = "0"
                margintop         = "0"
                pagetype          = "custom"
                pagewidth         = "8.5"
                pageheight        = "11"
                unit              = "in"
                format            = "pdf">
                <cfdocumentsection>
                   #page#
                </cfdocumentsection>

          </cfdocument>
    </cfoutput>