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?
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'); pageRef.getParameters().put('id',account.Id); 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.