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
Niki Shah 12Niki Shah 12 

How to create pdf save on same object page.

I made one custom object and i display as a pdf but the same pdf i want to save on same object page like quotes can you please help me.
Raj VakatiRaj Vakati
You can create attachment  like below from the Visualforce page render as pdf 

 
//generate and attach the PDF document
		PageReference pdfPage = Page.pdfDemo; //create a page reference to our pdfDemo Visualforce page, which was created from the post https://interactiveties.com/blog/2015/render-visualforce-pdf.php
		Blob pdfBlob; //create a blob for the PDF content
		if (!Test.isRunningTest()) { //if we are not in testing context
			pdfBlob = pdfPage.getContent(); //generate the pdf blob
		} else { //otherwise, we are in testing context and getContent() gets funky so create the blob manually
			pdfBlob = Blob.valueOf('Some Text for a boring PDF file...');
		}
		Attachment attach = new Attachment(parentId = a.Id, Name = 'pdfAttachmentDemo.pdf', body = pdfBlob); //create the attachment object
		insert attach; //insert the attachment

http://www.interactiveties.com/blog/2015/visualforce-button-pdf.php
https://salesforce.stackexchange.com/questions/89607/save-pdf-as-a-attachement-in-notes-and-attachment-using-apex-classwithout-click
https://www.sundoginteractive.com/blog/saving-a-pdf-attachment-salesforce
https://developer.salesforce.com/forums/?id=906F0000000BRF2IAO
https://pradeepgali.blogspot.com/2013/06/how-to-save-rendered-pdf-file-as.html
https://blog.jeffdouglas.com/2010/07/14/attach-a-pdf-to-a-record-in-salesforce/