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
santusantu 

Display Standard Object records and Display only Siebel table records after 5 seconds in PDF

Hi All,

 

Our requirement is Displaying some standard object records along with some siebel table records in PDF and siebel tables data will be display in PDF after 5 seconds. but the problem is scripting is not working in VF page. i displayed standard object records and siebel table records in VF page not in PDF but i want to display in PDF but now how to proceed i don't know please give me any one suggest me. this is very urgent i want to complete.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
MTBRiderMTBRider

Unfortunately, I have never used getcontentaspdf.  I have only used the renderas propoerty for generating pdfs.  I think most developers that use it so so to create an attachment that they add to emails.  

 

Getcontentaspdf returns a blob that represents the generated pdf.   So generally after calling it, you would have to store it as a attachment or document and then pull it into an iframe or something like that to display it to the user.   From the code you posted, it looks like you are not doing anything with the pdf once you have generated it. 

 

 

 

All Answers

MTBRiderMTBRider

Have you tried using the renderAs="pdf" attribute in the <apex:page> component?

santusantu

Hi,

 

I was put attribute RenderAs="PDF" in <apex:page>.

If i put this attribute in page after 5 seconds siebel table records will display this logic not working but my requirement is definately we will display siebel table records in PDF. for this logic i used below code. this logic not working when we use renderas pdf in vF page.

 

     <apex:page controller="FunctionAsPollerController">
    <apex:form >
        <apex:pageBlock id="x">
        </apex:pageBlock>
        <script language="javascript">
            setTimeout(function(){aF()},1);
            function aF(){
                ActionFunctionName();
            }
            function aF1(){
                ActionFunctionName1();   
            }
            function aF2(){
                ActionFunctionName2();   
            }
            function aF3(){
                ActionFunctionName3();   
            }
        </script>
        <apex:actionFunction action="{!ControllerAction}" name="ActionFunctionName" oncomplete="aF1();" rerender="x"/>
        <apex:actionFunction action="{!ControllerAction1}" name="ActionFunctionName1" oncomplete="aF2();" rerender="x"/>
        <apex:actionFunction action="{!ControllerAction2}" name="ActionFunctionName2" oncomplete="aF3();" rerender="x"/>
        <apex:actionFunction action="{!ControllerAction3}" name="ActionFunctionName3" rerender="x"/>
    </apex:form>
</apex:page>

 

MTBRiderMTBRider

Ok, I was not quite sure from your original post if you knew of the attribute.  

 

I think there are two ways you could do this.  

 

The first way would be to use the action attribute of the page component in addition to the renderAs attribute of your VF page.  The action atttribute would reference a method in your controller and the VF page will not render until that method returns.  So the method that the action attribute calls could loop until either the siebel db returns the data that will be displayed on the page or until some time out like 10 or 15 seconds.  

 

The second possible way is to not use the renderAs="pdf" in the VF page, but instead use the ApexPages.currentPage().getContentAsPDF() in your controller.  Maybe the VF page renders as a regular VF page and then either the user clicks a button that will call this method or you call the method programatically if you are able to determine that all of the data is displayed on the page.

 

Let me know if either of these ideas work or if you found something else that works.

 

 

santusantu

Hi,

 

Thank you for your reply -

 

This is what I tried out to call using my last action funtion :

 

public pageReference generatePdf(){
        ApexPages.currentPage().getContentAsPDF();
       return null;
}

 

Turns out that this method is called but the page never renders as PDF. Am I doing something wrong ?

 

Thanks,

Santosh

 

MTBRiderMTBRider

Unfortunately, I have never used getcontentaspdf.  I have only used the renderas propoerty for generating pdfs.  I think most developers that use it so so to create an attachment that they add to emails.  

 

Getcontentaspdf returns a blob that represents the generated pdf.   So generally after calling it, you would have to store it as a attachment or document and then pull it into an iframe or something like that to display it to the user.   From the code you posted, it looks like you are not doing anything with the pdf once you have generated it. 

 

 

 

This was selected as the best answer
santusantu

Hi,

 

I Used Document and In that Document I Stored the generated PDF and Using this i have shown the PDF to the Client. He Approved thanks for Your Support.

 

One more thing i tried to display the Output Text(Column Name) in column header in two lines because that very lengthy but i can't to display. that text will come Dynamically. Please Help me.

 

Thanks,

Santosh 

MTBRiderMTBRider

OutputText has an attribute called "escape".  If you set that to false, you can embed html tags into the value of outputtext.  So, perhaps using this you can embed a <br/> tag into the value if the string is too long.  Let me know if that works.

santusantu

 

Thanks for Reply.

 

The Above thing is not working. is any another way available for to display column header name in two lines and Could you Please help me how can we display again column headers after page break occurs in RenderaAs PDF in Visualforce.

 

I am posting what i used sample output text for what you said in previous replay.

 

 <apex:Repeat value="{!lstDisplayLeaseLabel}" var="FieldLabel"> 
   <apex:column style="border-bottom: solid 1px #D3D3D3;" width="20px">
     <apex:facet name="header">
        <apex:outputLabel style="font-size:10px;font-weight:bold;font-family:Arial;">
            <apex:outputText value="{!FieldLabel}" escape="false"/><br/>
         </apex:outputLabel>
      </apex:facet>
  </apex:column>
</apex:repeat>

 

 

Regards,

Santosh

MTBRiderMTBRider

That is not quite how escape="false" is used.  You would use it this way:

 

---VisualForce code----

...
<apex:outputText value="{!FieldLabel}" escape="false"/>
....

--Controller code---

public String getfieldLabel() {
    	return 'This my really long field label<br/>I want it on two lines';
}

 

As for displaying the column headers after a page break, that is a pagination issue.  I, luckly, have never had to do that!  

 

There are a number of posts in this forum about it.  Do a search in the visualforce discussion board for "pdf pagination" and you will get  some postings on the topic.

santusantu

Thanks for Reply.

 

I Done display the Column header name in 2 lines and after page break I displayed the column header names.

Thanks for your support.

 

Regards,

Santosh

MTBRiderMTBRider

Sure, glad it all worked out.  If you do not mind, can you mark this post as fixed?