+ Start a Discussion
Dream_weaverDream_weaver 

How can I display an ARTICLE having word document uploaded to it in a VF page?

For displaying an PDF I used <object type='application/pdf' but it only opens PDF article..How to open a word doc? what is the object type format of word doc? is there any master object type that will allow any type of document..!!! please help!!

sivaextsivaext

hi

 

Rendering visualforce page to word document 

 

<apex:page contentType="application/msword">

</apex:page> 

 

when you execute or save this , the result opened in word document.

Dream_weaverDream_weaver

I tried your approach...but unfortunately it is not working..

 

Let me post the whole code here...My article is having 2 file field one is having PDF another worddoc attached to the..Now My VF page is:

 

<apex:page standardController="test__kav" >
  <apex:form >
  <apex:pageBlock title="Document">
      <apex:pageBlockSection collapsible="true" showHeader="true" columns="10" >
             <apex:pageBlockSectionItem >
                <object data="{!URLFOR($Action.test__kav.FileFieldDownload,test__kav.id,-----PDF------
                         ['field'=$ObjectType.test__kav.fields.UploadFile__Body__s.name])}"
                         type="application/pdf" width="100%" height="600px">
    
                 <embed src="{!URLFOR($Action.test__kav.FileFieldDownload,
    test__kav.id, ['field'=$ObjectType.test__kav.fields.UploadFile__Body__s.name])}"  width="100%" height="600px"/>
                 </object>
             </apex:pageBlockSectionItem>
             <apex:pageBlockSectionItem >
                  <object  data="{!URLFOR($Action.test__kav.FileFieldDownload,test__kav.id,
                         ['field'=$ObjectType.test__kav.fields.UploadDoc__Body__s.name])}"------Word Doc----
                         type="application/pdf" width="100%" height="600px" >
    
                 <embed src="{!URLFOR($Action.test__kav.FileFieldDownload,
    test__kav.id, ['field'=$ObjectType.test__kav.fields.UploadDoc__Body__s.name])}"  width="100%" height="600px"/>
                 </object>
             </apex:pageBlockSectionItem>
                </apex:pageBlockSection>   
 </apex:pageBlock>
  </apex:form>
</apex:page>

 

PDF file is getting displayed properly ....But not the word doc...the section is comimg as a blank!!!Could you please suggest!!!!!!!!

 

sivaextsivaext

Hi 

 

you used  type ='application/pdf' in both places pdf as well as word doc. 

 

<object  data="{!URLFOR($Action.test__kav.FileFieldDownload,test__kav.id,
                         ['field'=$ObjectType.test__kav.fields.UploadDoc__Body__s.name])}"------Word Doc----
                         type="application/pdf" width="100%" height="600px" >

 

try this code inplace of above code

 

<object  data="{!URLFOR($Action.test__kav.FileFieldDownload,test__kav.id,
                         ['field'=$ObjectType.test__kav.fields.UploadDoc__Body__s.name])}"------Word Doc----
                         type="application/msword" width="100%" height="600px" >

Dream_weaverDream_weaver
Tried that approach also.....but its not working...
colemabcolemab

Dream_weaver, have you verified that the address to the file is correct and that you have permissions/security to access it?

 

You can use a tool like firebug to get the URL and then copy and paste it into a new window.  If the window prompts to you either open or save the file and you are able to open or save it, andthen see the correct file then this would make sure the address and secruity isn't the issue.

 

I mention this because the last version of the HTML / Visualforce looked correct.

Dream_weaverDream_weaver

I am having the permissions to the article..but stilll the issue persists..Mean while I tried with I-Frame..

 

<script> $(document).ready(

function(){  $("p").html('<iframe align="center" name="iFrameContent" id="iFrameContent" frameborder="0" src="{!URLFOR($Action.test__kav.FileFieldDownload,test__kav.id,                          ['field'=$ObjectType.test__kav.fields.UploadDoc__Body__s.name])}"  width="100%" scrolling="auto" height="600px"></iframe>');                     }                  );

</script>

 

 

<p></p> used in one of the apex:sectionItem..

 

But in this case the documents are prompting for downloading not displaying on the page itself..But it is happening for PDF& word in both the cases....

 

But still my  issue is not resolved.....My question is Can we use

 

https://xyz.salesforce.com/servlet/servlet.FileDownload?file=id for displaying the attached document...If yes, then which id should I pass for 'file' attribute...I used the same for displaying a case attachment where I passed case.attachment.id .but here it is uploaded in 'file' field.....What to do!!!!!!  Any help plz.....