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

Free Support Forum - aspose.com

Aspose.Pdf converting pdf to tiff

Hello,


We just bought a license to Aspose.Totals and we are trying to convert a pdf file to tiff. The problem is some of the pages is not being converted to tiff. As an example I attached the result tiff file and the source pdf file. Below is the function we use to do the conversion.

//----------------------------------------------------------------------------------
private static bool PdfToTiff(string SourceFileName, string DestinationFileName)
{
bool ReturnResult = true;
TiffSettings tiffSettings;
PdfConverter pdfConverter;
string WorkDestinationFileName = Path.GetDirectoryName(DestinationFileName) +
@"\con_" + Path.GetFileName(DestinationFileName);
try
{
pdfConverter = new PdfConverter();
pdfConverter.Resolution = 300;
pdfConverter.BindPdf(SourceFileName);
pdfConverter.DoConvert();
// create TiffSettings object and set ColorDepth
tiffSettings = new TiffSettings();
tiffSettings.Depth = ColorDepth.Default;
tiffSettings.Compression = CompressionType.CCITT4;
// convert to TIFF image
pdfConverter.SaveAsTIFF(WorkDestinationFileName, 300, 300, tiffSettings);
pdfConverter.Close();
}
catch (Exception e)
{
ReturnResult = false;
WriteToEventLog(EventLogEntryType.Error,
“{0}\nException occurred during conversion \nFile:{1} \nType: {2}\nMessage:\n{3}”,
@"(PdfToTiff)", SourceFileName, e.GetType().FullName, e.Message);
}
finally
{
pdfConverter = null;
tiffSettings = null;
if (File.Exists(WorkDestinationFileName)) File.Move(WorkDestinationFileName, DestinationFileName);
}
return ReturnResult;
}

this is very urgent so any help would be greatly appreciated. Thank you !

Hi Rommel,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the template file and sample code.

I checked your issue with the latest version of Aspose.Pdf for .NET v6.5 and the generated Tiff is still showing problem (attached the resultant file for reference). The issue has been registered in our issue tracking system with issue id: PDFNEWNET-32600. You will be notified via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

No update yet in this issue ?

This issue has caused us unecessary expense in terms of man hours implementing this functionality for our client. It also strain our relationship with our customers. Since then we made a more detailed study on the problem. It appears that using the Aspose.pdf library in a multi threaded environment cause the pdfconverter to be interrupted and the effect is its failing to convert certain page in the pdf document. We know this because we isolated the code and place it in a small exe and then create instances of that exe to convert more than one document at a time and it performed as expected. So clearly the Aspose.pdf library is not capable of being use in a multi threaded scenario. Please correct me if I am wrong. I would have thought that your library is multi threaded capable. I would greatly appreciate any feedback
or advice on this issue. We need answers to this problem because this is an on going project.

Hi Rommel,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for the inconvenience.

I have shared the details provided by you with our development team and asked them to share the ETA regarding the resolution of the issue. I will update you as soon as I get a response from the development team.

Thank You & Best Regards,

Hello Rommel,


We are able to reproduce blank images results.
In case high load (multithreading is the best to simulate it), high resolution (300 is enough) there is probability for PdfConverter to break because of insufficient memory.

But we would like to ensure we had reproduced your mentioned issue but not other similar.

Could you please share a sample project that reproduces the issue, or answer some questions:

1. do you get any exceptions when PdfConverter works in multithreading environment and produces blank images?
2. are you able to get blank images result if much lower resolution is set (for example, 96DPI, 50DPI or so)

Depending on answers we may would like to ask additional questions.
Or reproducing project would be great.

Thanks!

//----------------------------------------------------------------------------------
public static bool PdfToTiff(string SourceFileName, string DestinationFileName)
{
bool ReturnResult = true;
Aspose.Pdf.Facades.PdfConverter pdfConverter;
string WorkDestinationFileName = Path.GetDirectoryName(DestinationFileName) +
@"\con_" + Path.GetFileName(DestinationFileName);
try
{
pdfConverter = new PdfConverter();
pdfConverter.Resolution = 300;
pdfConverter.BindPdf(SourceFileName);
pdfConverter.StartPage = 1;
pdfConverter.EndPage = pdfConverter.PageCount;
pdfConverter.DoConvert();
if (File.Exists(WorkDestinationFileName)) File.Delete(WorkDestinationFileName);
pdfConverter.SaveAsTIFF(WorkDestinationFileName, CompressionType.CCITT4);
pdfConverter.Close();
}
catch (Exception e)
{
ReturnResult = false;
WriteToEventLog(EventLogEntryType.Error,
"{0}\nException occurred during conversion \nFile:{1} \nType:{2}\nMessage:\n{3}",
@"(PdfToTiff)", SourceFileName, e.GetType().FullName, e.Message);
}
finally
{
if (File.Exists(WorkDestinationFileName))
File.Move(WorkDestinationFileName, DestinationFileName);
pdfConverter = null;
GC.Collect();
}
return ReturnResult;
}

Above is the function that is wrapped in paramatized thread that do the conversion. Because of the problems we were having there were alot of variation but we ended up using this function to convert the pdf. We are using vistual studio 2010. Yes we did get exceptions but not consistently. Running the same pdf files in various iterations we get "out of memory exceptions" and "invalid parameter exceptions"but I have to emphasize that in some iterations we did not get those errors. I thing is consistent though we do get blank pages. I have changed the resolution from 90 to 500 and the result is still the same. I have attached the 10 pdfs that we use for testing.

Hi Rommel,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the details, sample code and template PDF files.

All the details have been shared with our development team. Please give us some time to thoroughly analyze your issue. As soon as we have any update, we will notify you via this forum thread.

Thank you for being patient,

Hello Rommel,

We were able to reproduce non-memory related failures with old versions of the Aspose.Pdf.
It looks like you use 6.4.1 or earlier versions.

Please upgrade to 6.5.
You may download it here:
http://www.aspose.com/community/files/51/.net-components/aspose.pdf-for-.net/entry348420.aspx

Please also overview PdfConverter related API changes here:
https://blog.aspose.com/2011/12/13/add-page-background-optimized-performance-better-memory-management

The 6.5 upgrade solves multithreading issues, but out of memory cases will still be in place.

There will be memory management improvements in our next release.
And the probability out of memory failures is going to be lower.

So, as immediate solution you may upgrade to 6.5, and to manage out of memory issues you may implement some retry logic when exception happens (out of memory or parameter not valid (which is the same)).
I argee that it is not the best solution but it unblocks your application right now while we are working on memory management improvements.

Thanks!

Thank you for your quick reply. I actually want to download the latest Aspose.Totals Library since we I have a license for that product. I assumed Aspose.Totals should contain all the latests libraries including Aspose,pdf. Can you provide me a link where I can download the latest Aspose.Total Library for .NET.

Hello Rommel,

You may download the Aspose.Total for .NET here:
http://www.aspose.com/community/files/51/.net-components/aspose.total-for-.net/default.aspx

Hello Rommel,


Adding more to Igor’s response, you may visit the following link to explicitly download the latest version of Aspose.Pdf for .NET 6.5.0.

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


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