Skip to main content
added 186 characters in body
Source Link
Nick
  • 7.2k
  • 27
  • 147
  • 286

EDIT:

I have no problem viewing the page and it does display the fields but my problem is when you generate content as pdf it does not show the visualforce page content in the PDF

I have a standard page and in that standard page layout I have added Custom Visualforce page and added a Detail Page Button at the top of the page layout. when the user clicks on the page it execute the code below to generate the PDF and attach to notes/attachments, all is good so far.

PageReference pagePdf = new PageReference('/'+parentId);         
pagePdf.getParameters().put('id', parentId); 
Attachment a = new Attachment();
a.Body = pagePdf.getContentAsPDF();
a.ParentID = parentId; 
a.Name = 'Attach.pdf';
insert a; 

The issue I see is that it does not generate visualforce page fields at all.

How do I solve this issue? any thoughts?

I have a standard page and in that standard page layout I have added Custom Visualforce page and added a Detail Page Button at the top of the page layout. when the user clicks on the page it execute the code below to generate the PDF and attach to notes/attachments, all is good so far.

PageReference pagePdf = new PageReference('/'+parentId);         
pagePdf.getParameters().put('id', parentId); 
Attachment a = new Attachment();
a.Body = pagePdf.getContentAsPDF();
a.ParentID = parentId; 
a.Name = 'Attach.pdf';
insert a; 

The issue I see is that it does not generate visualforce page fields at all.

How do I solve this issue? any thoughts?

EDIT:

I have no problem viewing the page and it does display the fields but my problem is when you generate content as pdf it does not show the visualforce page content in the PDF

I have a standard page and in that standard page layout I have added Custom Visualforce page and added a Detail Page Button at the top of the page layout. when the user clicks on the page it execute the code below to generate the PDF and attach to notes/attachments, all is good so far.

PageReference pagePdf = new PageReference('/'+parentId);         
pagePdf.getParameters().put('id', parentId); 
Attachment a = new Attachment();
a.Body = pagePdf.getContentAsPDF();
a.ParentID = parentId; 
a.Name = 'Attach.pdf';
insert a; 

The issue I see is that it does not generate visualforce page fields at all.

How do I solve this issue? any thoughts?

Source Link
Nick
  • 7.2k
  • 27
  • 147
  • 286

getContentAsPDF: Not generating custom Visualforce page

I have a standard page and in that standard page layout I have added Custom Visualforce page and added a Detail Page Button at the top of the page layout. when the user clicks on the page it execute the code below to generate the PDF and attach to notes/attachments, all is good so far.

PageReference pagePdf = new PageReference('/'+parentId);         
pagePdf.getParameters().put('id', parentId); 
Attachment a = new Attachment();
a.Body = pagePdf.getContentAsPDF();
a.ParentID = parentId; 
a.Name = 'Attach.pdf';
insert a; 

The issue I see is that it does not generate visualforce page fields at all.

How do I solve this issue? any thoughts?