I am trying to build a utility where a user can upload a pdf or word and after successful upload, it should create a record in salesforce by reading that pdf/word? Is it something doable? If not, can it be stored as an attachment and create a record from that attachment?

  • You can check PDFTron and build a custom solution for your own needs.
    – nica
    Feb 1, 2021 at 20:25
  • "reading that pdf/word" Are you looking to do this purely client side in the browser? Or is server processing allowed? I know some cases everything has to stay in Salesforce environment, so you cannot use your own servers.
    – Ryan
    Feb 8, 2021 at 19:25

1 Answer 1


This is technically possible, not not really practical or feasible.

PDFs and .docx files are complex beasts. PDF is probably the simpler of the two, but it's still not something that you can just grab text out of. docx has the additional complications of being a zipped directory containing xml (for the "main" sub-file in the document).

Apex doesn't have good support for binary streams, and no native support for zipping/unzipping files. It is possible to write an unzip utility in Apex, but the platform limits on heap size and CPU time makes it so that you could only handle small files (I think I remember reading some speculation that you wouldn't be able to work on a .docx more than about 1 MB in size).

Storing as an attachment won't help you here either, since the main problem you're up against is accessing the data in the document.

CSV files and the Salesforce-provided Data Loader is the established way to generate records in SFDC from a document.

  • There's a lib for zip files (github.com/pdalcol/Zippex) already, but you're right, the heap and CPU limits means you won't get through even remotely large .docx files. Would be far easier to export to a remote service and decode there (e.g. heroku, aws).
    – sfdcfox
    Feb 1, 2021 at 21:15
  • 1
    "not really practical or feasible" I would disagree with this statement. The rest of the answer seems fine, but the first sentence seems misleading
    – Ryan
    Feb 8, 2021 at 19:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .