Convert TIF to PDF System.OutOfMemoryException

Hello,



When i want convert this TIF file to PDF. An exeption “System.OutOfMemoryException” is rised.



Can you help me.



PS: I use the lastest version of Aspose.Imaging and PDF.



[vb.net]

If Args.Count.Equals(1) Then



Dim licencePDF As New Aspose.Pdf.License

licencePDF.SetLicense(“aspose.lic”)

Dim licenceImage As New Aspose.Imaging.License

licenceImage.SetLicense(“aspose.lic”)



Dim FQDN As String = Args(0)

Dim File As String = Split(FQDN, "").Last

Dim Path As String = Replace(FQDN, File, “”)



Dim fs As New FileStream(FQDN, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)

Dim FichierTIF As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(fs)

Dim FichierTIFStream As New MemoryStream()

FichierTIF.Save(FichierTIFStream, New Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default))

'Dim tmpBytes As Byte() = New Byte(Convert.ToInt32(fs.Length - 1)) {}

'fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length))



Dim pdf As New Aspose.Pdf.Document()



Dim b As New Bitmap(FichierTIFStream)

’ Create a new section in the Pdf document

Dim dimension As New Imaging.FrameDimension(b.FrameDimensionsList(0))

Dim framesCount As Integer = b.GetFrameCount(dimension)

Dim sec As Aspose.Pdf.Page



For frameIdx As Integer = 0 To framesCount - 1



b.SelectActiveFrame(dimension, frameIdx)

Dim currentImage As New MemoryStream()

b.Save(currentImage, System.Drawing.Imaging.ImageFormat.Tiff)



sec = pdf.Pages.Add()

sec.PageInfo.Height = b.Height

sec.PageInfo.Width = b.Width



Dim imageht As Aspose.Pdf.Image = New Aspose.Pdf.Image()

'imageht.ImageInfo.ImageFileType = ImageFileType.Tiff

imageht.ImageStream = currentImage

currentImage.Dispose()

Next

'Dim pdfa As New Aspose.Pdf.Document(Path & Replace(File, “.tif”, “.pdf”))

pdf.Convert(New MemoryStream(), Aspose.Pdf.PdfFormat.PDF_A_1A, Aspose.Pdf.ConvertErrorAction.Delete)

Dim pdfOptimizeResources As New Aspose.Pdf.Document.OptimizationOptions()

pdfOptimizeResources.RemoveUnusedObjects = True

pdfOptimizeResources.RemoveUnusedStreams = True

pdfOptimizeResources.AllowReusePageContent = True

pdfOptimizeResources.CompressImages = True

pdf.OptimizeResources(pdfOptimizeResources)

pdf.Save(Path & Replace(File, “.tif”, “.pdf”, 1, -1, CompareMethod.Text))

Else

MsgBox(“Problème avec l’argument passé en paramètre.”, MsgBoxStyle.Critical, “ERREUR”)

End If

Hi Nicolas,

Thank you for your inquiry and sharing sample.

This is to update you that Aspose.Pdf is the correct forum to deal with your query. I am forwarding your post to Aspose.Pdf support forum where my colleague from Aspose.Pdf support will guide you properly.

Hi Aspose support !

Can you give me any news ?

Thanks,

Hi Nicolas,

Thanks for contacting support.

The earlier shared TIFF image appears to be corrupted, so can you please share the input TIFF image, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Hi Codewarior,



This TIF working fine for me. I can open it with XnView for example.



In attachment two files who meet an issue when I convert to PDF.



Either I have a error message wither the converted file do 0 ko.



Thanks you very much for your help.

Paga16:
Hi Codewarior,

This TIF working fine for me. I can open it with XnView for example.

In attachment two files who meet an issue when I convert to PDF.

Either I have a error message wither the converted file do 0 ko.

Thanks you very much for your help.

Hi Nicolas,

Thanks for sharing the sample files.

I have tested the scenario of TIFF to PDF conversion and have managed to reproduce following issues.

  • 4922601.TIF - An OutOfMemory Exception during conversion. The problem is logged in our issue tracking system as PDFNET-42004.
  • 6318111.TIF - An OutOfMemory Exception during conversion. The problem is logged in our issue tracking system as PDFNET-42005.

We will further look into the details of these problems and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.