function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MarniMarni 

Date Appears Blank But Only When Renderas PDF

I have a Visualforce page which I have two versions of but the only difference is that one renders as a PDF.  On this one, the date does not appear.  I use the same code for the page that does not render as a PDF and the date appears without issue.  Any help would be great!  Thanks!

 

<apex:page renderas="PDF" standardController="Policy__c" showHeader="false" sidebar="false">
<p><b><font size="4">{!Policy__c.Name} - {!Policy__c.Insured__r.Name}</font></b></p>
<p><b><font size="2">Claim Check as of <script>
 var mydate=new Date()
    var year=mydate.getYear()
   
    if (year < 1000)
        year+=1900
   
    var day=mydate.getDay()
    var month=mydate.getMonth()+1
   
    if (month<10)
        month="0"+month
   
    var daym=mydate.getDate()
    if (daym<10)
        daym="0"+daym
   
    document.write(month+"/"+daym+"/"+year)
</script></font></b></p>
<p></p>
<table border="1" cellspacing="2" cellpadding="10">
<tr>
<th>Claim Number</th>
<th>Insured</th>
<th>Claimant Name</th>
<th>Policy Number</th>
<th>Claim Status</th>
<th>Date Reported</th>
<th>Examiner</th>
</tr>
<apex:repeat var="rc" value="{!Policy__c.Claims1__r}">
<tr>
<td>{!rc.Name} </td>
<td>{!rc.Insured_Lookup__r.name}</td>
<td>{!rc.Claimant_Name__c}</td>
<td>{!rc.Policy__r.name}</td>
<td>{!rc.Status__c}</td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rc.Date_Reported__c}"/></apex:outputText></td>
<td>{!rc.Assigned_Examiner2__r.Name}</td>
</tr>
</apex:repeat>
</table>
<p/>
<div class="bPageFooter" id="bodyFooter"><div class="footer">Privileged and Confidential - LVL Claims Services, LLC</div></div>
</apex:page>

Best Answer chosen by Admin (Salesforce Developers) 
TheSwamiTheSwami

Javascript is not supported in PDFs:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_renderas_pdf.htm?SearchType=Stem&Highlight=PDF|pdf|PDFs

 

You should be able to do the same thing with formulas or Apex.

All Answers

TheSwamiTheSwami

Javascript is not supported in PDFs:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_renderas_pdf.htm?SearchType=Stem&Highlight=PDF|pdf|PDFs

 

You should be able to do the same thing with formulas or Apex.

This was selected as the best answer
MarniMarni

Thanks!  I was able to find a code that worked.  I figured I would share it in case anyone else has the same problem:

 

{!if(Month(Today())=1,"January","")}{!if(Month(Today())=2,"February","")}{!if(Month(Today())=3,"March","")}{!if(Month(Today())=4,"April","")}{!if(Month(Today())=5,"May","")}{!if(Month(Today())=6,"June","")}{!if(Month(Today())=7,"July","")}{!if(Month(Today())=8,"August","")}{!if(Month(Today())=9,"September","")}{!if(Month(Today())=10,"October","")}{!if(Month(Today())=11,"November","")}{!if(Month(Today())=12,"December","")} {!Day(Today())}, {!Year(Today())}