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

Free Support Forum - aspose.com

Need Attachment to tiff conversion

We are converting email attachments to TIFF images in C#. But we are not able to convert the attachments to TIFF when the attachments having color pages.

Please provide the code and dll for implementing it.

Attached one sample file which is having color images.

Hi Anish,

Thanks for your inquiry. The shared document have size 0kb. It would be great if you please share following detail for investigation purposes. I will investigate the issue on my side and provide you more information.


  • Please attach your input Word document.
  • Please attach the output Tiff file that shows the undesired behavior.

Thanks for the reply Tahir.


I have attached the input PDF file and the output TIFF file. When we try to convert we are getting the TIFF as corrupted.

Hi Anish,

Thanks for sharing the detail. Your query is related to Aspose.Pdf. I am moving this forum thread to Aspose.Pdf forum. My colleagues from Aspose.Pdf team will reply you shortly.

Hi Anish,


Thanks for sharing the resource files.

I have tested the scenario using Aspose.Pdf for .NET 10.9.0 while using following code snippet in VisualStudio 2010 project with .NET Framework 4.0 running over Windows 7 (x64) and I am unable to notice any issue. For your reference, I have attached the output generated over my end.

[C#]

//open document<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/merged+(4).pdf");

//create Resolution object

Resolution resolution = new Resolution(300);

//create TiffSettings object

TiffSettings tiffSettings = new TiffSettings();

tiffSettings.Compression = CompressionType.CCITT4;

tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;

tiffSettings.SkipBlankPages = false;

//create TIFF device

TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);

//convert a particular page and save the image to stream

tiffDevice.Process(pdfDocument,
“c:/pdftest/merged+(4)_output.tif”);

Thanks Nayyer for the codes.


But we are using .Net framework 3.5 and Aspose DLL version 5. The above methods are not available in aspose 5. We cannot upgrade our .Net framework.
Is there any methods available for this with aspose 5.

Thanks
Lijo

Hi Anish,


Aspose.Pdf for .NET 5.0.0 is quite old release and above mentioned code was introduced in MergedAPI starting release 6.0.0, so we recommend you to please try migrating to latest release of Aspose.Pdf for .NET 10.9.0 and also please note that this release is compatible with .NET Framework 3.5.

We also suggest you to please visit the following links for further details on

Thanks Nayyer.


I tried with above code and its working fine.
We are using 3.5 framework version of aspose.pdf 9.1 DLL.
But after creating TIFF one watermark text also coming in image as "Evaluation period only.Created with aspose.pdf. Copyright 2002-2014…"

below mentioned is our licence details:

20140607
2.2

Please reply me.

anishvj:

We are using 3.5 framework version of aspose.pdf 9.1 DLL.

But after creating TIFF one watermark text also coming in image as “Evaluation period only.Created with aspose.pdf. Copyright 2002-2014…”

below mentioned is our licence details:

20140607

2.2
Hi Anish,

The evaluation watermark appears when license is expired and the version of API you are trying to use is published after the API release. As per above information, your license only supports the API versions published before 07June2014. Before your upgrade your license subscription, you may consider requesting a 30 days temporary license to test the latest release versions. For more information, please visit Get a temporary license

Ok Thanks Nayyer.



Also please give me code for converting TEXT file to TIFF and WORD to TIFF.

anishvj:
Also please give me code for converting TEXT file to TIFF

Hi Anish,

Please try using following code snippet to accomplish your requirements.

