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
Madhuri GowdaMadhuri Gowda 

Creating a Custom save to pdf Button ON a Visual Force Page

Hello All

i need a small help

i have already created a VF page, i have put it in a custom button called "Generate PDF ", now i need a Button called "Save & Send Email " where a PDF should get saved and email must be sent to its related contact, just like Quote PDF (Save & Email Quote)

i tried to refer the below links 

https://developer.salesforce.com/forums/?id=9060G000000Xj73QAC

but dint have any luck, can anyone please help
Deepali KulshresthaDeepali Kulshrestha
Hi Manjunath,

I've gone through your requirements and you can find below code helpful:

If you need not only convert your page to PDF but save this file with a specific name here is a workaround. You will need two pages. First page generates an PDF file and second saves it with specific filename:

The main "wrapper" page saves PDF and gives a filename:
<apex:page id="MainPage"
           showHeader="false"
           cache="true"
           contentType="application/x-pdf#Here-is-your-filename.pdf">
 
    <!-- Here comes another page with a content to be converted to PDF -->
    <apex:include pageName="PageThatGeneratesPdf"/>
</apex:page>
PageThatGeneratesPdf - only generates PDF content:

<apex:page showHeader="false"
           renderAs="PDF"
           cache="true">

<head>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

<style type="text/css">

@page{

    size:A4 portrait;

    @bottom-right {
        content: "Page " counter(page) " - " counter(pages);
        font-family: 'Arial', 'Helvetica', sans-serif;
        font-size:10px;

    }
}

</stype>

</head>

Here is your main content ...

</apex:page>


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com