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

Free Support Forum - aspose.com

TIFF to PDF

I have been trying for the past several days to convert a .Tiff file into a .PDF file and have not had any success. I have tried the code listed in the word documentation but most pages just show a big x image.





I have also tried various methods found in the forums and documentation for all products and have yet to find a solution that can create the desired output.





I do know that the image can be converted as proven by using ‘Office Convert Image TIFF Jpeg to PDF Free’ this application will produce the images as individual files but each one is actually readable.





When I use the .PDF Generator process I am only able to get a very low resolution .PDF if the IsBlackWhite value is True, when False the output is a zero bitted .PDF file???





How can I get a 100-200 page tiff converted to a .PDF





I would add a sample file but so far I have not been able to attach the 90 mb + file via this forum UI.





Thank You.

Hi Earl,<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>Thanks for contacting support.<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>Our forums support file upload feature up-to 25MB. <div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>

Jagsoft:
I would add a sample file but so far I have not been able to attach the 90 mb + file via this forum UI
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>You may either upload the file to some free file sharer and share the link with us or Archive the document inot multiple instances and then try uploading them in multiple posts. Once we have the input file, we will test the scenario and will keep you updated on the status of correction. We are sorry for this inconvenience.

Ok, I am uploading the file as 4 separate zip files with the 7-Zip split tiff files.


Please keep this information confidential as it has very sensitive information.

Hi Earl,


Thanks for sharing input file.

I have tested the scenario of TIFF to PDF conversion using Document Object Model of com.aspose.pdf package of Aspose.Pdf for Java 17.2.0 and as per my observations, the resultant file is being created but first frame is missing in output file i.e. input TIFF contains 12 frames whereas in resultant PDF, there are only 11 frames.

For the sake of correction, I have logged it as PDFJAVA-36567 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Hi Earl,


You may consider visiting this link to download output generated with Aspose.Pdf for Java 17.2.0.

I am not licensed to use the Java version of Aspose. I only have access to the .NET versions.


The file that I sent has been successfully created using a different product “PDFSharp” and should have 161 pages.

I am unable to successfully extract the .PDF file from the .zip file that was placed on Dropbox.

EDIT: I was finally able to get this file downloaded and viewed but it has only 11 pages???

Thank You,

Hi Earl,


Thanks for sharing the details.

I have again tested the scenario of input TIFF image which contains 39 frames (as shown in attached image file) and as per my observations, the resultant PDF contains all 30 frames. I have used Aspose.Pdf for .NET 17.2.0 in VisualStudio 2015 running over Windows 10 and I am unable to notice any issue.

I wonder how you are getting 161 pages when using PDFSharp. Can you please double check the input TIFF image and share your observations. Please get the resultant file from this link.

[C#]

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();<o:p></o:p>

Aspose.Pdf.Image image = new Aspose.Pdf.Image();

// provide information for source/input TIFF image

image.File= @"C:\pdftest\00206B92A9AE170307105147.tif";

// add page to pages collection of DOC object

doc.Pages.Add();

// add TIFF image to paragraphs collection of first page

doc.Pages[1].Paragraphs.Add(image);

// save resultant PDF file

doc.Save(@“C:\pdftest\00206B92A9AE170307105147.pdf”);

I have also downloaded the original files uploaded and still see 161 pages in this multi-page tiff file using Aspose.Word .NET 17.2.0. I am running Windows 7 and also testing on Windows Server 2012 R2. Please see the results from the attached split pdf files.


Here is the VB code that I am running.

Public Function ConvertImageToPdf(inputFilename As String) As String
Dim retval As String = inputFilename
If Not String.IsNullOrEmpty(inputFilename) AndAlso IO.File.Exists(inputFilename) Then
Dim doc As Aspose.Words.Document = New Aspose.Words.Document
Dim builder As Aspose.Words.DocumentBuilder = New Aspose.Words.DocumentBuilder(doc)
Using image As Image = image.FromFile(inputFilename)
Dim dimension As FrameDimension = New FrameDimension(image.FrameDimensionsList(0))
Dim framesCount As Integer = image.GetFrameCount(dimension)
For frameIdx As Integer = 0 To framesCount
Try
If Not frameIdx = 0 Then
builder.InsertBreak(BreakType.SectionBreakNewPage)
End If
image.SelectActiveFrame(dimension, frameIdx)
Dim ps As PageSetup = builder.PageSetup
ps.PageWidth = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution)
ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution)
Console.Clear()
Console.Write(“Processing image {0} of {1}.”, frameIdx.ToString, framesCount.ToString)
builder.InsertImage(image, RelativeHorizontalPosition.Page, 0, RelativeVerticalPosition.Page, 0, ps.PageWidth, ps.PageHeight, WrapType.None)
Catch ex As Exception
Console.WriteLine(ControlChars.CrLf & "Failed to include Frame " & frameIdx.ToString & " due to ERROR: " & ex.Message)
End Try
Next
retval = IO.Path.Combine(IO.Path.GetDirectoryName(retval), IO.Path.GetFileNameWithoutExtension(retval) & “.pdf”)
Try
Console.WriteLine(“Saving ‘{0}’.”, retval)
doc.Save(retval)
Console.WriteLine(“Document ‘{0}’ has been saved.”, retval)
Catch ex As Exception
Console.WriteLine("FAILED TO SAVE: " & ex.Message)
retval = inputFilename
End Try
End Using
End If
Return retval
End Function

