Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have used the following cod to render as PDF, but website is not render when using the render as PDF/ but if I remove the PDF, the webpage is loading.

Code:

   <apex:page render="pdf">
// external webstie link (ex: bing.com)
</apex:page>
share|improve this question

3 Answers 3

up vote 1 down vote accepted

please refer the following.

Check

We cant render as pdf. we can render only when using the third party tool.

share|improve this answer

You can't put iFrames, Javascript and that sort of stuff in a PDF. The PDF render engine only looks at the DOM as it is when the page is loaded (HTML/CSS/VF).

You can get the content of the website (the source code) but there is no way to render that as a PDF in your visualforce page. Below is a code how to get the content if that helps:

Controller:

public with sharing class MyClass
{
    public String content {get; set;}

    public void init()
    {
        PageReference pageRef = new PageReference('https://google.com');
        content = pageRef.getContent().toString();
    }
}

Page:

<apex:page controller="bbtest" action="{!init}" renderAs="PDF">
    <apex:outputText value="{!content}" />
</apex:page>

You need to add the external website's domain name in Remote Sites.

You can probably use a headless browser and some fancy screen capture method, then add that as an image into your VF PDF, but that's a challenge that I'm leaving with you and good luck :)

share|improve this answer
    
I don't know what you're trying to achieve here. But if you're about to load another website and generate PDF out of it, you won't be able to do that unfortunately. –  Bachovski Aug 7 at 7:38
    
You can't do that. You can get the source code of the page but you won't be able to render "as is" on your page. I've updated the answer of how to get the content of the page if that helps. –  Bachovski Aug 7 at 7:55
    
Because the PDF renderer does not support that. It only looks what is on the page at that given moment when the page loads. The PDF renderer is not capable to interpret Javascript or to load an iFrame etc. salesforce.com/us/developer/docs/pages/Content/… –  Bachovski Aug 7 at 8:14
    
Let us continue this discussion in chat. –  Lemon Aug 7 at 8:23
    
You are give useless answer. pelasee provide the answer or else please allow some other person. –  Lemon Aug 8 at 5:26

I just found one work around for this. We can use third party API to convert any URL into PDF.

Here is site that provide this service

Please note that this is paid service.

They also have Rest API that we can call from SFDC.

Here is sample PDF that i generated for testing.

enter image description here

share|improve this answer
    
Hi please look the question and provide the solution. how to load the external website with in the vf page and show as the pdf? –  Lemon Aug 8 at 5:30
    
For including page just use Iframe and for generating PDF use the solution provided above. –  AtulRajguru9 Aug 8 at 5:40
    
Ok I will use the IFrame but how to make the pdf, I dont see the code in your answer. but that is paid verson so please help easiest way. –  Lemon Aug 8 at 5:58
    
This is the easiest way i know my friend. Call Rest API and get the PDF! I do not have code ready but you should be able to figure that out. –  AtulRajguru9 Aug 8 at 6:02
    
Call Rest API and get the PDF! is too may stuff so can you guide anyother way? –  Lemon Aug 8 at 6:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.