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
Surender MSurender M 

Doc,PDF,TXT,RTF,etc files preview in Sites of Salesforce


I am not able to find a solution to preview Doc,PDF,TXT,RTF,etc files in Sites of Salesforce.
I tried below major scenarios to preview

1) When Iframe is used with url of "/servlet/servlet.FileDownload?file={!contact.AVTRRT__Resume_Attachment_Id__c}" as below, it is previewing 30KB pdf properly where as for 46KB pdf, it is not preview rather it is downloading.
Why is it happening like this? it is a limitation with url of "/servlet/servlet.FileDownload?file={!contact.AVTRRT__Resume_Attachment_Id__c}"?

<iframe  src="/servlet/servlet.FileDownload?file={!contact.AVTRRT__Resume_Attachment_Id__c}" ></iframe>

2) When used with <embed> tag as below for preview in Sites of Salesforce, it is giving error as "Page Not Found: /ex/errorduringprocessing.jsp" where as same <embed> tag used in Salesforce sandbox directly, it works preview perfectly.

<embed allowfullscreen="true" allowscriptaccess="sameDomain" bgcolor="#f3f3f3" flashvars="shepherd_prefix=/sfc/servlet.shepherd&amp;v=068170000008QWaAAM&amp;mode=chatterfilepreview&amp;in_tests=false" id="renditionLarge" name="renditionLarge" pluginspage="" quality="high" src="/_swf/121310/sfc/flex/DocViewer.swf" type="application/x-shockwave-flash" wmode="opaque" align="middle" height="100%" width="100%" />

Could I know what is the issue here?

3) How could we access/preview Attachment docs of Salesforce using <Iframe> tag (or) Google Docs viewer?
i.e., how could we access preview url's for Attachments?

4) If we render Attachment as PDF in VF using "renderAsPDF", is there any issues for documents like for .Doc, .Docx, .PDF, .RTF in review?

5) While using "renderAsPDF", how to get preview content of .Doc, .Docx, .PDF, .RTF files?

Could anyone guide here?
Appreciate your help here.