Find your content:

Search form

You are here

How to print a quote or invoice from salesforce

 
Share

How do I print a Bill, or an Invoice on a custom object on the click of a button.

Things I've thought of

  • Printable view : it does not give me the control to change the formatting
  • Visualforce Page : gives me the styling but how do I automate the printing without multiple clicks?
  • AppExchange Apps : I tried a couple of freebies, but they Don't work when I took a test drive

Thanks for the help !!


Attribution to: Shivanath D

Possible Suggestion/Solution #1

I haven't tried this personally, and am somewhat skeptical that this would work, but you could try:

  1. Create a PDF Visualforce page (See Daniel Ballinger's comment)
  2. Invoking window.print() on the VF page
  3. Creating a custom visualforce button on the object's page layout that opens the VF page.

Attribution to: James Loghry

Possible Suggestion/Solution #2

This is the best solution I could think of and it requires a Visualforce page:

<apex:page >
    <script>      
        window.onload = function() { 
            window.print();
        }
    </script>
    <h1>Congratulations</h1>
    <p>This is your new invoice!</p>
</apex:page>

This will render as:

Immediate print

When you close the print popup, you get this:

Screen capture

The <h1> and the <p> tag were put in there purely as test data. The way this works, the page will load and the window.onload event will fire, which will immediately request for the page to be printed. Unfortunately, this will not be a PDF version, but using CSS Media Types, you can style this page using the @media print annotation. Let's take a quick look at that in action:

<apex:page >
    <script>      
        window.onload = function() { 
            window.print();
        }
    </script>
    <style>
        @media print{
            h1{
                font-size:120px;
            }
            p{
                font-size: 70px;
            }
        }
    </style>
    <h1>Congratulations</h1>
    <p>This is your new invoice!</p>
</apex:page>

which will render as:

Print with Large Font

However, when you click cancel, the page will view as:

Non printed page

Notice how the display of the text changed in the first load in the print preview, yet the page itself didn't change. That is the power of @media print. Using Visualforce, HTML, CSS, and Javascript, you can definitely get this all to work. You can strip it down and basically do whatever you want.

The easy thing to then do in order to make this a single click is to simply create a custom button that points to your Visualforce page. The Visualforce page itself will handle all the rest.


Attribution to: Jesse Altman

Possible Suggestion/Solution #3

One of the most popular solutions is Conga Composer by AppExtremes. I've used it successfully for several applications. Their support is excellent as well.


Attribution to: Bryan Boroughf

Possible Suggestion/Solution #4

So if I understand correctly, you want to render a view (lets say a PDF) and have that PDF print out without having to download the pdf first and print it manually?

while I don't have a packaged solution, you could achieve a one click solution by putting together a print server on your network that is customized for receiving print requests from the web.

The flow would look a bit like this:

  1. person clicks button, a pdf is rendered.
  2. the pdf is sent (encoded) to a third party service that then sends the print request to your printer.
  3. your publicly available web printer or software on an attached computer would receive the request and start printing the pdf.

you could cut step 2 out if you had a print server on your network that would just wait for print requests from the web.


Attribution to: ebt
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/495

My Block Status

My Block Content