• Vijay Kumar Yadav
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I had created an email template using visualforce. I had written the CSS code in the apex component. I had called the apex component inside the visualforce page. When i am testing that email template all the content is displayed in proper way in salesforce, but when it is generating pdf inside that pdf content is not displayed properly. I think CSS is not working when i am generating pdf. 
Hello,

I have a Lightning component on my opportunity page that does the following:
  • When clicking on the button, it opens a Lightning modal box
  • This modal box display a Visualforce page, renderas PDF, inside an iframe.
  • I have two button bellow: Cancel, Save
The purpose is to generate and save a PDF to the current record. the modal box allows to preview the document before saving attach it.

-> My issue is: how to save the PDF generated by the Visualforce page, and attach it to the Opportunity?
Any ideas?

demoModal.cmp:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
  <!--use boolean attribute for Store true/false value,
    make default to "false" so modal box are not display on the load of component. 
    --> 
    
    <aura:attribute name="recordId" type="Id" />

  <aura:attribute name="isOpen" type="boolean" default="false"/>
 
  <!--Use "slds-m-around- -xx-large" class to add standard Large padding to the component--> 
  <div class="slds-m-around--xx-large">
    <button class="slds-button slds-button--brand" onclick="{!c.openModel}">Create a document</button>  
    
  <!--Use aura:if tag to display Model Box, on the bese of conditions. [isOpen boolean attribute] -->   
    <aura:if isTrue="{!v.isOpen}">
      
   <!--###### MODAL BOX Start From Here ######--> 
      <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open ">
        <div class="slds-modal__container">
          <!-- ###### MODAL BOX HEADER Part Start From Here ######-->
          <div class="slds-modal__header">
            <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeModel}">
            X
            <span class="slds-assistive-text">Close</span>
            </button>
            <h2 id="header99" class="slds-text-heading--medium">Your document</h2>
          </div>
          <!--###### MODAL BOX BODY Part Start From Here ######-->
            <iframe src="{! '/apex/monpdf?Id='+v.recordId}" width="100%" height="500px;" frameBorder="0"/>
          <div class="slds-modal__content slds-p-around--medium">
            <p><b>Some random text.
              </b>
            </p>
          </div>
          <!--###### MODAL BOX FOOTER Part Start From Here ######-->
          <div class="slds-modal__footer">
            <button class="slds-button slds-button--neutral" onclick="{!c.closeModel}" >Cancel</button>
            <button class="slds-button slds-button--brand" onclick="{!c.savenClose}">Save the document</button>
          </div>
        </div>
      </div>
      <div class="slds-backdrop slds-backdrop--open"></div>
      <!--###### MODAL BOX Part END Here ######-->
    
 </aura:if>
  </div>
</aura:component>

monpdf.vfp:
<apex:page standardController="Opportunity" showHeader="false" renderAs="pdf">
{!Opportunity.Account.Name}
</apex:page>

demoModalController.js
({
   openModel: function(component, event, helper) {
      // for Display Model,set the "isOpen" attribute to "true"
      component.set("v.isOpen", true);
   },
 
   closeModel: function(component, event, helper) {
      // for Hide/Close Model,set the "isOpen" attribute to "Fasle"  
      component.set("v.isOpen", false);
   },
 
   savenClose: function(component, event, helper) {
      // Display alert message on the click on the button from Model Footer 

      
       alert('It works');
      component.set("v.isOpen", false);
   },
})

 
I have a requirement to automate SSN structure.
example:
user input SSN: 123456789
automate output SSN format: 123-45-6789
with my below logic am not able to achieve the scenario, anyone please help.
Component:
<lightning:input aura:id="SSN__c" name="SSN" 
           label="SSN" 
           maxlength="9" onblur="{!c.formatSSN}"                                          
           value="{!v.newCallerModel.Ssn}" />  
JS Controller 
formatSSN: function(component, helper, event)  {   
     var patt = new RegExp("\d{3}[\-]\d{2}[\-]\d{4}");
     var x = document.getElementById("SSN__c");
     var res = patt.test(x.value);
        if(!res){
            x.value = x.value
            .match(/\d*/g).join('')
            .match(/(\d{0,3})(\d{0,2})(\d{0,4})/).slice(1).join('-')
            .replace(/-*$/g, '');
        }
    },  
hi all,

i am creating an VF email template wherein i am sending an attachment in pdf format.However the styling that i am applying through css is not working.
can anyone help me?below is my code

<messaging:emailTemplate subject="{!relatedTo.Business_Partner__c}confirm next visit date please" 
                         recipientType="User"
                         relatedToType="Order__c">
                       
<messaging:htmlEmailBody >
    <html>
    <head>
    <style>
    table,td,th{border-style: groove;  border-collapse: collapse;}
    </style>
    </head>
        <body>
        <center><apex:image value="{!$Resource.MaxxiumHeader}" alt="header"/></center>
        <p>Dear {!relatedTo.Contact_Person__r.name},</p>
        <p>I would like to confirm our Product Order detail</p>
        
        <table>
        <tr>
           <th>Product Name</th>
           <th>Product Brand</th>
           <th>Product Category</th>
           <th>Net Price</th>
        </tr>
      
        </table>
        <p>Thank you for your confirmation.</p>
        <p>Kind Regards,</p>
      
        </body>
    </html>
</messaging:htmlEmailBody>
 
<messaging:attachment renderAs="PDF">

<head>
<style type="text/CSS">
 .colorStyle
 {
     background-color=#A0A0A0;
 }
</style>
</head>
<body>
 <div>
  <apex:outputText styleClass="colorStyle">Wholesaler Information         </apex:outputText>
   <apex:repeat value="{!relatedTo.Wholesaler__r}" var="acc">
    <tr><td>Name</td><td>{!acc.name}</td></tr>
    <tr><td>Fax</td><td>{!acc.Fax}</td></tr>    
  </apex:repeat>
 </div>

  </body>

</messaging:attachment>
</messaging:emailTemplate>