You need to sign in to do that
Don't have an account?
SFDC 18
Compile error in VF custom object page to render a PDF
This is my VF page code for Rendering a PDF for custom Object as below
Controller page
I got the error Unknown property 'MyController.custom_object__C' in my VF page
Due to this compile error, in the preview screen I got the display of only top left, bottom right, centre but no data related to "<p>{!custom_object__C.Name__C</p>" line
<apex:page controller="MyController" renderAs="pdf" applyBodyTag="false"> <head> <style> body { font-family: 'Arial Unicode MS'; } @page{ size: letter; margin:10%; @top-left{ content: "Dear,"; font-family: Helvetica, Arial, sans-serif; font-size: 12px; } @bottom-right{ content: "Yours Sincerely,"; font-family: Helvetica, Arial, sans-serif; font-size: 10px; } } body { font-family: Helvetica, Arial, sans-serif; font-size: 11px; } </style> </head> <div align="right"><strong>Date</strong>: {!DAY(Today())} {!CASE(MONTH(Today()), 1, 'January', 2, 'February', 3, 'March', 4, 'April', 5, 'May', 6, 'June', 7, 'July', 8, 'August', 9, 'September', 10, 'October', 11, 'November', 12, 'December', 'Unknown')} {!YEAR(Today())}</div> <center> <h1> Letter</h1> </center> <p>{!custom_object__C.Name__C</p> </apex:page>
Controller page
public class MyController { private final custom_object__c customobject; public MyController(){ customobject = [SELECT Id, Name__c FROM custom_object__c LIMIT 1]; } public custom_object__c getcustom_object__c(){ return customobject; } public PageReference save() { update customobject; return null; } }
I got the error Unknown property 'MyController.custom_object__C' in my VF page
Due to this compile error, in the preview screen I got the display of only top left, bottom right, centre but no data related to "<p>{!custom_object__C.Name__C</p>" line
Please put the getter and setter methods to the variable in the controller .
Example : private final custom_object__c customobject {set;get;}
Thanks & Regards
Srikanth
Salesforce Developer
All Answers
Please put the getter and setter methods to the variable in the controller .
Example : private final custom_object__c customobject {set;get;}
Thanks & Regards
Srikanth
Salesforce Developer
How to add generate PDF button to my object if the VF page contains custom controller?
firstly you can create a custom button then select display type should be Detail Page Button then behaviour Execute javascript ..
content source : on click java script
In the Dialog Box :
window.location = 'apex/yourVfpageName';
Try this one it will help you to acheive this requirement.
Thanks & Regards
Srikanth
Salesforce Developer