[C#]

var pdfDocument = new Document();<o:p></o:p>

pdfDocument.Pages.Add();

//Specify the location of input text file

String FILE_NAME = "c:/pdftest/convertlog.txt ";

if (File.Exists(FILE_NAME))

{

System.IO.TextReader objReader = new System.IO.StreamReader(FILE_NAME);

// Read the file till the end of the file has come

do

{

//Create a new text paragraph & pass text to its constructor as argument

Aspose.Pdf.Text.TextFragment text1 = new Aspose.Pdf.Text.TextFragment(objReader.ReadLine());

// add the text object to paragraphs collection of section

pdfDocument.Pages[1].Paragraphs.Add(text1);

// Read till the end of file

} while (objReader.Peek() != -1);

// Close the StreamReader object

objReader.Close();

}

else

MessageBox.Show("File Does Not Exist");

// Save the PDF file

//pdfDocument.Save("c:/pdftest/FinalMergedFile.pdf");

pdfDocument.ProcessParagraphs();

//create Resolution object

Resolution resolution = new Resolution(300);

//create TiffSettings object

TiffSettings tiffSettings = new TiffSettings();

tiffSettings.Compression = CompressionType.CCITT4;

tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;

tiffSettings.SkipBlankPages = false;

//create TIFF device

TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);

//convert a particular page and save the image to stream

tiffDevice.Process(pdfDocument, "c:/pdftest/TXT_PDFoutput.tif");

pdfDocument.Dispose();

For further details, please visit


anishvj:
and WORD to TIFF.
Please visit the following ink for required information on How to Save Document as a Multipage TIFF

Thanks.


Please provide ppt to tiff conversion code also…

anishvj:
Please provide ppt to tiff conversion code also…
Hi Anish,


In order to accomplish this requirement, you need to try using Aspose.Slides for .NET. Please visit the following link for further information on Converting Presentation to TIFF

Thanks I got it.


One more issue we are facing is after converting attachments to TIFF, the attachment size is much bigger. Is there any way to reduce the tiff.

this is the setting we are using…

Resolution resolution = new Resolution(150);
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Compression = CompressionType.LZW;
tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;


Pls check and reply…

Hi Anish,


In order to reduce the size of resultant TIFF image, you may consider using various values from CompressionType and ColorDepth enumerations. In case you still face any issue, please share the resource PDF document, so that we can test the scenario in our environment.

Thanks for the reply.


I have attached the PDF file and converted TIF file here. PDF was 35kb size and TIF became 961kb size. We need to convert as color images.

This is the code i am using for PDF to TIF conversion.

Document pdfDocument = new Document(FileName);
Resolution resolution = new Resolution(96);
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Compression = CompressionType.LZW;
tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;
tiffSettings.SkipBlankPages = false;
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
string outputTiffName = FileName.Replace(Path.GetExtension(FileName), “.tif”);
tiffDevice.Process(pdfDocument, outputTiffName);

I tried with some other compression type also, but i got color TIF in less size with LZW.
Please have a look and help me to reduce the size.

Thanks.

Hi Anish,


Thanks for sharing the details.

As per my observations, the input PDF file is Black&White and if you use any value from ColorDepth enumeration, the output file will still be Black&White. In order to compress the size of resultant TIFF image, you need to use the value from CompressionType enumeration. However if you need to have maximum compressed output, you will have to comprise on color information and in case you need to have colored output, the size of output will not be much compressed. When using following code snippet, the output file size is 98 KB.

[C#]

Document pdfDocument = new Document(“c:/pdftest/Herrington±+%23+PA0016467846-01++Supp.+%23+2.pdf”);<o:p></o:p>

Resolution resolution = new Resolution(96);

TiffSettings tiffSettings = new TiffSettings();

tiffSettings.Compression = CompressionType.CCITT4;

tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;

tiffSettings.SkipBlankPages = false;

TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);

tiffDevice.Process(pdfDocument,
“c:/pdftest/Herrington±+%23+PA0016467846-01++Supp.+%23+2_compressed.tiff”);

Thanks for the details Nayyer.



tiffSettings.Compression = CompressionType.CCITT4;
The above compression type will convert as black and white right, even if the pdf is color.
I wanted to convert as color tiff with maximum compressed size. So for that the above type not work right ?

Thanks
Lijo

Hi Anish,


Yes your understanding is correct. When using CompressionType as CCITT4, the output will be much compressed and color information is removed.

ok , thanks nayyer.


I need one more help.
I am using aspose dll for conveting PDF to TIF image.
Also I want to extract images from the pdf file (if pdf is having any images) and save to a location.

Please let me know any aspose methods provides solution for this.

Thanks
Lijo