Opne a VF page in Print Mode using a custom Button
Step 1: Create a VF page
<apex:page standardController="Contact" sidebar="false" showHeader="false">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
<style>
body{ font-size:14px;}
.lblPrint{
width:49%;
float:left;
border:1px solid White;
height:260px;
}
</style>
<apex:form >
<div style='margin-left:5px;display:block;'>
<div class='lblPrint'>
<div class='MainPrint' style="padding-left:20px;padding-top:15px;" >
<b>
<apex:outputText value="{!UPPER(Contact.Salutation)}" style="font-size:14px;"/>
<apex:outputText value="{!UPPER(Contact.Name)}" style="font-size:14px;"></apex:outputText>
</b>
</div>
</div>
</div>
</apex:form>
<script type="text/javascript">
$(document).ready(function(){
var counter = 0;
$(".lblPrint").each(function(){
counter = counter + 1;
if(counter%8 == 1 || counter%8 == 2)
{
$(this).find(".MainPrint").first().css("padding-top","35px");
}
else if(counter%8 == 3 || counter%8 == 4)
{
$(this).find(".MainPrint").first().css("padding-top","20px");
}
if(counter%8 == 7 || counter%8 == 0)
{
$(this).find(".MainPrint").first().css("padding-top","5px");
}
});
window.print();
});
</script>
</apex:page>
Step 2: Create a Custom Button
Open a button using JavaScript
write the below code in Box
var ConID = '{!Contact.Id}';
window.open("/apex/VfpageName?id="+ConID ,"mywindow");
Step 3: Put this Custom Button on Detail Page Layout
<apex:page standardController="Contact" sidebar="false" showHeader="false">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
<style>
body{ font-size:14px;}
.lblPrint{
width:49%;
float:left;
border:1px solid White;
height:260px;
}
</style>
<apex:form >
<div style='margin-left:5px;display:block;'>
<div class='lblPrint'>
<div class='MainPrint' style="padding-left:20px;padding-top:15px;" >
<b>
<apex:outputText value="{!UPPER(Contact.Salutation)}" style="font-size:14px;"/>
<apex:outputText value="{!UPPER(Contact.Name)}" style="font-size:14px;"></apex:outputText>
</b>
</div>
</div>
</div>
</apex:form>
<script type="text/javascript">
$(document).ready(function(){
var counter = 0;
$(".lblPrint").each(function(){
counter = counter + 1;
if(counter%8 == 1 || counter%8 == 2)
{
$(this).find(".MainPrint").first().css("padding-top","35px");
}
else if(counter%8 == 3 || counter%8 == 4)
{
$(this).find(".MainPrint").first().css("padding-top","20px");
}
if(counter%8 == 7 || counter%8 == 0)
{
$(this).find(".MainPrint").first().css("padding-top","5px");
}
});
window.print();
});
</script>
</apex:page>
Step 2: Create a Custom Button
Open a button using JavaScript
write the below code in Box
var ConID = '{!Contact.Id}';
window.open("/apex/VfpageName?id="+ConID ,"mywindow");
Step 3: Put this Custom Button on Detail Page Layout
Comments
Post a Comment