function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Adriana Smith 9Adriana Smith 9 

Create PDF Document from Custom Object

I've created a custom object called Invoices, related to Opportunities.  I've added a ton of custom fields, autonumber fields, etc.  What I need is to have a button that says 'create pdf' like how quotes work.  I would also LOVE to have templates so I can play with the pdf.  Pretty much, I need this new invoices custom object to act just like how quotes work.... 

So I don't know where to start....
LBKLBK
Hi Adriana,

You can build a VF page to achieve this.

You can pretty much throw in any HTML content to it (Logos, images, colors, etc.,) and render the final output as PDF.

You can add a button to your Page Layout to execute this VF page on click of this button.

Let me know if you need any more information.
Adriana Smith 9Adriana Smith 9
So, I can create a custom button, I can create lookup fields... I'll try to create a VF page (I'm bad at writing VF), BUT, how would I PDF the final output?
LBKLBK
You can use the renderAs option in apex:page tag.
It will look like this (below) in your VF page.
<apex:page renderAs="pdf">
Please refer the reference links below for more information on this.
https://help.salesforce.com/articleView?id=000004706&type=1
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_renderas_pdf.htm

Let me know if this helps.
Adriana Smith 9Adriana Smith 9
As I'm new to writing VF,  the first reference is very helpful.  How would I add in logos, fields, editable sections, etc and move them around on the pdf?
LBKLBK
I believe all your editable components (like text boxes, picklists, etc.) would be part of your page layout.

You just need to add the output fields to populate the VF page with all the info and render it as PDF.

Here are some sample references.
https://developer.salesforce.com/forums/?id=906F000000097liIAA
https://www.interactiveties.com/blog/2015/render-visualforce-pdf.php

 
Hermes Gomez 3Hermes Gomez 3
What if also we need a button that says "SEND PDF" that will automatically send the pdf to the email on a contact lookup field on the record?