I get an AccessViolationException when using the PdfDocument.SaveAsImage function. the function works and it saves the images but after saving a couple of images it throws me the error.
Here is the code I am using:
- Code: Select all
Try
Dim image As Image = Nothing
image = doc.SaveAsImage(page - 1, PdfImageType.Metafile)
image.Save(TestFileName.Replace(".pdf", "_t" + page.ToString + ".png"))
image.Dispose()
Catch ex As AccessViolationException
Catch ex As Exception
Console.Write(ex.Message)
End Try
And this is the error:
System.AccessViolationException was unhandled
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=System.Drawing
StackTrace:
at System.Drawing.SafeNativeMethods.Gdip.GdipFillPath(HandleRef graphics, HandleRef brush, HandleRef path)
at System.Drawing.Graphics.FillPath(Brush brush, GraphicsPath path)
at spr6393.0(FillMode A_0)
at spr6393.0(spr5017 A_0)
at spr6393.7(Boolean A_0)
at spr6393.40()
at spr728.0(Single A_0, Boolean A_1)
at Spire.Pdf.PdfDocumentBase.0(Stream A_0, Int32 A_1)
at Spire.Pdf.PdfDocumentBase.0(Int32 A_0, PdfImageType A_1)
at Spire.Pdf.PdfDocument.SaveAsImage(Int32 pageIndex, PdfImageType type)