Hi Earl,

Thanks for sharing the sample output. I am further looking into this matter and will update you shortly.

Hi Earl,


Thanks for your patience. I have tested the whole scenario using Aspose.Pdf for .NET v17.3.0 and did not notice any issue with the generated output file. I have used the same code snippet which Nayyer has shared earlier for TIFF to PDF Conversion. The TIFF which you have shared has 161 frames and the generated PDF also has 161 pages. There are no error image(s) (i.e big X images) in the resultant file. You may download output file from here and join the split parts using WinRAR.

Please try using Aspose.Pdf v17.3.0 for TIFF to PDF Conversion and in case if you still face any problem please feel free to contact us.


Best Regards,

It looks like this still has issues as most of the large multipage tiffs that I processed encountered an ‘Out of Memory’ error including the file used for this support issue.

I have tested this on 3 different machines, Windows 7 with 16GB ram, Windows Server 2008R2 with 8GB ram, and Windows Server 2012R2 with 4GB ram, all with the same issue.

Hi Earl,


Thanks for sharing more details. For the sake of testing I have processed large TIFF (i.e size of 3.98GB) from one of my samples and I did not notice any OutOfMemory exception. A PDF file has been generated without raising any exception. I have tested the scenario on a machine with Windows 10 and 8GB of RAM installed on it.

Please note that sometimes issue may be related with some specific input file(s). To reproduce the earlier stated exception in our environment we will need that specific file with which you are facing the issue. We will really appreciate if you please share that file with us. We will test the scenario again and update you accordingly. We are sorry for the inconvenience.


Best Regards,

I have experienced this issue with the .TIFF file that has been uploaded as part of this incident.

Please test using this file and let me know. Thanks,

Hi Earl,


Thanks for writing back. I have again tested the scenario with the file which you have shared earlier and I was unable to notice the issue. I have run the scenario in x64 mode of debugging. But when I switched mode of debugging to x86, I encountered an OutOfMemory Exception.

Please note that in order to process large files you need to set the debugging mode to x64 so that your program can access full memory. When you run a program in x86 or 32-bit mode, it only have access to 2GB of memory regardless of how much size of RAM you have installed. As a result code throws OutOfMemory Exception. To get large files processed and take benefits of complete memory your program should be executed in x64 mode.

Please try using x64 mode to process the large file(s) and in case if you still encounter same exception in x64 mode please let us know.


Best Regards,

Thank You, It appears that x64 was the issue.

It now looks like it is working.

Hi Earl,


Thanks for your feedback. It is good to know that your issue has been resolved. In event of any further inquiry please feel free to contact us. We will be happy to extend our support.


Best Regards,

It all is working until I add the ConversionProgressEventHandler once I add the handler the PDF save goes real quick and then the output document is left unreadable???


This is the code that I am using:

Private Function ConvertTiffToPDF(filepath As String) As String
Dim retval As String = filepath
If Not String.IsNullOrEmpty(filepath) AndAlso IO.File.Exists(filepath) Then
Try
Dim newFileName As String = IO.Path.Combine(IO.Path.GetDirectoryName(filepath), IO.Path.GetFileNameWithoutExtension(filepath) & “.pdf”)
Dim doc As New Aspose.Pdf.Document()
Dim image As Aspose.Pdf.Image = New Aspose.Pdf.Image()
image.File = filepath
doc.Pages.Add()
doc.Pages(1).Paragraphs.Add(image)
Try
WriteToOutput(ControlChars.Tab & “Saving '” & newFileName & “’…”)
Dim saveOptions As New Aspose.Pdf.DocSaveOptions
saveOptions.CustomProgressHandler = New Aspose.Pdf.UnifiedSaveOptions.ConversionProgressEventHandler(AddressOf RaiseOnProgressEvent)
doc.Save(newFileName)
WriteToOutput(ControlChars.Tab & “Save has completed for file '” & newFileName & “’.”)
retval = newFileName
Catch ex As Exception
WriteToOutput(ControlChars.Tab & "Failed to convert file. ERROR: " & ex.Message & ControlChars.CrLf)
retval = filepath
End Try
Catch ex As Exception
WriteToOutput(ControlChars.Tab & "Failed to convert file. ERROR: " & ex.Message & ControlChars.CrLf)
retval = filepath
End Try
End If
Return retval
End Function

Hi Earl,

Thanks for sharing code snippet. I have tested the scenario in my environment and noticed that the API is generating unreadable/corrupted PDF when we use DocSaveOptions to save the document. As this issue was reported in [this](https://forum.aspose.com/t/12005) thread by you and I already have logged it as PDFNET-42475 in our issue tracking system. So I am associating issue ID with this thread as well so that you may be notified about the status of its resolution. Please be patient and spare us a little time. We are sorry for the inconvenience.

Best Regards,

It appears there are issues with this process while running in Windows Server Standard 2008 SP2.

I can run the attached project on Windows Server Standard 2008 R2 SP1 with no issues but when run on the 2008 SP2 server I receive the following error: “Parameter is not valid”.

Is there something I need to do to get this to work on the 2008 SP2 server? This is an x64 server with 8GB ram.

Thanks,
Earl

Hi Earl,


Thanks for contacting support.

I am testing the scenario in the stated environment and will share my findings with you shortly. Please be patient.


Best Regards,