| 
		
	 | 
	
	
	
		Rank: Member Groups: Member
 
 
Joined: 8/27/2013 Posts: 11 
	 | 
		   
	     
		    Hi,
  I've used [RenderAsPDF(AutoConvert = false)] a lot and that works great, I now have a different scenario where I need to create a PDF attachment and send it via email.
  I have it all working with: HtmlToPdf.ConvertUrl(pdfUrl, memoryStream, options); //options contain cookie credentials
  The generated PDF is only 50KB so do you have any idea why it takes 30 + seconds to generate?
  Thanks, Kevin
		 
	 | 
 | 
	
	
	
		Rank: Administration Groups: Administration
 
 
Joined: 5/27/2007 Posts: 24,427 
	 | 
		   
	    
		    Hi, This is usually due to ASP.NET session lock. Please see here for a detailed description of the problem: http://www.essentialobjects.com/forum/postst8527_This-session-is-no-longer-valid-If-you-wish-to-reuse-the-session-later-please-consider-calling-GetCookies-to-retain-the-sessio.aspxGenerally, you should avoid calling ConvertUrl back to your own site. If you wish to send the page via email, you can follow the steps here: http://www.essentialobjects.com/doc/4/web/mvc.aspx#saveThe sample code calls PdfDocument.Save to save the file into a physical file. If you do not want a physical file, you can use a MemoryStream and save it to a MemoryStream instead. Then you can get a get byte array from the MemoryStream and pass that to your email module. Thanks!
		  
	 | 
 | 
	
	
	
		Rank: Member Groups: Member
 
 
Joined: 8/27/2013 Posts: 11 
	 | 
		   
	     
		    Have you got an example of an action that calls another action that has the PDF attribute on it?
  e.g.
          public ActionResult MethodA()         {             var pdfStream = GeneratePdf();
              //How do I get a memoryStream of the view GeneratedPdf?
              return View();         }
          [RenderAsPDF(AutoConvert = false, SendToClient = false)]         public ActionResult GeneratePdf()         {             return View();         }
  Thanks, Kevin
		 
	 | 
 | 
	
	
	
		Rank: Administration Groups: Administration
 
 
Joined: 5/27/2007 Posts: 24,427 
	 | 
		   
	     
		    Hi,
  I am not sure if I understand your question correctly. If you wish to call one action directly as a function from another action, it shouldn't have anything to do with RenderAsPDF attribute.
  Thanks!
		 
	 | 
 | 
	
	
	
		Rank: Member Groups: Member
 
 
Joined: 8/27/2013 Posts: 11 
	 | 
		   
	     
		    Hi,
  In my example, OnResultExecuted is called twice but the result is empty for the the action GeneratePdf(). I only want an attachment PDF generated for GeneratedPdf() but it needs to be called via MethodA().
  [RenderAsPDF(SendToClient = false)] public ActionResult MethodA() { var pdfStream = GeneratePdf();
  //How do I get a memoryStream of the view GeneratedPdf?
  return View(); }
  [RenderAsPDF(SendToClient = false)] public ActionResult GeneratePdf() { return View(); }
  protected override void OnResultExecuted(ResultExecutedContext filterContext) {             base.OnResultExecuted(filterContext);
              EO.Pdf.HtmlToPdfResult result = MVCToPDF.Result;
              if (result != null)             {                 //this is null for GeneratePdf();                 //I only get a result for MethodA(); when I open that PDF I get 'Object moved here' and the word 'here' is a URL to the page that I want a PDF generated of.             } } 
		 
	 | 
 | 
	
	
	
		Rank: Administration Groups: Administration
 
 
Joined: 5/27/2007 Posts: 24,427 
	 | 
		   
	    
		    Hi, I am still not exactly sure what you are trying to do. You can try to isolate the problem into a test project and send the test project to us and we will be happy to take a look. Please see test project guideline here: http://www.essentialobjects.com/forum/test_project.aspxThanks!
		  
	 | 
 |