+ Start a Discussion
raji devi 1raji devi 1 

Block blocks in table when visualforce render to PDF

Hi All, 
I am generating a pdf . the content on  the pdf is dynamic images of different products.In my code i have two tables.
i want to fit the content of one page , but in my pdf content is going to other page .My all product images are >=150px.
I used CSS class to fix the table but i am getting black color blocks at end of the page.
Please help me.
Thanks and Regards,
Raji
<apex:page standardcontroller="Quote" sidebar="false" showHeader="false" renderAs="pdf" applyBodyTag="false" standardStylesheets="true" >

<head>
<style type="text/css" >
@page {
/* Landscape orientation */
/* size:landscape; */
/* Portrait orientation */
size:portrait;
margin:190px 50px 60px 50px;
background:#fff;
 @top-center {
 content: element(header);
}
@bottom-left {
 content: element(footer);
}
}

<!---------by kdfld
applyHtmlTag="false" docType="html-5.0"
@media print {
    table tbody tr td:before,
    table tbody tr td:after {
        content : "" ;
        height : 4px ;
        display : block ;
    }
}
end kjksa--------->


div.footer {
    display: block;
    padding: 0px;
    position: running(footer);
    background: #fff;
    height: 75px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    padding: 10px 0 0 0;
}
div.header {
    display: block;
    position: running(header);
    background: #fff;
    height: 190px;
    padding: 0px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}
div.content {
    background: #fff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 50%;
}
.pagenumber:before {
    content: counter(page);
}
.pagecount:before {
    content: counter(pages);
}
.allFontsize {
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
"
}
  

</style>


<style>
    table.print-friendly tr td, table.print-friendly tr th {
        page-break-inside: avoid;
    }
</style>



<!------------added by raji--------------------
<style type="text/css">


 table { page-break-inside:auto }
   tr    { page-break-inside:avoid; page-break-after:auto }
.p {
        page-break-inside: avoid;
    }
   table { page-break-inside:auto }
   tr    { page-break-inside:avoid; page-break-after:auto }

</style>
<style type="text/css">


@media print {

    p {
        page-break-inside: avoid;
    }
}
</style>------------------------------------->


</head>


