Exception during GdPictureDocumentConverter.ConvertToPDF or GdPictureDocumentConverter.LoadFromStream using .eml file

Discussions about image processing and document imaging.
Post Reply
MGR
Posts: 2
Joined: Mon Apr 17, 2023 1:04 pm

Exception during GdPictureDocumentConverter.ConvertToPDF or GdPictureDocumentConverter.LoadFromStream using .eml file

Post by MGR » Mon Apr 17, 2023 1:26 pm

Hello,

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)
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):

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.

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: Exception during GdPictureDocumentConverter.ConvertToPDF or GdPictureDocumentConverter.LoadFromStream using .eml fil

Post by Hugo » Tue Apr 18, 2023 4:10 pm

Hi there,

For EML to PDF conversion you need to have a web browser installed on your machine. We suggest chrome however MS Edge also works fine.
You can use the following methods to better manage and control this:
https://www.gdpicture.com/guides/gdpict ... rPath.html
https://www.gdpicture.com/guides/gdpict ... rPath.html
https://www.gdpicture.com/guides/gdpict ... lable.html

If you have all of this installed then please make sure you are using our latest version (currently V14.2.24):
https://www.gdpicture.com/download-gdpicture/

If your issue still persists, I will be needing the input file EML which you are using so I can reproduce this on my end. This may be private data so you can contact us here to provide this:
https://orpalis.zendesk.com/hc/en-us/requests/new

Regards,
Hugo Cudd
Technical Support

MGR
Posts: 2
Joined: Mon Apr 17, 2023 1:04 pm

Re: Exception during GdPictureDocumentConverter.ConvertToPDF or GdPictureDocumentConverter.LoadFromStream using .eml fil

Post by MGR » Fri Apr 21, 2023 11:58 am

I tested it with V14.2.24 and the issue does not happen anymore, but for us, it's not the solution, as we cannot for older versions update the GdPicture 14.1.0.135
Is it possible any workaround or code solution to avoid this exception? I found very similar ticket https://www.gdpicture.com/forum/viewtopic.php?t=6778 but the solution with changing to:

Code: Select all

using (Stream inputStream = File.Open("input.html", System.IO.FileMode.Open, FileAccess.Read, FileShare.Read))
doesn't work for me.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest