Ever wondered if you could create PDF contracts from Salesforce®, with no server required? Well, in this article, we share a simple, secure method of Salesforce contract generation -- PDFTron WebViewer -- for those looking to streamline contract management and create efficiencies in a contracting or quoting process.

Salesforce developers can check out the doc gen sample project on our GitHub.

How Does Salesforce Document Management and Automation Work with WebViewer?

This Lightning Web Component plugs right in to look and feel like part of your Salesforce solution. Users can then create contracts using any Office or Word templates on the fly, with fast, in-app processing, for pixel-perfect results in seconds. At no point does your data leave the Salesforce platform.

Read on for details on these Salesforce-native, dynamic doc gen features, plus a step-by-step tutorial on how to get your Salesforce contract generator up and running in minutes.

Learn more about our many other capabilities on our Salesforce page. Or experience the web demo to see features for creating contracts in Salesforce at work in your browser. Check out the end of this post for links to further resources.

Dynamically Generate PDF Contracts from Salesforce Using Office Templates

With a Salesforce-specific WebViewer that snaps into any Salesforce app as an LWC -- contract generation in Salesforce has never been easier. Salesforce.com uses the very same technology in its Salesforce Industries group to accelerate custom digital transformation projects.

Features to auto-generate contracts come out of the box, ready to deploy to your Salesforce environment in minutes. Features are also fully flexible.


WebViewer plugs in as an LWC for serverless, dynamic contract generation

Use Cases for Salesforce Contract Generation

With Salesforce contract management in WebViewer, you can:

  • Generate an employee contract with Salesforce data
  • Generate a sales agreement with Salesforce data
  • Generate a vendor contract document with Salesforce data

For example, to create a PDF contract from an opportunity or an order, you could...

  1. Have users upload templates and then map data visually via an intuitive, fully customizable built-in viewer UI
  2. Auto-generate contracts via the back-end API, drawing data from any data source (e.g., any JSON or XML file)

You're free to use templates in a variety of Office formats, created in any familiar Office tool or anything that can create a Word document.

Next, with its built-in Office engine, the component automatically detects the formatting and styling of your Office templates. It then dynamically reflows content to fit newly inserted text, figures, and images -- using the PDFTron SDK’s leading accuracy to preserve the original look and feel of your document.

Since there are no server-side dependencies or API calls out, templates and data are processed natively to your Salesforce solution reliably and on the fly. Any confidential information never leaves your control.

Lastly, you can set up the solution to track the contract through an approval process or use workflow alerts to notify you of your contract renewals. You can also simplify the recycling or migration of your template mappings by saving them as a custom metadata record.

How to Extend Your Solution with Salesforce-Native Contract Generation

Use the following steps to extend your Salesforce capabilities by creating, uploading, and editing contract templates with little-to-no training.

Note: This is just one way to complete this task; you can also customize this process to do it your own way following Salesforce contracts best practices.

  1. To create a Salesforce contract from an opportunity, first create the template using Google docs or another program. You can use Microsoft Word if you have a license, but it is not required.

    The following image is a sample contract.

    • Make sure your template includes double curly brackets {{}} for fields that users will customize.
    • For example, users will replace the terms {{Vendor}}, {{Bank}}, and {{Bank-Address}} below with their own vendor and bank names.

Creating a Salesforce contract from an opportunity

  1. Go to the Salesforce Home tab to upload the template.

Setting up contracts in Salesforce in Home tab

  1. In File Explorer, click Upload Files.

Salesforce contract template upload button

  1. Upload the template you created.

Now, you can generate contracts or generate Salesforce agreements by using the template. 5. To open the template, go to File Explorer > Search. Type the file name and open it.

The file opens in the Salesforce main window.

Note: If the file does not automatically open, you may need to download a local copy first.

Search for Salesforce contract template in File Explorer

  1. Once the template displays, go to the File Explorer section, and click Document Generation.

Salesforce contract generator using Document Generation button.

  1. The template keys display on the right-hand side of the screen. Replace the text in each value field with your custom data.

For example, where the first value displays “Replace {{Bank}},” click and type in the real bank name.

Automating contracts using the Template Keys options.

  1. Fill out the remaining value keys.

Auto generate contracts using the Document Generation Key Values.

  1. When finished, scroll to the bottom of the Document Generation section, and click Fill Template.

This applies all your custom key values to the contract template.

Create PDF contract from Salesforce

  1. To download a PDF copy of your new customized contract, click the gear wheel, then click Download.

Download Option in Salesforce Home tab

The file now opens in your PDF viewer.
  1. To download a PDF copy of your new customized contract, click the gear wheel, then click Download.

Wrap Up

And that’s it! You’ve created a contract template to customize whenever you generate new contracts. Use it daily and streamline your quoting and proposal process.

You can also consider adding more professional, Salesforce-native features down the road, such as annotations, digital signatures, redaction, collaboration, and much, much more.

The WebViewer LWC contract generator is just one part of our definitive document application development platform for Salesforce. This lets you easily build complete and professional document experiences for Salesforce that are fully customizable. The built-in viewer UI is also fully developer friendly, which means they will have little problem tailoring it to match any specific workflow requirements.

Benefits of Dynamic, Salesforce-Native Contract Generation

  • Securely merge data directly in your Salesforce solution. No need to share confidential data with anyone!
  • Directly import templates in open Office formats designed with familiar Office tools (MS Office, WPS, LibreOffice, Google Office, etc.) or anything that can create a DOCX, XLSX, or PPTX file.
  • Avoid vendor lock-in with open-standard Microsoft Office format templates and leverage existing collections of ready-to-use templates.
  • Prevent server bottlenecks by generating documents on the fly directly in the browser.
  • Embed the document viewing experience directly into your solution.
  • Top-quality PDF generation and accurate, dynamic reflow via the market leading PDFTron SDK, repackaged for your needs on the Salesforce platform!

Next Steps

For more information on our Salesforce contract generation, visit our Salesforce page or our PDF Generation Library using JavaScript page.

Developers can check out our Salesforce documentation, including Office document generation via JavaScript.

Start your free trial today with unlimited usage. And should you have any questions or feedback -- don’t hesitate to talk to one of our product specialists or the developers who built the product for support. We’d be delighted to help.