Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Mar 25, 2019 10:20 am

Hi Sir/Madam,

Sorry to bother u.
I would like to generate a PDF and send it to Client browser. My solution is based on .Net core 2.0. And I was trying to use SaveToHttpResponse as per existing instruction.

However, seems like this SaveToHttpResponse is not applicable for .NET core 2.0 in the package: ".nuget\packages\spire.pdf\5.3.8\lib\netstandard2.0\Spire.Pdf.dll".
The error msg is
-------------------------
"'PdfDocument' does not contain a definition for 'SaveToHttpResponse' and no accessible extension method 'SaveToHttpResponse' accepting a first argument of type 'PdfDocument' could be found (are you missing a using directive or an assembly reference?)"
-------------------------

Could you suggest how i can send the pdf to client browser for my case?

Thanks.

emoryxu
 
Posts: 7
Joined: Mon Mar 25, 2019 10:03 am

Tue Mar 26, 2019 6:16 am

Hello,

Thanks for your inquiry.
Sorry to tell that our Spire.PDF for .NET Core doesn't support the function SaveToHttpResponse at present, we will add the new feature into our future list. If it is achieved in the future, we will inform you. For your case, you could first save to stream, then output the stream to client browser.
Code: Select all
pdf.SaveToStream(stream, FileFormat.PDF);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Apr 09, 2019 12:02 pm

Hi,

Im planning to use the FreeSpire.PDF in my .NetCore App.
It seems to have a dependency on Microsoft.Win32.SystemEvents

So im curious, that after adding this library, will my project still be a cross platform app?

sunainaDG
 
Posts: 3
Joined: Tue Apr 09, 2019 11:56 am

Wed Apr 10, 2019 6:50 am

Hello,

Thanks for your inquiry.
Please note that the Microsoft.Win32.SystemEvents is a common assemble of .NET Core application. It would not affect your cross platform app (.NET Core). Our Spire.PDF supports working with .NET Core, just go for it. If there is any question, just feel free to write back.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Wed Dec 30, 2020 5:33 am

Dear Emory,

Sorry for long silence.
The principle of internal implementation of the new feature SaveToHttpResponse in our Spire.PDF is first saving to stream, then using the HTTP Response to post the stream to browser. After our development's discussion, we decided not to provide this method in NET Core anymore. Please try my previous suggestion that using our Spire.PDF to save document to stream, then using the HTTP Response to post the stream to browser. Any other question, please feel free to write back.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Mar 16, 2021 8:19 pm

Nina.Tang wrote:Hello,
For your case, you could first save to stream, then output the stream to client browser.
Code: Select all
pdf.SaveToStream(stream, FileFormat.PDF);

Sincerely,
Nina
E-iceblue support team


Would you please demonstrate exactly how to output the stream to the client browser in .NET Core? Let's assume it's a controller ActionResult being called from a button on a view. Do you have to do a byte conversion on the stream and return a response?

Thanks.

mtceegee
 
Posts: 17
Joined: Wed Oct 28, 2020 4:32 pm

Wed Mar 17, 2021 9:51 am

Hello,

Thanks for your inquiry.
Please refer to the following code to achieve your needs. Feel free to contact us if you have further issues.
Code: Select all
        public IActionResult Download()
        {
            PdfDocument pdf = new PdfDocument();
            //....

            //save pdf to stream
            MemoryStream ms = new MemoryStream();
            pdf.SaveToStream(ms, FileFormat.PDF);         
            return File(ms.ToArray(), "application/pdf", "text.pdf");
        }


Sincerely
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Return to Spire.PDF