Hi,
I tried to convert a simple .txt file to Pdf:
But I get the following exception upon first line in try block:
"Attempted to read past the end of the stream."
Hi,
I tried to convert a simple .txt file to Pdf:
Hello,
If you will need any help or you will have any other questions please feel free to ask.
Warm Regards
Hi Leap,
Hi leap ,
We just changed the Project Properties and Target Framework to .NET Framework 4.5 of your provided sample project and found no issue in it, everything works great.
If you will need any help or you will have any other questions please feel free to ask.
Warm Regards,
Muhammad,
I tried the same and no success. Here is the project with .net framework ver 4.5:
https://drive.google.com/open?id=0B6C2p6WGgdycYU5DbHVfQkpxNEk
Hello,
using GroupDocs.Conversion.Config;using GroupDocs.Conversion.Converter.Option;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace DocConvert{class Program{static void Main(string[] args){string workingFolder = @“e:”;string textFilePath = @“e:\test.txt”;var config = new ConversionConfig(){OutputPath = Combine(workingFolder, “temp”),CachePath = Combine(workingFolder, “temp”),LocalesPath = Combine(workingFolder, “temp”),StoragePath = Combine(workingFolder, “temp”),UseCache = false};GroupDocs.Conversion.Handler.ConversionHandler handler = new GroupDocs.Conversion.Handler.ConversionHandler(config);PdfSaveOptions saveOptions = new PdfSaveOptions(){ConvertFileType = PdfSaveOptions.PdfFileType.Pdf,PageNumber = 1,NumPagesToConvert = 1,OutputType=OutputType.String};try{var memStream = new MemoryStream(File.ReadAllBytes(textFilePath));var stream = handler.Convert(memStream, saveOptions);//var bytes = new byte[stream.Length];}catch (Exception ex){throw ex;}}private static string Combine(string workingFolder, string folder){return Path.Combine(workingFolder, folder);}}}
Hi Muhammad.
Thanks for consideration so far.
I copied and pasted the code: No Success and the same exact exception.
I’m very curious to know if you tested on the very last solution I provided. It’s .in net 4.5 and is using groupdocs.conversion 3.1.0.
By the way, I install groupdocs.conversion using Nuget:
Install-Package groupdocs-conversion-dotnet
I hope this information helps.
Bests
Hi,
Hi Muhammd,
Unfortunately, it didn’t work. but:
1- The only overload by which I could generate a proper pdf file (and not a stream) was:
handler.Convert(fileStream, outputFileName, stringSaveOptions);
2- I tried to use this overload to receive back a stream:
handler.Convert(fileStream, outputFileName, streamSaveOptions);
and it worked as well.
Hi,
Please find below some resources to quickly get started with GroupDocs.Conversion API.
If you will need any help or you will have any other questions please feel free to ask.
Warm Regards