+ Start a Discussion

render as pdf

hi i have requirement here like we will be sending some links in the emails to the guest users  .so when a user clicks on the link a page opens with some populated data.i am using java script to populate the data. i made the page render as pdf. then the page is loading as pdf but the data is not populating.when i take off the render as pdf the page is loading with populated data.


So i want to create a button on the page so that when user clicks on that button the page with populated data should convert as pdf.



can anybody how can i achieve this.,



Nathan CrosbyNathan Crosby

Place the logic to populate the Visualforce page into an associated APEX Controller and then the rendered result will display correctly.


but hte logic i have written in java script



the logic to pupulate the data is in java script


function GetWebTrend(name)
  var start=location.search.indexOf("?"+name+"=");
  if (start<0) start=location.search.indexOf("&"+name+"=");
  if (start<0) return '';
  start += name.length+2;
  var end=location.search.indexOf("&",start)-1;
  if (end<0) end=location.search.length;
  var result='';
  for(var i=start;i<=end;i++) {
    var c=location.search.charAt(i);
    result=result+(c=='+'?' ':c);
  return unescape(result);
	// set defaults here
	var wtQueryStr = "No Name";
   if (location.search.indexOf("WT.mc_id=") != -1) {
     wtQueryStr = GetWebTrend("WT.mc_id");
function populateName(){ 

function populateHiddenFields(){
    var AreaCode = document.getElementById("phoneArea").value;
    var Prefix = document.getElementById("phonePrefix").value; 
    var PhNumber = document.getElementById("phoneNumber").value;
    if (AreaCode != ""){
    document.getElementById("phone").value='('+AreaCode+') '+Prefix+'-'+PhNumber;
   // var Month = document.getElementById("exMonth").value;
   // var Day = document.getElementById("exDay").value; 
   // var Year = document.getElementById("exYear").value;
   // if (Month != "MM"){
  //  document.getElementById("ExDateHidden").value=Month+'/'+Day+'/'+Year;
   // }


how can we keep this in controller.