I have a requirement to create separate pdf files with informations of HCPs having been called where samples are dropped. I can extract in csv, but how to do that in a presentable format in pdf? Please let me know if an apex class can be written for this. Please find my apex page here.
<apex:page controller="AccountPDF" setup="true" sidebar="false" showheader="false" renderas="pdf">
<head>
<style type="text/css" media="print">
@page
{
@top-center
{
content: element(header);
}
@bottom-left
{
content: element(footer);
}
}
div.header
{
padding: 10px;
position: running(header);
}
div.footer
{
display: block;
padding: 5px;
position: running(footer);
}
.pagenumber:before
{
content: counter(page);
}
.pagecount:before
{
content: counter(pages);
}
</style>
</head>
<div class="header">
<div> <center><i> Health Care Persons.</i></center></div>
</div>
<div class="footer">
<div align="center">
Otsuka Pharmaceutical Group.
</div>
<div align="left">
Page <span class="pagenumber"/> of <span class="pagecount"/>
</div>
</div>
<apex:pageBlock title="hcps)"> {!NOW()}
<TABLE width="100%">
<TR style="background-color:#F5F7FF; font-family: sans-serif;font-size:12px">
<TH>First Name</TH>
<TH>Last Name</TH>
<TH>Name</TH>
<TH>Call Name</TH>
<TH>Call Date</TH>
<TH>Call Created By</TH>
</TR>
<apex:repeat value="{!m1}" >
<TR style="height:40px; background-color:#D5DDF4; font-family: sans-serif;">
<TD wrap="true" colspan="3" style="color:blue;padding-top: 3px;padding-left: 5px;font-size:12px"><B>{!m1[Name]}</B> <!--<a href="/{!m1[ID]}"></a>-->
</TD>
<TD style="color:blue;font-size:12px">
</TD>
<TD style="color:blue;font-size:12px" colspan="6">
</TD>
</TR>
<apex:repeat value="{!m1.Call2_vod__r}">
<TR style="height:20px; background-color:#F5F7FF; font-family: sans-serif;font-size:11px">
<TD wrap="true">{!m1[FirstName]}</TD>
<TD wrap="true">{!m1[LastName]}</TD>
<TD wrap="true">{!m1[Name]}</TD>
<TD wrap="true">{!m1[Call2_vod__r.Name]}</TD>
<TD wrap="true">{!m1[Call2_vod__r.call_Date_vod__c]}</TD>
<TD wrap="true">{!m1[Call2_vod__r.Createdby.Name]}</TD>
</TR>
</apex:repeat>
</apex:repeat>
</TABLE>
</apex:pageBlock>
</apex:page>
The class from where refering as below.
public class AccountPDF
{ Public void AccountPDF(){}
Public Set<ID> s = new Set<ID>();
Public String query;
public Map<ID,Call2_vod__c> getm1()
{ for(Call2_vod__c c:[SELECT Account_vod__c FROM Call2_vod__c where Is_Sampled_Call_vod__c =true limit 10 offset 11])
{s.add(c.Account_vod__c);
}
//List<Call2_vod__c > m1 = [SELECT Account_vod__r.FirstName,Account_vod__r.Lastname,Account_vod__r.Name,Name,Call_datetime_vod__c,Createdby.Username FROM Call2_vod__c where Is_Sampled_Call_vod__c =true order by Account_vod__c];
//Set<ID> L1=[SELECT Account_vod__c FROM Call2_vod__c where Is_Sampled_Call_vod__c =true];
Map<ID,Call2_vod__c> m1= new Map <ID,Call2_vod__c>([SELECT Account_vod__r.FirstName,Account_vod__r.Lastname,Account_vod__r.Name,Name,Call_datetime_vod__c,Createdby.Username FROM Call2_vod__c where Is_Sampled_Call_vod__c =true and Account_vod__c in :s ]);
return m1;
}
}
Issue: Can't find the records in apex page