0

I have "Generate Attachment" button on VF page. when i click on that button. The Same VF pages Save as Pdf in "Notes & Attachment releted list" in Opportunity object. But Pdf Showing the Marks of button on it. So how to Remove the Marks of Button from PDF and I dont want to use RenderAs = "pdf"

Below Pdf Image

enter image description here

my controller is

public PageReference attachPDF() {
    SaveAttachment  = true;
    PageReference pdf =  new PageReference('/apex/MyPageThatGeneratePdf'); 

    Blob body = pdf.getContentAsPDF();
    Attachment attach = new Attachment(); 
    attach.parentId =  oppid;
    attach.Name = 'PDf ';
    attach.body =body;
    attach.IsPrivate = false;
    insert attach;



     return null;
      }  

and VF page is

<apex:commandButton value="Generate Attachment"  action="{!attachPDF}" 
            rendered="{!$CurrentPage.Parameters.flatid != null && !SaveAttachment}" 
            style="margin-right:4px;"   />    
0

I assume that you are using the same Visualforce Page for creating the PDF. You could try using the following style :

<style type="text/css" media="print">
.btn { display: none; }
</style>
1
  • Yeah I used this but It is not working.
    – Sfdce
    Jul 12 '16 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.