<div class="header">
    <apex:image value="{!$Resource.askagroupHeader}" height="186" width="700"/>
  </div>
  <div class="footer">
    <apex:image value="{!$Resource.askagroupFooter}" height="46" width="700"/>
  </div>
  <div class="content" > 
    <!-- Quote Format Start --> 
 
    <!-- Quote Format End --> 
    
    <!-- Industrial Quote Format Start-->
    <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:Arial, Helvetica, sans-serif;font-size:12px;" class="print-friendly">
      <tr>
        <td align="center" valign="middle"><h2><u>QUOTATION</u></h2></td>
      </tr>
      <tr>
        <td height="25" align="left" valign="middle">Ref: {!Quote.QuoteNumber} </td>
      </tr>
      <tr>
        <td height="25" align="left" valign="middle">Dt.:
          <apex:outputText value="{0,date,dd'/'MM'/'yyyy}">
            <apex:param value="{!Quote.CreatedDate}"/>
          </apex:outputText></td>
      </tr>
      <tr>
        <td height="30" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle"><u>Company Name &amp; Address</u></td>
      </tr>
      <tr>
        <td align="left" valign="middle">Address Line1: {!Quote.BillingName} </td>
      </tr>
      <tr>
        <td align="left" valign="middle">Address Line2: {!Quote.BillingStreet} </td>
      </tr>
      <tr>
        <td align="left" valign="middle">Address Line3: {!Quote.BillingCity} </td>
      </tr>
      <tr>
        <td align="left" valign="middle">Contact Ph.: {!Quote.Phone} </td>
      </tr>
      <tr>
        <td align="left" valign="middle">Contact Mob.: {!Quote.Mobile__c} </td>
      </tr>
      <tr>
        <td align="left" valign="middle">Email: {!Quote.Email} </td>
      </tr>
      <tr>
        <td height="30" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle">Kind Attn.: {!Quote.Contact.Name} </td>
      </tr>
      <tr>
        <td align="left" valign="middle">Ref. No.: {!Quote.Ref_No__c} </td>
      </tr>
      <tr>
        <td align="left" valign="middle">Sub.: <strong>{!Quote.Name}</strong></td>
      </tr>
      <tr>
        <td height="25" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle">Dear Sir/Madam,</td>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle">We thankfully acknowledge receipt of your valued enquiry and as accordingly we are pleased to submit our formal Quotation with reference to your RFQ as under:-</td>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle"><table width="700" border="1" cellspacing="0" cellpadding="0" bgcolor="#000" style="min-width:700px;max-width:700px; ">
            <tr>
              <th align="center" valign="middle" bgcolor="#FFFFFF" height="30">Line Item</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">Product Description</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">Part Code</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">UOM</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">Qty</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">MOQ</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">Price</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">Value</th>
              <th align="center" valign="middle" bgcolor="#FFFFFF">Image</th>
            </tr>
            <apex:repeat var="lineItemObj" value="{!Quote.QuoteLineItems}">
              <tr >
                <td align="left" valign="middle" bgcolor="#FFFFFF" >{!lineItemObj.Product2.Name}</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF" ><apex:outputField value="{!lineItemObj.Product2.Description}" styleClass="p"/></td>
                <td align="left" valign="middle" bgcolor="#FFFFFF">{!lineItemObj.Product2.ProductCode}</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF" >{!lineItemObj.UOM__c}</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF" >{!lineItemObj.Quantity}</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF" >{!lineItemObj.MOQ__c}</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF">{!lineItemObj.ListPrice}</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF" >{!lineItemObj.Quote.Grand_Total__c}</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF" width="180" ><apex:outputField value="{!lineItemObj.Product2.Image__c}" style="width:200px; page-break-inside:avoid" /></td>
              </tr>
            </apex:repeat>
          </table>
          <br clear="right" />
          </td>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <th align="left" valign="middle"><em>Product Datasheet attached.</em></th>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle"><apex:outputPanel id="termsConds" rendered="{!Quote.Terms_Conditions__c}" >
            <table width="100%" border="0" cellspacing="0" cellpadding="0" >
              <tr>
                <th align="left" valign="middle" styleClass="allFontsize"><u><em>Please refer to our terms and conditions next page…</em></u></th>
              </tr>
              <tr>
                <td align="left" valign="middle">&nbsp;</td>
              </tr>
              <tr>
                <th align="left" valign="middle" styleClass="allFontsize"><u>Terms &amp; conditions</u></th>
              </tr>
              <tr>
                <td align="left" valign="middle">&nbsp;</td>
              </tr>
              <tr>
                <td align="left" valign="middle" styleClass="allFontsize"><table width="100%" border="1" cellspacing="1" cellpadding="5" bgcolor="#000000" >
                    <tr>
                      <td width="6%" align="center" valign="middle" bgcolor="#FFFFFF">1.</td>
                      <td width="18%" align="left" valign="top" bgcolor="#FFFFFF">Prices</td>
                      <td width="76%" align="left" valign="top" bgcolor="#FFFFFF"> {!Quote.Price_Term__c} <br/></td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">2.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">P&amp;F Charges</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Extra @ 2%</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">3.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Excise Duty</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Not Applicable</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">4.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Sales Tax</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF"> CST @ {!Quote.CST_Tax__c}% <br/></td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">5.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">C Form</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">If purchaser to submit Form C, then ASKA C Form Policy will be applicable. Purchaser will be required to deposit the differential tax amount to our Account, i.e., 3% in case of supply from Delhi &amp; 12.5 % in case of supply from Roorkee, along with an interest @1.25% for 6 months on the differential tax amount. <br />
                        <br />
                        Along with the Security Deposit, purchaser will also have to submit us a Declaration as per Annexure I to our Delhi Office.</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">6.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Payment Terms</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">100% Advance against PI before dispatch.</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">7.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Freight Charges</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Extra at actuals.</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">8.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Insurance</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF"> {!Quote.Insurance__c} <br /></td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">9.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Octroi / Entry Tax</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">(If applicable) Extra at actual at your end</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">10.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Road Permit/ Waybill</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">If applicable then 01 No. Road Permit/ Way Bill should be provided along with PO.</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">11.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Dispatch Period</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">{!Quote.Dispatch_Period__c}</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">12.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Warranty</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">12 months (One Year) from the date of receipt at site. Consumable items not covered.</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">13.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Validity</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">45 days from the date of our offer.</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">14.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Bank Guarantee</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">NO Bank Guarantee/ PBG will be submitted by Aska.</td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">15.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Delivery Mode</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF"> {!Quote.Delivery_Mode__c} <br /></td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">16.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Any other terms:</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">{!Quote.Any_other_terms__c} </td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" bgcolor="#FFFFFF">17.</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">Comments:</td>
                      <td align="left" valign="top" bgcolor="#FFFFFF">{!Quote.Comments__c} </td>
                    </tr>
                  </table></td>
              </tr>
            </table>
          </apex:outputPanel></td>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <th align="left" valign="middle"><u>Note:</u></th>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle" style="white-space:normal !important;"><ol type="1" >
            <li style="margin:10px 0;white-space:normal; !important;"><strong>In case of supply from Delhi, your Purchase Order &amp; Road Permit / Waybill should be addressed to: </strong><br />
              M/s. Aska Equipments Ltd., R-482, New Rajendra Nagar, Sir Ganga Ram Hospital Square, Shankar Road, New Delhi Pin – 110 060 India Phone +91 11 49458800 (30 Lines) Fax +91 11 49458844. Email: indsales@askagroup.com. </li>
            <li style="margin:10px 0;white-space:normal !important;"><strong>In case of supply from Roorkee, your Purchase Order &amp; Road Permit / Waybill should be addressed to:</strong> <br />
              M/s. Aska Equipments Ltd., Plot No. C-21, Dev Bhoomi Industrial Estate, Pohana – Iqbalpur Road, Village – Bantakhedi, Tehsil – Roorkee, Dist. Haridwar – 247 668 (Uttarakhand). </li>
            <li style="margin:10px 0;white-space:normal  !important;"><strong>PLEASE SEND YOUR ORIGINAL PURCHASE ORDER ONLY TO NEW DELHI OFFICE FOR FASTER COMMUNICATIONS.</strong><br />
              M/s. Aska Equipments Ltd., R-482, New Rajendra Nagar, Sir Ganga Ram Hospital Square, Shankar Road, New Delhi PIN – 110 060 INDIA Phone +91 11 49458800 (30 Lines) Fax +91 11 49458844 Email: indsales@askagroup.com. </li>
          </ol></td>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle">We sincerely look forward to your valued Purchase Order that will fetch our prompt and quality attention at all times.</td>
      </tr>
      <tr >
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr><!-----------------second tble-------------------------------------------------------------------->
        <td align="left" valign="middle"><table width="50%" border="0" cellspacing="0" cellpadding="5" style="border:1px solid #000; page-break-inside: avoid;" >
       

            <tr >
            
              <td width="33%" height="20" align="left" valign="middle">CIN No </td>
              <td width="4%" align="center" valign="middle">:</td>
              <td width="63%" align="left" valign="middle">U29222DL1989PLC148198</td>
            </tr>
            <tr>
              <td height="20" align="left" valign="middle">TIN No </td>
              <td align="center" valign="middle">:</td>
              <td align="left" valign="middle">05001745928</td>
            </tr>
            <tr>
              <td height="20" align="left" valign="middle">PAN No </td>
              <td align="center" valign="middle">:</td>
              <td align="left" valign="middle">AABCA4838Q</td>
            </tr>
            <tr>
              <td height="20" align="left" valign="middle">TAN No </td>
              <td align="center" valign="middle">:</td>
              <td align="left" valign="middle">DELA31278C</td>
            </tr>
            <tr>
              <td height="20" align="left" valign="middle">Service Tax No </td>
              <td align="center" valign="middle">:</td>
              <td align="left" valign="middle">AABCA4838QST004</td>
            </tr>
          </table></td>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="100" align="center" valign="bottom" >This is a computer generated offer hence no signature is required.</td>
      </tr>
    </table>
    <!-- Industrial Quote Format End --> 
    
  </div>
 
 
 
</apex:page>


 
VineetKumarVineetKumar
What's the error?