Exception during GdPictureDocumentConverter.ConvertToPDF or GdPictureDocumentConverter.LoadFromStream using .eml file
Posted: Mon Apr 17, 2023 1:26 pm
Hello,
When I try to convert the eml file to the pdf I get following exception:
It doesn't matter if I use ConvertToPDF or try to LoadFromStream(exception happens already on load) then SaveAsPDF.
Below you can see code snippets for both scenarios (they are basically copies from the documentation (https://www.gdpicture.com/guides/gdpict ... rmat).html https://www.gdpicture.com/guides/gdpict ... eight.html), so I would suspect it should work):
I would be really grateful for help.
When I try to convert the eml file to the pdf I get following exception:
Code: Select all
System.Exception: You cannot set LocalEdnPoint after you start the connection.
at gdpicture_⒃.gdpicture_ᦛ(EndPoint A_0)
at gdpicture_⑼.ᦁ()
at gdpicture_⑺.ᦁ()
at gdpicture_⒃.ᦃ()
at gdpicture_⒘.ᜀ(Int32 A_0, String A_1)
at gdpicture_Ⓞ.gdpicture_ᧃ(gdpicture_⒘ A_0, gdpicture_⒙ A_1)
at gdpicture_⒘.gdpicture_ᜀ(gdpicture_⒙ A_0)
at gdpicture_⒘.gdpicture_ᜀ(Byte[] A_0, Int32 A_1, Int32 A_2)
at gdpicture_⒘.gdpicture_ᜀ(Object A_0, gdpicture_⑽ A_1)
at gdpicture_⑼.gdpicture_ᜀ(Byte[] A_0, Int32 A_1, Int32 A_2)
at gdpicture_⑺.gdpicture_ᜀ(SocketAsyncEventArgs A_0)
at gdpicture_⑺.gdpicture_(Object A_0, SocketAsyncEventArgs A_1)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.ExecutionCallback(Object ignored)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
Below you can see code snippets for both scenarios (they are basically copies from the documentation (https://www.gdpicture.com/guides/gdpict ... rmat).html https://www.gdpicture.com/guides/gdpict ... eight.html), so I would suspect it should work):
Code: Select all
var fileName = @"C:\temp\testFile.eml";
var output = @"C:\temp\test.pdf";
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Set the text and document properties to be used for the resulting file.
gdpictureDocumentConverter.EmailPageHeight = 612; // A3 page size
gdpictureDocumentConverter.EmailPageWidth = 1191; // A3 page size
gdpictureDocumentConverter.EmailPageMarginTop = 10;
gdpictureDocumentConverter.EmailPageMarginBottom = 10;
gdpictureDocumentConverter.EmailPageMarginLeft = 10;
gdpictureDocumentConverter.EmailPageMarginRight = 10;
using (Stream inputStream = File.Open(fileName, System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create(output))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatEML, outputStream, PdfConformance.PDF1_5);
}
}
}
Code: Select all
var fileName = @"C:\temp\testFile.eml";
var output = @"C:\temp\test.pdf";
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
using (System.IO.Stream fileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open))
{
// Loading the source document.
gdpictureDocumentConverter.LoadFromStream(fileStream, GdPicture14.DocumentFormat.DocumentFormatEML);
// Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF(output, PdfConformance.PDF1_5);
}
}
I would be really grateful for help.