You need to sign in to do that
Don't have an account?

'Failed to load document' error after PDF save.?
I am opening a pop up VF page as 'render as pdf'.I have created a button Save and on click on save i am closing the pop window and saving PDf to opportunity.
Issue
When i am saving the code when calling the savePdf method without rerender and oncomplete.Its saving the attachment and i am able to open the attachment in opportunity without issue.When i am using either using rerender or oncomplete i am able to save the attachment but it says ".'Failed to load document'"
Its been a week i am stuck please help.
Class
Issue
When i am saving the code when calling the savePdf method without rerender and oncomplete.Its saving the attachment and i am able to open the attachment in opportunity without issue.When i am using either using rerender or oncomplete i am able to save the attachment but it says ".'Failed to load document'"
Its been a week i am stuck please help.
<apex:form> function myClose(){ self.close(); window.opener.location.href="/{!$CurrentPage.parameters.Id}"; //you could also use self.close(); } <apex:pageBlock mode="maindetail" id="thePb"> <apex:pageBlockButtons > <apex:commandButton value="Save to Opportunity" action="{!savePdf}" oncomplete="myClose();" /> </apex:pageBlockButtons> <apex:pageMessages /> <iframe height="600px" id="Page" name="InvoicePDF" src="/apex/GenerateQuotePDF?id={!parentId}" width="100%"></iframe> </apex:pageBlock> </apex:form>
Class
public void savePdf() { PageReference pdf = Page.GenerateQuotePDF; pdf.getParameters().put('id',parentId); pdf.setRedirect(true); // create the new attachment Attachment attach = new Attachment(); // the contents of the attachment from the pdf Blob body; body = pdf.getContent(); attach.Body = body; // add the user entered name attach.Name = 'Opportunity'+ '.pdf'; attach.IsPrivate = false; // attach the pdf to the account attach.ParentId = parentId; attach.ContentType = 'application/pdf'; insert attach; }
Any suggestions,..
VF page :
Apex Class : Can you remove the iFram tag from your VF page and another thing your onComplete function would only work if your action method returns true,if it is returning false it won't.
Hope this helps !!
I cant remove iFrame as its my inner page.On outer page i have save buttons.If i remove iframe PDF will not come.Both of them have a same controller.
I am stuck on this issue for a week now but no solution