0

Following scenario: A custom label has to be displayed in a rendered PDF (display in a VF Iframe). Now - it should display the specific custom label translation language found in a controller function {!lang}. Like:

-1--works fine !-------------------------------------------
<apex:page controller="Account" extensions="AccExtens" Language="de" renderAs="pdf" >     
  Text: {!$LABEL.FreeTextLabel}     
</apex:page>

-2--works fine !-------------------------------------------
<apex:page controller="Account" extensions="AccExtens" Language="de" renderAs="{!renderas}" >     
  Text: {!$LABEL.FreeTextLabel}     
</apex:page>

-3--does not work!-------------------------------------------

<apex:page controller="Account" extensions="AccExtens" Language="{!lang}" renderAs="{!renderas}" >     
  Text: {!$LABEL.FreeTextLabel}     
</apex:page>

-------------------------------------------

public class AccExtens{

   public String getRenderas(){ 
      System.Debug('--renderas--');  
      return 'pdf';
   }  
   public String getLang(){ 
      System.Debug('--lang--');
      return 'de';
   }  
}

The strange part here is that code portions 1 and 2 work fine as far as the renderas call to controller is concerned. On page refesh the lang controller function gets also called as i see the debug of both lang and renderas.

I have a strange feeling that the language attribute and renderas attribute of apex:page are handled differently as far as the build up of the view state is concerned ! Can someone confirm that? And does somebody have a workaround?

5
  • It seems to be working when the page is viewed directly. Issue is only when embedded in an iframe?
    – Raul
    Jan 19, 2018 at 10:03
  • I copied your code to class and page in my DEV org, then created another page with an apex:iframe to your page's code. Now when I view the iframe page, translation in PDF works. Note that my API version of class and pages are 41.0. What are you doing differently to have that issue? And I don't think the attributes language and renderAs are handled differently.
    – Raul
    Jan 19, 2018 at 10:06
  • 1
    @RahulSharma that's awesome - worked ! the version update solved the problem !! Strange that it did work with version 36 before the last release ... and it gave this problem just now by not having version 41 ... but great ... thanks for your proactive help ... why not put your comment as an answer and ill mark it as best answer
    – owsata
    Jan 19, 2018 at 10:44
  • Added answer, glad to be of any help. :)
    – Raul
    Jan 19, 2018 at 12:16
  • Just FYI I finally figured this out on my end - solution may/may not be helpful to people here but sharing link in case: salesforce.stackexchange.com/a/337663/43223 Mar 23, 2021 at 18:12

1 Answer 1

1

I copied your code to class and page in my DEV org, then created another page with an apex:iframe to your page's code.

Now when I view the iframe page, translation in PDF works.

Note: API version of all classes and pages are 41.0.

Your question: Have a strange feeling that the language attribute and renderas attribute of apex:page are handled differently as far as the build up of the view state is concerned - I don't think the attributes language and renderAs are handled differently.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .