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

Free Support Forum - aspose.com

Poor quality when Converting PDF to TIF with v8.2 in comparison to PNG

Hi,


I saw that different evolutions/fixes have been made to PDF.NET v8.2 for tif creation so I tried it to see if the quality of the conversion of a PDF to TIF was better with that version. Unfortunately please see the attached samples. They are parts of the images (TIF and PNG) obtained after the conversion:
- the PNG conversion is really good => the text is rendered optimally
- the TIF conversion is poor => I think you could try to find a better way to do the conversion because the current one leads to a serious quality loss.
I thought that Aspose could be in my case a good alternative to a TIF printer driver but today I am not really convinced.

Here is the code I used : in both cases I ask the library a resolution of 300dpi; I think in the TIF case this parameter is not really used…

TIF:
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(FullInputFileName);
Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();
            tiffSettings.Compression = Aspose.Pdf.Devices.<span style="color:#2b91af;">CompressionType</span>.CCITT4;
            tiffSettings.Depth = Aspose.Pdf.Devices.<span style="color:#2b91af;">ColorDepth</span>.Default;

            <span style="color:green;">//create TIFF device</span>
            Aspose.Pdf.Devices.<span style="color:#2b91af;">TiffDevice</span> tiffDevice = <span style="color:blue;">new</span> Aspose.Pdf.Devices.<span style="color:#2b91af;">TiffDevice</span>(resolution, tiffSettings);
            
            <span style="color:blue;">for</span> (<span style="color:blue;">int</span> page = 1; page <= pdfDocument.Pages.Count; page++)
            {
                <span style="color:blue;">using</span> (<span style="color:#2b91af;">Stream</span> output = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>())
                {
                    tiffDevice.Process(pdfDocument, page, page, output);
                    System.Drawing.<span style="color:#2b91af;">Image</span> newPage = System.Drawing.<span style="color:#2b91af;">Image</span>.FromStream(output);
                    newPage.Save(<span style="color:#2b91af;">Path</span>.Combine(OutputFolder, <span style="color:#2b91af;">String</span>.Concat(<span style="color:#2b91af;">Path</span>.GetFileNameWithoutExtension(FullInputFileName), <span style="color:#a31515;">"."</span>, page.ToString().PadLeft(3, <span style="color:#a31515;">'0'</span>), <span style="color:#a31515;">".tif"</span>)));
                } </pre><div><span style="background-color: white; font-family: Consolas; font-size: 13px;">                }</span></div><div><br></div><div>PNG:  </div><div><br></div><div><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">Aspose.Pdf.<span style="color:#2b91af;">Document</span> pdfDocument = <span style="color:blue;">new</span> Aspose.Pdf.<span style="color:#2b91af;">Document</span>(FullInputFileName);
            Aspose.Pdf.Devices.<span style="color:#2b91af;">PngDevice</span> device = <span style="color:blue;">new</span> Aspose.Pdf.Devices.<span style="color:#2b91af;">PngDevice</span>(<span style="color:blue;">new</span> Aspose.Pdf.Devices.<span style="color:#2b91af;">Resolution</span>(300));

            <span style="color:blue;">for</span> (<span style="color:blue;">int</span> page = 1; page <= pdfDocument.Pages.Count; page++)
            {
                <span style="color:blue;">using</span> (<span style="color:#2b91af;">Stream</span> output = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>())
                {
                    device.Process(pdfDocument.Pages[page],output);
                    System.Drawing.<span style="color:#2b91af;">Image</span> newPage = System.Drawing.<span style="color:#2b91af;">Image</span>.FromStream(output);
                    newPage.Save(<span style="color:#2b91af;">Path</span>.Combine(OutputFolder, <span style="color:#2b91af;">String</span>.Concat(<span style="color:#2b91af;">Path</span>.GetFileNameWithoutExtension(FullInputFileName), <span style="color:#a31515;">"."</span>, page.ToString().PadLeft(3, <span style="color:#a31515;">'0'</span>), <span style="color:#a31515;">".png"</span>)));
                }
            }</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">Any solution would be really appreciated.</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;"><br></pre></div>

Hi there,

Sorry for the inconvenience faced. While using the latest version of Aspose.Pdf for NET 8.2.0, I've managed to reproduce image quality issue on my side and logged a feature enhancement issue in our bug tracking system as PDFNEWNET-35592 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,

Hi Daniel,


Thanks for your patience. You can use CompressionType.None to eliminate quality difference. Hopefully it will serve the purpose.

tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.None;

Please feel free to contact us for any further assistannce.

Best Regards,

Hi,

Thanks you for the answer but when you set the compression to none it expands the size of the tif file to 1MB per page. Today, if my boss asks me why a B&W PDF is transformed into a 1MB x N pages document it is hard to explain ...

Using B&W CCITT4 would compress to the image to a reasonable size... (and for most office docs B&W is an acceptable solution.).

For the moment, I am unable to use your component because of that and I hate using a TIFF printer driver :)

Hi Daniel,


Thanks for your feedback. After initial investigation, I’ve shared your findings with our development team. We will keep you updated about issue progress via this forum thread.

Sorry for the inconvenience faced.

Best Regards,

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

The blog post for this release is created over this link


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

Hi Daniel,


Thanks for your patience. Please use following code snippet, hopefully it will help you to accomplish the task.


Aspose.Pdf.Document pdfDocument = new
Aspose.Pdf.Document(“Input.pdf”);<o:p></o:p>

Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);

Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();

tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.None;

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

//create TIFF device

Aspose.Pdf.Devices.TiffDevice tiffDevice = new Aspose.Pdf.Devices.TiffDevice(resolution, tiffSettings);

for (int page = 1; page <= pdfDocument.Pages.Count; page++)

{

using (Stream output = new MemoryStream())

{

tiffDevice.Process(pdfDocument, page, page, output);

System.Drawing.Image newPage = System.Drawing.Image.FromStream(output);

string outputImageFile = "Page"+page+".tif";

newPage.Save(outputImageFile);

}

}

Please feel free to contact us for any further assistance.


Best Regards,

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan