You need to sign in to do that
Don't have an account?
sgoldberRH
renderAs PDF ignoring JavaScript
I have a visual force page which needs to be rendered as a PDF, but when I set renderAs = "PDF" it ignores my Javascript entirley. I can't even do a document.write('test'); My issue is that the field labels in the PDF I am rendering need to be dynamic based on the users language. I have written a class to do this for me based on the API field name, but when I try and call it in this page I get nothing. Anyone have any suggestions on how to dynamically pass field labels to a VF page that will be rendered as a pdf?
using the label expression is correct ( and very elegant) since no extra round trips are created.
Section heading labels ? no, at least i don't think so.
you would have to store these into a custom label and display it on the page using $Label.mysection
https://tapp0.salesforce.com/help/doc/user_ed.jsp?section=help&target=cl_about.htm&loc=help&hash=topic-title
All Answers
there is no browser when you render as PDF, so no javascript will run.
if you expose the labels using $Label feature, you can use those labels in your page.
You can also use OutputField to print the field and value. Use action methods instead of javascript to select the language.
RenderAs='Pdf' is a SFDC feature so achieve your Business Logic with SFDC features as far as possible.
If you have to use JavaScript...
Put the code in some S-control or other VF and make it redirect to page using RenderAs PDF passing the option as URL parameters.
You can fetch the parameters in constructor and render things accordingly.
Hope it helps.
P.s. If you can put a code snippet here, i believe you can get more information.
Siddhesh,
Thanks for the help... I am still a little confused ... I am very new to VF. Here is an example of what I am trying to do.
//getting the field label var mdfFundsAvailQ1 = sforce.apex.execute("getFieldLabels","bpGetLabel", {fieldName:"MDF_Funds_Available_Q1__c"}); // the page <apex:pageBlock > <apex:pageBlockSection columns="4"> <b><script> document.write(mdfFundsAvailQ1</script></b> <apex:outputText value="{!AllocatedBudget1}"/>
Maybe I am missing something, but I don't see a way to get the field label from a standard SFDC feature... Thanks again for your help.
there is a feature designed for labels, please try to use this instead of calling Apex from javascript.
$Label
Ron,
Thanks for the info. I am currently using this now:
{!$ObjectType.SFDC_Channel_Account_Plan__c.Fields.Partner_Name__c.label}
will that function differently?
using the label expression is correct ( and very elegant) since no extra round trips are created.
Section heading labels ? no, at least i don't think so.
you would have to store these into a custom label and display it on the page using $Label.mysection
https://tapp0.salesforce.com/help/doc/user_ed.jsp?section=help&target=cl_about.htm&loc=help&hash=topic-title
hey ron,
Can you put the code snippet here. unable to see the link, maybe its broken