I am working on a contract module in package. As you all know contract for diffreant companies are diffrent, I mean their logo, their way of data representation etc.

So I am createing a vf page which shows contract details to user. How can I create a vf page that can change its content.

I am thinking of saving an word file of contract and then reading it in visualforce page.

Visualforce Page

    <apex:page controller="UploadDocumentController" >
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
              <apex:pageBlockSectionItem >
                <apex:outputLabel value="Resume" />
                 <apex:outputPanel > 
                  <div class="requiredInput">
                    <div class="requiredBlock"></div>
                      <apex:inputFile value="{!attachment1Blob}" /><br/>  
                      <div class="note"> doc, docx, txt, and pdf. Max 800 KB </div>

        <apex:commandButton value="Save" action="{!save}"/>
        <apex:outputText value="{!tempString}"></apex:outputText>


public with sharing class UploadDocumentController {
transient public Blob attachment1Blob {get;set;}
public String tempString  {get;set;}
    Public void save(){
         Document resume = new Document();
         tempString= EncodingUtil.base64Encode(attachment1Blob);
         resume.body = attachment1Blob;
         resume.name = 'test';
         resume.Folderid = UserInfo.getUserId();
         insert resume;



How can I read the content of visualforce page and display in visualforce page. Also how can I embed my values from controller to visualforce page.

Please help, Thanks in advance

  • 1
    conga composer has a solution for generating sfdc data into word documents from a button click
    – cropredy
    Apr 17, 2015 at 2:21
  • Please help need solution without using any third party apps. Apr 17, 2015 at 5:26
  • What is the use case? What you are really trying to achieve? Do you want to generate a word doc from SFDC data? Do you want your users to modify that document and commit the changes in SFDC? Can you please elaborate? Apr 20, 2015 at 7:11
  • I am trying to get content from user. User will give an word file or a doc which will have data. I will get that data and add to my visualforce page. But my question is how will i take this doc or pdf file and add it to visual force page? Apr 21, 2015 at 5:37
  • if an overhead is acceptible your users can probably save the document as a word xml and then upload that to your application which can parse this xml and extract the data. Apr 21, 2015 at 13:33

2 Answers 2


So, basically you need ability to read doc file then update the doc file with some content from SFDC. To do this you need some sort of API/COM component to interact with doc file. As of now there is no such API/COM component available on force.com Due to this, it is not feasible to READ/UPDATE doc file on force.com platform. So the only option to you is either use 3rd party solution like
conga composer or develop your own service using .net(or some other programming language) and consume that service from SFDC.


//Simple Custom Controller to Insert an Attachment into Salesforce

public  class AttachmentUploadController 
    public String parentId {get;set;}
    public Attachment attach {get;set;}
    public string caseid{get;set;}
    public AttachmentUploadController()
        attach = new Attachment();

    //When user clicks upload button on Visualforce Page, perform upload/insert
    //Redirect user to newly inserted document
    public ApexPages.Pagereference upload()

        //This shows how to insert an Attachment
        attach.ParentId = CaseId;
        insert attach;

        return new ApexPages.Standardcontroller(attach).view();   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.