Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Jul 15, 2021 9:05 am

Hello. I am having a problem while saving a dock file to a stream pdf format

Code: Select all
public async Task<FileModel> ConvertDocToPdfAsync(IFormFile file, string resultFileName)
{
Document document = new();
using (Stream stream = file.OpenReadStream())
using (MemoryStream targetStream = new())
{
document.LoadFromStream(stream, Spire.Doc.FileFormat.Auto);
document.SaveToStream(stream, Spire.Doc.FileFormat.PDF); //  error
return FileModel.Build(resultFileName, targetStream.ToArray());
}
}




"Message": "Specified method is not supported.",
"Data": null,
"InnerException": {
"$type": "System.NotSupportedException, System.Private.CoreLib",
"ClassName": "System.NotSupportedException",
"Message": "Specified method is not supported.",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at Microsoft.AspNetCore.Http.ReferenceReadStream.Write(Byte[] buffer, Int32 offset, Int32 count)\r\n at System.IO.Stream.WriteByte(Byte value)\r\n at spr㚳.ᜂ(String A_0)\r\n at spr㚏.ᜅ(Stream A_0, spr㚞 A_1, Boolean A_2)\r\n

s.shevyakov
 
Posts: 18
Joined: Thu Jul 15, 2021 8:42 am

Thu Jul 15, 2021 9:46 am

Hello,

Thanks for your inquiry.
Please refer to the following modified code.
Code: Select all
                //document.SaveToStream(stream, Spire.Doc.FileFormat.PDF);
                document.SaveToStream(targetStream, Spire.Doc.FileFormat.PDF);

If there are any other issues related to our products, just feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Jul 15, 2021 10:12 am

Thank you very much, carelessness was the cause of the error

s.shevyakov
 
Posts: 18
Joined: Thu Jul 15, 2021 8:42 am

Fri Jul 16, 2021 1:12 am

Thanks for your feedback.
If you need any other help, just feel free to let us know. We are always here to help.
Have a nice day!

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc

cron