You need to sign in to do that
Don't have an account?
App Shark
PDF not displayed when clicking the button in CHROME and IE
Below are the class, Pgae, Button I am using .
CLASS:
public class PrintStandardLabel
{
public list<zkfedex__Shipment__c> Shipmentlist {get;set;}
public list<Attachment> lstAttachment {get;set;}
public String currentRecordId ='';
public string ShipmentID = '';
public PrintStandardLabel(){
currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
system.debug(':::::currentRecordId'+currentRecordId);
Shipmentlist = new list<zkfedex__Shipment__c>();
lstAttachment = new list<Attachment>();
if(currentRecordId != null && currentRecordId != ''){
Shipmentlist = [Select zkfedex__RecipientLead__c, Name, Id, CreatedDate From zkfedex__Shipment__c WHERE zkfedex__RecipientLead__c =:currentRecordId ORDER BY CreatedDate DESC];
}
system.debug('::::ShipmentID'+ShipmentID);
if(Shipmentlist != null && Shipmentlist.size()>0){
lstAttachment = [Select ParentId,OwnerId,Name,Id,Description,CreatedDate,ContentType,BodyLength,Body From Attachment WHERE ParentId =: Shipmentlist[0].Id ORDER BY CreatedDate DESC];
}
system.debug(':::::List Attachment'+lstAttachment[0].Id);
}
public PageReference Redirect(){
PageReference newocp = new PageReference('/servlet/servlet.FileDownload?file='+lstAttachment[0].Id);
newocp.setRedirect(true);
return newocp;
}
}
PAGE:
<apex:page controller="PrintStandardLabel" action="{!Redirect}" renderAs="pdf">
<apex:form >
</apex:form>
</apex:page>
LIST BUTTON:
var LeadID = '{!Lead.Id}';
var newwindow = window.open('/apex/PrintStandardLabelPg?id='+LeadID,'_blank');
CLASS:
public class PrintStandardLabel
{
public list<zkfedex__Shipment__c> Shipmentlist {get;set;}
public list<Attachment> lstAttachment {get;set;}
public String currentRecordId ='';
public string ShipmentID = '';
public PrintStandardLabel(){
currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
system.debug(':::::currentRecordId'+currentRecordId);
Shipmentlist = new list<zkfedex__Shipment__c>();
lstAttachment = new list<Attachment>();
if(currentRecordId != null && currentRecordId != ''){
Shipmentlist = [Select zkfedex__RecipientLead__c, Name, Id, CreatedDate From zkfedex__Shipment__c WHERE zkfedex__RecipientLead__c =:currentRecordId ORDER BY CreatedDate DESC];
}
system.debug('::::ShipmentID'+ShipmentID);
if(Shipmentlist != null && Shipmentlist.size()>0){
lstAttachment = [Select ParentId,OwnerId,Name,Id,Description,CreatedDate,ContentType,BodyLength,Body From Attachment WHERE ParentId =: Shipmentlist[0].Id ORDER BY CreatedDate DESC];
}
system.debug(':::::List Attachment'+lstAttachment[0].Id);
}
public PageReference Redirect(){
PageReference newocp = new PageReference('/servlet/servlet.FileDownload?file='+lstAttachment[0].Id);
newocp.setRedirect(true);
return newocp;
}
}
PAGE:
<apex:page controller="PrintStandardLabel" action="{!Redirect}" renderAs="pdf">
<apex:form >
</apex:form>
</apex:page>
LIST BUTTON:
var LeadID = '{!Lead.Id}';
var newwindow = window.open('/apex/PrintStandardLabelPg?id='+LeadID,'_blank');
<apex:page controller="PrintStandardLabel" action="{!Redirect}" renderAs="pdf">
Thanks for your reply, its is displaying in Firefox, can't get in Chrome and IE.