PdfDocument save("output") does not work?

Hi tried to follow this example "https://www.syncfusion.com/kb/9893/how-to-convert-form-authenticated-webpage-to-pdf-using-c-and-vb-net", went step by step, got stuck at line 22:

document.Save("AuthenticatedWebPage.pdf", HttpContext.Current.Response, Syncfusion.Pdf.HttpReadType.Save);

VS Studio is complaining that the "save()" method only take Stream as parameter, nothing else.


So just wondering why this sample code won't even work. 

Any advice is appreciated!

1 Reply

SL Sowmiya Loganathan Syncfusion Team April 15, 2020 11:59 AM UTC

Hi Mac,    
   
Thank you for contacting Syncfusion support.    
   
We have analyzed the mentioned query and suspect that you were trying to run the sample (mentioned in this KB https://www.syncfusion.com/kb/9893/how-to-convert-form-authenticated-webpage-to-pdf-using-c-and-vb-net) in ASP.NET Core platform. Due to platform limitation, in the ASP.NET Core platform, we need to save the PDF document as a memory stream only. Please refer the below documentation for more details,    
  
So kindly use the below code snippet to save the PDF document in ASP.NET Core platform and refer the below KB link if you have any doubts on this,    
  
//Saving the PDF to the MemoryStream   
MemoryStream stream = new MemoryStream();   
    
document.Save(stream);   
    
//Set the position as '0'.   
stream.Position = 0;   
    
//Download the PDF document in the browser   
FileStreamResult fileStreamResult = new FileStreamResult(stream, "application/pdf");   
    
fileStreamResult.FileDownloadName = "Sample.pdf";   
    
return fileStreamResult;   
   
Please let us know if you need any further assistance with this.    
   
Regards, 
Sowmiya Loganathan 


Loader.
Up arrow icon