We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Conversion of large TIF file to PDF fails

Hi there.

I have a task of displaying pdf-files in a browser. As the files are stored in the tif image format I need to convert the files to PDF. I have experimented with code provided on the Aspose web site. However, it doesnt seem to work consistently. Can you help me out here?

To test I used the chrysanthemum.jpg example image that comes with Windows. I edited it in paint.NET and saved it as a tif file. I also edited the image by copy pasting the image content. That gave me an image around 10Mb. The files are attached.

I used the code example found here: http://www.aspose.com/docs/display/pdfnet/Performance+Improvement+while+converting+TIFF+to+PDF

My test results show that when swithing the IsBlackWhite property:
  1. Converting the small Tif image works in both color and black n white
  2. Converting the large Tif image works in black n white
  3. Converting the large Tif image in color DOES NOT WORK. The generated pdf file has a size of zero bytes.
My setup:
-Windows 7 Pro 64bit
-Aspose.pdf .NET 3.5

My code:
Private Sub DoItLikeAspose()

Dim outDir As String = “C:\temp\tifftest”

'get a list of tiff image files
Dim files As New List(Of String)

'Instantiate a Pdf object
Dim pdf1 As New Aspose.Pdf.Generator.Pdf()

'navigate through the files and them in the pdf file
Dim myFile As String
For Each myFile In files

'Load all tiff files in byte array
Dim fs As New FileStream(myFile, FileMode.Open, FileAccess.Read)
Dim tmpBytes As Byte() = New Byte(fs.Length - 1) {}
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length))

Dim mystream As New MemoryStream(tmpBytes)
Dim b As New Bitmap(mystream)

'Create a new section in the Pdf document
Dim sec1 As New Aspose.Pdf.Generator.Section(pdf1)

'Set margins so image will fit, etc.
sec1.PageInfo.Margin.Top = 5
sec1.PageInfo.Margin.Bottom = 5
sec1.PageInfo.Margin.Left = 5
sec1.PageInfo.Margin.Right = 5

sec1.PageInfo.PageWidth = (b.Width / b.HorizontalResolution) * 72
sec1.PageInfo.PageHeight = (b.Height / b.VerticalResolution) * 72
'Add the section in the sections collection of the Pdf document

'Create an image object
Dim image1 As New Aspose.Pdf.Generator.Image(sec1)

'Add the image into paragraphs collection of the section
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff
'set IsBlackWhite property to true for performance improvement
'image1.ImageInfo.IsBlackWhite = True
'Set the ImageStream to a MemoryStream object
image1.ImageInfo.ImageStream = mystream


'Save the Pdf
pdf1.Save(outDir + “OutputFile.pdf”)

End Sub

Hi there,

Sorry for the inconvenience faced. While using the latest version of Aspose.Pdf for NET 8.3.0, I've managed to reproduce this issue on my side and logged the issue in our bug tracking system as PDFNEWNET-35716 for further investigation and resolution. I've also linked your request to this issue and you will be notified via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,


Can you tell me if a fix for this is in your development pipeline? To be able to plan my development, I would like to know when a fix for this can be expected.

Jonas Toft

Hi Jonas,

Thanks for your inquiry. Our development team is looking into issue and I’m afraid its not resolved completely. We are coordinating with our development for the updates and will also update you accordingly.

Thanks for your patience and cooperation.

Best Regards,

Hi there. I noticed that according to the changelog found here: http://www.softpedia.com/progChangelog/AsposePdf-Changelog-11344.html

the issue seems to have been resolved. It states that:

  • Exception is occurring while creating a PDF document
  • OutOfMemoryError during large PDF generation
  • TIFF to PDF conversion throws exception
  • Exception while flattening the PDF document
  • OutOfMemoryException during Image to PDF conversion
  • Exception while opening the PDF file
  • NullReferenceException when loading PDF file
And further below:
  • TIFF to PDF - Resultant PDF is 0KB

So it would seem as though the error has been resolved. Now I dont get the 0kb error any longer. I do, however, get an OutOfMemoryException. I notice that in my dev environment that about 400Mb RAM is used when calling Pdf.Save(stream).So this raises the following questions:

1. Has the original error been resolved?
2. If yes, should I not have been informed?
3. If yes, how much RAM should be available for TIFF to pdf conversion? Given the changelog, I assume you have some kind og table comparing file size/Ram requirements. Tiff-files are often greater in size that a jpeg so 10Mb should be no problem in my world.

Jonas Toft

Hi Jonas,

Thanks for your inquiry. I am afraid your reported issue is still not resolved. Our development team has investigated the issue and found it is because of GDI limitations. So our development team is working over to implement our custom image encoder(Aspose.Imaging) in Aspose.Pdf. Your issue will be fixed as soon as it is implemented.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35716) have been fixed in Aspose.Pdf for .NET 11.1.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.