I have created a customer signup form using VF page and Html Tags. In Account object I have created one formula field to reach this form via Account object. If the user reach the form via account the Account details should be auto populated in the form and there is one place available for getting the customer signature. I have done all the above said process but I am facing some issues while I am trying to save this form as a PDF in the attachment of the particular account.After the PDF generation the PDF should be sent as a Email to the user automatically via code. We tried both renderAs='PDF' and getContentAsPdf() but we are getting the same error "PDF Generation Failed Check the Page Markup is valid" Can any one please guide me on the PDF generation part?

  • Please add some code .And Pdf markup failed means there is something wrong in the visualforce code .So first remove RenderAs='pdf' and use in normal and then try debugging Jan 7, 2014 at 7:19

1 Answer 1


If your visualforce page (page which you are rendering as pdf) is working properly then please see following code to get visualforce page content as pdf.

PageReference pageRef = new PageReference('/apex/MyPage');
Blob pdfBlob = pageRef.getContent();

Now you can use this Blob data to send as an attachment.

Just for an information, I'm using this code in different visualforce page controller than the one which I'm rendering as pdf.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .