I'm migrating the Salesforce org of a company we acquired into ours. The company we acquired used the quote object in Salesforce but we don't. I would still like to migrate the Quote PDF files attached to each quote and attach them to the opportunity.

I've already done a Data Export of their org and was able to import all attachments and documents from their instance. The Quote PDFs were not included in the attachments folder of the data export though.

I'm looking for a way to extract all Quote PDFs stored on the quote object.

4 Answers 4


It's located in an object called QuoteDocument. The Document field contains the binary data (encoded in Base64), while the rest of it contains some basic information, like the total, quote ID, and so on. You'll need to pull this file out using the data loader, as it appears that the standard export doesn't include this data (at least, not by default). It should be a trivial export process:

Query 1:

SELECT Id, Document, Name, QuoteId FROM QuoteDocument

Query 2:

SELECT Id, OpportunityId FROM Quote


Link the two spreadsheets together, and add a few columns, so that you have: ParentId (OpportunityId), Body (Document), Name (Name), ContentType (application/pdf).


I've looked into the same requirement and, as far as I can see, there is no way to export the Quote PDF as a document and, while sfdcfox's queries will allow you to export them as Base64-encoded data in a CSV, you're unable to re-import them to a new org because the data exceeds the field size limit when you try to initialise the CSV file in Dataloader. This seems insurmountable.

I'd be intrigued to know if anyone manages to find a workaround for this; in the meantime, I've added an idea in the Ideas Exchange, which you might consider giving a vote to:



I've been working back and forth with Salesforce support for a couple weeks now, saying the same thing. Not possible, here's some workarounds, maybe.

I was looking at the files that the Data Export (Quotes only, + all attachments). In the Attachments folder are codenamed files. Looking at them in Notepad, there was definitely Quote data there. Just trying something, I renamed the file with ".pdf" extension and now I have a perfect quote in PDF.

The one issue was that it was codenamed. In the "Attachments.csv" file has the real quote names. I ran a simple rename in CMD (Windows) for all the files there. Perfectly named, working PDF files.


How to export the Quote PDF file and read convert it from Base64 back to PDF using Linux command Line

  1. Use Dataloader and export the QuoteDocument object with all fields and data

  2. Use text editor, TextPad to open the csv file. Don’t use Notepad because it cannot handle the large size data and truncates it.

  3. TextPad can handle the large data and respects any newlines characters, etc., when you open the file and also when you copy/paste the data.

  4. Go to a specific row in the data and select and copy the cell field string that contains the PDF Base64 encoded data. Make sure you select it all the way to the end – but do not include subsequent fields after it.

  5. Do not include subsequent fields after it.

  6. Select the string up to but do not include the quote " symbol.

  7. Copy/paste the string into a new TextPad window.

  8. Save the new TextPad to a file, for example, document1.txt

  9. Copy the docuemnt1.txt file to your Linux computer (you could use Dropbox for this).

  10. Open a Linux command line terminal window

  11. Run the base64 decode command (base64 is part of the coreutils package), $ base64 --decode ~/Dropbox/linux_stuff/Document1.txt > ~/Dropbox/linux_stuff/decoded1.pdf

  12. This command will read in the Document1.txt file and output the decoded PDF file to decoded1.pdf.

  13. You can now open the decoded1.pdf file as an PDF file.

  14. You can rename the decoded1.pdf file to whatever you want, i.e., back to the original file name that was attached in the original Salesforce Quote object record.

You must log in to answer this question.