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
App SharkApp 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');
surasura
your page never get loaded , because on page load you are redirecting user to a an attachment file

<apex:page controller="PrintStandardLabel" action="{!Redirect}" renderAs="pdf">
App SharkApp Shark
Hi sura,
  Thanks for your reply,  its is displaying in Firefox, can't get in Chrome and IE.