+ Start a Discussion
DixitSDixitS 

Cross is coming while showing VF page as Word document using simple <apex:detail> tag

Hello All,
I have a requirement, on button click download the detail page of record as a Word doc, I wrote the below code but when file is getting downloaded cross is coming in place of image (Owner name avatar),  however, I used CSS and javascript to hide all the images from Page but it's not working . Please help. Thanks in advance
<apex:page standardController="opportunity"  contentType="application/msword#Tender_Opportunity.doc" cache="true" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
<html xmlns:w="urn:schemas-microsoft-com:office:word">
     <head>
       <style>
       
         .labelCol {
               font-weight: bold;    
               font-family: Calibri;             
                width: 200px;
               text-align: left;

            }
             .dataCol {
                     width: 300px;
                     margin-right: 20px;
           }
           .col02 {
                     width: 300px;
                     margin-right: 20px;
           }    
           a {
                text-decoration: none;
            }   
            img[src=""] {
               display: none;
               visibility: hidden;
            } 
        </style> 
        <script>
        window.onload = function removeImg() {
          var images = document.getElementsByTagName('img');
            for(var i=0; i < images.length; i++) {
                images[i].parentNode.removeChild(images[i]);
            }
        }
        </script>
          <base href="http://blogforce9dev-developer-edition.ap1.force.com/salesforceicons"/>       
     </head>   
     <body>
         <apex:detail subject="{!opportunity.id}" relatedList="false" title="false"/>
     </body>
 </html>
</apex:page>

 
Raj VakatiRaj Vakati
Try this code
 
<apex:page standardController="opportunity"  contentType="application/msword#Tender_Opportunity.doc" cache="true" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
    <html xmlns:w="urn:schemas-microsoft-com:office:word">
        <head>
            <style>
                
                .labelCol {
                font-weight: bold;    
                font-family: Calibri;             
                width: 200px;
                text-align: left;
                
                }
                .dataCol {
                width: 300px;
                margin-right: 20px;
                }
                .col02 {
                width: 300px;
                margin-right: 20px;
                }    
                a {
                text-decoration: none;
                }   
                img {
                display: none;
                visibility: hidden;
                border:0;
                outline: none;
                } 
                
                .chatter-avatarStyle{
                background :none !important;
                visibility: hidden !important;
                border:0 !important;
                outline: none !important;
                
                display: none  !important;
                }
                
                
                a:link, a:visited {
                pointer-events: none;
                cursor: default;
                text-decoration: none;
                color: black;
                }
            </style> 
            <script>
            window.onload = function removeImg() {
                var images = document.getElementsByTagName('img');
                for(var i=0; i < images.length; i++) {
                    images[i].parentNode.removeChild(images[i]);
                }
            }
            </script>
            <base href="http://blogforce9dev-developer-edition.ap1.force.com/salesforceicons"/>       
        </head>   
        <body>
            <apex:detail subject="{!opportunity.id}" relatedList="false" title="false"/>
        </body>
    </html>
</apex:page>




 
DixitSDixitS
Hi Raj,

Thanks for your kind response But still the problem is same. After document will get downloaded if the protected view mode is enabled then crosses are visible and once we clicking on enable editing crosses will go away. 

Thanks,
Shambhvi
DixitSDixitS
Hi Raj ,

you can see the cross in the image. Thanks User-added image
GhanshyamChoudhariGhanshyamChoudhari
input{
      display:none;
      }
                
.chatter-avatarInline{
      display:none;
   }

 
DixitSDixitS
The word is opening in protected mode and that might be because of the file is from the Internet or from other potentially unsafe locations which is the behavior of the word in general. Although this can be disabled but then we will be putting the system in risk which will not be recommended.
 
Sushant Patil 73Sushant Patil 73
Hi @DixitS, Did you find any workaround for same?