Thanks, I need to also set position to 0
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Groupdocs.Web.UI.Conversion;
using Groupdocs.Common;
using System.Diagnostics;
namespace TestGroup
{
class Program
{
static void Main(string[] args)
{
using (MemoryStream memoryStream = new MemoryStream())
{
using (FileStream fileStream = new FileStream("ToConvert/doc1.docx", FileMode.Open, FileAccess.Read))
{
// copy file to memory
fileStream.CopyTo(memoryStream);
// init
GroupdocsConversion.SetRootStoragePath(Path.Combine(Environment.CurrentDirectory, ""));
GroupdocsConversion.Init();
var conversion = GroupdocsConversion.Instance();
// convert memory stream or filestream
memoryStream.Position = 0;
var converted = conversion.Convert(memoryStream, FileType.Docx, FileType.Pdf);
var streams = converted.StreamConversionResult();
FileType testresult = streams.StreamItems[0].FileType;
var result = (MemoryStream)streams.StreamItems[0].Stream;
// and save it to file
using (FileStream file2 = new FileStream("test.pdf", FileMode.Create, System.IO.FileAccess.Write))
{
result.Position = 0;
result.WriteTo(file2);
}
Console.WriteLine("Finished!");
Console.ReadKey();
}
}
}
}
}